2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2009 On-Core
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-09 01:23:11 +08:00
|
|
|
https://axis-project.github.io/
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCActionGrid3D.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/CCDirector.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2013-06-20 14:13:12 +08:00
|
|
|
// implementation of Waves3D
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
Waves3D* Waves3D::create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Waves3D* action = new Waves3D();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration, gridSize, waves, amplitude))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2016-04-08 13:40:36 +08:00
|
|
|
action->autorelease();
|
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2016-04-08 13:40:36 +08:00
|
|
|
delete action;
|
|
|
|
return nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
bool Waves3D::initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if (Grid3DAction::initWithDuration(duration, gridSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
_waves = waves;
|
|
|
|
_amplitude = amplitude;
|
2013-06-15 14:03:30 +08:00
|
|
|
_amplitudeRate = 1.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Waves3D* Waves3D::clone() const
|
2013-06-19 06:06:53 +08:00
|
|
|
{
|
2015-01-08 10:22:45 +08:00
|
|
|
// no copy constructor
|
2016-04-08 13:40:36 +08:00
|
|
|
return Waves3D::create(_duration, _gridSize, _waves, _amplitude);
|
2013-06-19 06:06:53 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Waves3D::update(float time)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
2013-06-15 14:03:30 +08:00
|
|
|
for (i = 0; i < _gridSize.width + 1; ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
for (j = 0; j < _gridSize.height + 1; ++j)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2019-09-25 14:32:26 +08:00
|
|
|
Vec2 pos((float)i, (float)j);
|
|
|
|
Vec3 v = getOriginalVertex(pos);
|
2021-12-25 10:04:45 +08:00
|
|
|
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y + v.x) * 0.01f) * _amplitude * _amplitudeRate);
|
2022-07-16 10:43:05 +08:00
|
|
|
// AXLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude *
|
2021-12-25 10:04:45 +08:00
|
|
|
// _amplitudeRate));
|
2019-09-25 14:32:26 +08:00
|
|
|
setVertex(pos, v);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
// implementation of FlipX3D
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
FlipX3D* FlipX3D::create(float duration)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
FlipX3D* action = new FlipX3D();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2016-04-08 13:40:36 +08:00
|
|
|
action->autorelease();
|
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2016-04-08 13:40:36 +08:00
|
|
|
delete action;
|
|
|
|
return nullptr;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
bool FlipX3D::initWithDuration(float duration)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-10-23 23:27:14 +08:00
|
|
|
return Grid3DAction::initWithDuration(duration, Vec2(1, 1));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
bool FlipX3D::initWithSize(const Vec2& gridSize, float duration)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-12-26 18:59:31 +08:00
|
|
|
if (gridSize.width != 1 || gridSize.height != 1)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// Grid size must be (1,1)
|
2022-07-16 10:43:05 +08:00
|
|
|
AXASSERT(0, "Grid size must be (1,1)");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
return Grid3DAction::initWithDuration(duration, gridSize);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
FlipX3D* FlipX3D::clone() const
|
2013-06-16 10:44:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new FlipX3D();
|
2013-06-19 00:59:34 +08:00
|
|
|
a->initWithSize(_gridSize, _duration);
|
2015-01-08 10:22:45 +08:00
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-06-16 10:44:39 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void FlipX3D::update(float time)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
float angle = (float)M_PI * time; // 180 degrees
|
|
|
|
float mz = sinf(angle);
|
|
|
|
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
|
|
|
float mx = cosf(angle);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec3 v0, v1, v, diff;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-04-20 01:40:52 +08:00
|
|
|
v0 = getOriginalVertex(Vec2(1.0f, 1.0f));
|
|
|
|
v1 = getOriginalVertex(Vec2());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
float x0 = v0.x;
|
|
|
|
float x1 = v1.x;
|
|
|
|
float x;
|
|
|
|
Vec2 a, b, c, d;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (x0 > x1)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
// Normal Grid
|
2015-04-20 01:40:52 +08:00
|
|
|
a.setZero();
|
|
|
|
b.set(0.0f, 1.0f);
|
|
|
|
c.set(1.0f, 0.0f);
|
|
|
|
d.set(1.0f, 1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
x = x0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Reversed Grid
|
2015-04-20 01:40:52 +08:00
|
|
|
c.setZero();
|
|
|
|
d.set(0.0f, 1.0f);
|
|
|
|
a.set(1.0f, 0.0f);
|
|
|
|
b.set(1.0f, 1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
x = x1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
diff.x = (x - x * mx);
|
|
|
|
diff.z = fabsf(floorf((x * mz) / 4.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// bottom-left
|
2021-12-25 10:04:45 +08:00
|
|
|
v = getOriginalVertex(a);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.x = diff.x;
|
|
|
|
v.z += diff.z;
|
|
|
|
setVertex(a, v);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// upper-left
|
2021-12-25 10:04:45 +08:00
|
|
|
v = getOriginalVertex(b);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.x = diff.x;
|
|
|
|
v.z += diff.z;
|
|
|
|
setVertex(b, v);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// bottom-right
|
2013-07-08 23:05:47 +08:00
|
|
|
v = getOriginalVertex(c);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.x -= diff.x;
|
|
|
|
v.z -= diff.z;
|
|
|
|
setVertex(c, v);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// upper-right
|
2013-07-08 23:05:47 +08:00
|
|
|
v = getOriginalVertex(d);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.x -= diff.x;
|
|
|
|
v.z -= diff.z;
|
|
|
|
setVertex(d, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementation of FlipY3D
|
|
|
|
|
2013-07-08 23:05:47 +08:00
|
|
|
FlipY3D* FlipY3D::clone() const
|
|
|
|
{
|
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new FlipY3D();
|
2013-07-08 23:05:47 +08:00
|
|
|
a->initWithSize(_gridSize, _duration);
|
2015-01-08 10:22:45 +08:00
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-07-08 23:05:47 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
FlipY3D* FlipY3D::create(float duration)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
FlipY3D* action = new FlipY3D();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
action->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void FlipY3D::update(float time)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
float angle = (float)M_PI * time; // 180 degrees
|
|
|
|
float mz = sinf(angle);
|
|
|
|
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
|
|
|
float my = cosf(angle);
|
|
|
|
|
|
|
|
Vec3 v0, v1, v, diff;
|
|
|
|
|
2015-04-20 01:40:52 +08:00
|
|
|
v0 = getOriginalVertex(Vec2(1.0f, 1.0f));
|
|
|
|
v1 = getOriginalVertex(Vec2());
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
float y0 = v0.y;
|
|
|
|
float y1 = v1.y;
|
2012-08-01 15:30:12 +08:00
|
|
|
float y;
|
2021-12-25 10:04:45 +08:00
|
|
|
Vec2 a, b, c, d;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (y0 > y1)
|
|
|
|
{
|
|
|
|
// Normal Grid
|
2015-04-20 01:40:52 +08:00
|
|
|
a.setZero();
|
|
|
|
b.set(0.0f, 1.0f);
|
|
|
|
c.set(1.0f, 0.0f);
|
|
|
|
d.set(1.0f, 1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
y = y0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Reversed Grid
|
2015-04-20 01:40:52 +08:00
|
|
|
b.setZero();
|
|
|
|
a.set(0.0f, 1.0f);
|
|
|
|
d.set(1.0f, 0.0f);
|
|
|
|
c.set(1.0f, 1.0f);
|
2012-04-19 14:35:52 +08:00
|
|
|
y = y1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
diff.y = y - y * my;
|
|
|
|
diff.z = fabsf(floorf((y * mz) / 4.0f));
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// bottom-left
|
2021-12-25 10:04:45 +08:00
|
|
|
v = getOriginalVertex(a);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.y = diff.y;
|
|
|
|
v.z += diff.z;
|
|
|
|
setVertex(a, v);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// upper-left
|
2013-07-08 23:05:47 +08:00
|
|
|
v = getOriginalVertex(b);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.y -= diff.y;
|
|
|
|
v.z -= diff.z;
|
|
|
|
setVertex(b, v);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// bottom-right
|
2021-12-25 10:04:45 +08:00
|
|
|
v = getOriginalVertex(c);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.y = diff.y;
|
|
|
|
v.z += diff.z;
|
|
|
|
setVertex(c, v);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// upper-right
|
2013-07-08 23:05:47 +08:00
|
|
|
v = getOriginalVertex(d);
|
2012-04-19 14:35:52 +08:00
|
|
|
v.y -= diff.y;
|
|
|
|
v.z -= diff.z;
|
|
|
|
setVertex(d, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementation of Lens3D
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
Lens3D* Lens3D::create(float duration, const Vec2& gridSize, const Vec2& position, float radius)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Lens3D* action = new Lens3D();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration, gridSize, position, radius))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
action->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
bool Lens3D::initWithDuration(float duration, const Vec2& gridSize, const Vec2& position, float radius)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if (Grid3DAction::initWithDuration(duration, gridSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2015-04-20 01:40:52 +08:00
|
|
|
_position.set(-1.0f, -1.0f);
|
2012-12-26 18:59:31 +08:00
|
|
|
setPosition(position);
|
2021-12-25 10:04:45 +08:00
|
|
|
_radius = radius;
|
2013-06-15 14:03:30 +08:00
|
|
|
_lensEffect = 0.7f;
|
2021-12-25 10:04:45 +08:00
|
|
|
_concave = false;
|
|
|
|
_dirty = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Lens3D* Lens3D::clone() const
|
2013-06-19 06:06:53 +08:00
|
|
|
{
|
2015-01-08 10:22:45 +08:00
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new Lens3D();
|
2015-01-08 10:22:45 +08:00
|
|
|
a->initWithDuration(_duration, _gridSize, _position, _radius);
|
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-06-19 06:06:53 +08:00
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void Lens3D::setPosition(const Vec2& pos)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!pos.equals(_position))
|
2012-08-01 15:30:12 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_position = pos;
|
2021-12-25 10:04:45 +08:00
|
|
|
_dirty = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 09:48:37 +08:00
|
|
|
void Lens3D::update(float /*time*/)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_dirty)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
for (i = 0; i < _gridSize.width + 1; ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
for (j = 0; j < _gridSize.height + 1; ++j)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2019-09-25 14:32:26 +08:00
|
|
|
Vec2 pos((float)i, (float)j);
|
2021-12-25 10:04:45 +08:00
|
|
|
Vec3 v = getOriginalVertex(pos);
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 vect = _position - Vec2(v.x, v.y);
|
2021-12-25 10:04:45 +08:00
|
|
|
float r = vect.getLength();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (r < _radius)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
r = _radius - r;
|
2013-06-15 14:03:30 +08:00
|
|
|
float pre_log = r / _radius;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (pre_log == 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
pre_log = 0.001f;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
float l = logf(pre_log) * _lensEffect;
|
|
|
|
float new_r = expf(l) * _radius;
|
|
|
|
|
2013-07-11 16:38:58 +08:00
|
|
|
if (vect.getLength() > 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2014-04-30 18:07:05 +08:00
|
|
|
vect.normalize();
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 new_vect = vect * new_r;
|
2013-07-11 16:38:58 +08:00
|
|
|
v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-09-25 14:32:26 +08:00
|
|
|
setVertex(pos, v);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_dirty = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementation of Ripple3D
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
Ripple3D* Ripple3D::create(float duration,
|
|
|
|
const Vec2& gridSize,
|
|
|
|
const Vec2& position,
|
|
|
|
float radius,
|
|
|
|
unsigned int waves,
|
|
|
|
float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Ripple3D* action = new Ripple3D();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration, gridSize, position, radius, waves, amplitude))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
action->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool Ripple3D::initWithDuration(float duration,
|
|
|
|
const Vec2& gridSize,
|
|
|
|
const Vec2& position,
|
|
|
|
float radius,
|
|
|
|
unsigned int waves,
|
|
|
|
float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if (Grid3DAction::initWithDuration(duration, gridSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-12-26 18:59:31 +08:00
|
|
|
setPosition(position);
|
2021-12-25 10:04:45 +08:00
|
|
|
_radius = radius;
|
|
|
|
_waves = waves;
|
|
|
|
_amplitude = amplitude;
|
2013-06-15 14:03:30 +08:00
|
|
|
_amplitudeRate = 1.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void Ripple3D::setPosition(const Vec2& position)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_position = position;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Ripple3D* Ripple3D::clone() const
|
2013-06-19 06:06:53 +08:00
|
|
|
{
|
2015-01-08 10:22:45 +08:00
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new Ripple3D();
|
2015-01-08 10:22:45 +08:00
|
|
|
a->initWithDuration(_duration, _gridSize, _position, _radius, _waves, _amplitude);
|
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-06-19 06:06:53 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Ripple3D::update(float time)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (i = 0; i < (_gridSize.width + 1); ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
for (j = 0; j < (_gridSize.height + 1); ++j)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2019-09-25 14:32:26 +08:00
|
|
|
Vec2 pos((float)i, (float)j);
|
2021-12-25 10:04:45 +08:00
|
|
|
Vec3 v = getOriginalVertex(pos);
|
|
|
|
Vec2 vect = _position - Vec2(v.x, v.y);
|
|
|
|
float r = vect.getLength();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (r < _radius)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
r = _radius - r;
|
2013-06-15 14:03:30 +08:00
|
|
|
float rate = powf(r / _radius, 2);
|
2021-12-25 10:04:45 +08:00
|
|
|
v.z += (sinf(time * (float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-09-25 14:32:26 +08:00
|
|
|
setVertex(pos, v);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementation of Shaky3D
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
Shaky3D* Shaky3D::create(float duration, const Vec2& gridSize, int range, bool shakeZ)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Shaky3D* action = new Shaky3D();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration, gridSize, range, shakeZ))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
action->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-11-16 21:08:00 +08:00
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
bool Shaky3D::initWithDuration(float duration, const Vec2& gridSize, int range, bool shakeZ)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if (Grid3DAction::initWithDuration(duration, gridSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_randrange = range;
|
2021-12-25 10:04:45 +08:00
|
|
|
_shakeZ = shakeZ;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Shaky3D* Shaky3D::clone() const
|
2013-06-19 06:06:53 +08:00
|
|
|
{
|
2015-01-08 10:22:45 +08:00
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new Shaky3D();
|
2013-06-19 06:06:53 +08:00
|
|
|
a->initWithDuration(_duration, _gridSize, _randrange, _shakeZ);
|
2015-01-08 10:22:45 +08:00
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-06-19 06:06:53 +08:00
|
|
|
}
|
|
|
|
|
2016-11-16 09:48:37 +08:00
|
|
|
void Shaky3D::update(float /*time*/)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (i = 0; i < (_gridSize.width + 1); ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
for (j = 0; j < (_gridSize.height + 1); ++j)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2019-09-25 14:32:26 +08:00
|
|
|
Vec2 pos((float)i, (float)j);
|
|
|
|
Vec3 v = getOriginalVertex(pos);
|
2021-12-25 10:04:45 +08:00
|
|
|
v.x += (rand() % (_randrange * 2)) - _randrange;
|
|
|
|
v.y += (rand() % (_randrange * 2)) - _randrange;
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_shakeZ)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
v.z += (rand() % (_randrange * 2)) - _randrange;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-09-25 14:32:26 +08:00
|
|
|
setVertex(pos, v);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementation of Liquid
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
Liquid* Liquid::create(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Liquid* action = new Liquid();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration, gridSize, waves, amplitude))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
action->autorelease();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2021-12-08 00:11:53 +08:00
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(action);
|
2021-12-08 00:11:53 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
bool Liquid::initWithDuration(float duration, const Vec2& gridSize, unsigned int waves, float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if (Grid3DAction::initWithDuration(duration, gridSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
_waves = waves;
|
|
|
|
_amplitude = amplitude;
|
2013-06-15 14:03:30 +08:00
|
|
|
_amplitudeRate = 1.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Liquid* Liquid::clone() const
|
2013-06-19 06:06:53 +08:00
|
|
|
{
|
2015-01-08 10:22:45 +08:00
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new Liquid();
|
2015-01-08 10:22:45 +08:00
|
|
|
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
|
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-06-19 06:06:53 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Liquid::update(float time)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
for (i = 1; i < _gridSize.width; ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
for (j = 1; j < _gridSize.height; ++j)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2019-09-25 14:32:26 +08:00
|
|
|
Vec2 pos((float)i, (float)j);
|
|
|
|
Vec3 v = getOriginalVertex(pos);
|
2021-12-25 10:04:45 +08:00
|
|
|
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
|
|
|
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
|
2019-09-25 14:32:26 +08:00
|
|
|
setVertex(pos, v);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementation of Waves
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
Waves* Waves::create(float duration,
|
|
|
|
const Vec2& gridSize,
|
|
|
|
unsigned int waves,
|
|
|
|
float amplitude,
|
|
|
|
bool horizontal,
|
|
|
|
bool vertical)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Waves* action = new Waves();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration, gridSize, waves, amplitude, horizontal, vertical))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
action->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool Waves::initWithDuration(float duration,
|
|
|
|
const Vec2& gridSize,
|
|
|
|
unsigned int waves,
|
|
|
|
float amplitude,
|
|
|
|
bool horizontal,
|
|
|
|
bool vertical)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if (Grid3DAction::initWithDuration(duration, gridSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
_waves = waves;
|
|
|
|
_amplitude = amplitude;
|
2013-06-15 14:03:30 +08:00
|
|
|
_amplitudeRate = 1.0f;
|
2021-12-25 10:04:45 +08:00
|
|
|
_horizontal = horizontal;
|
|
|
|
_vertical = vertical;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Waves* Waves::clone() const
|
2013-06-19 06:06:53 +08:00
|
|
|
{
|
2015-01-08 10:22:45 +08:00
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new Waves();
|
2015-01-08 10:22:45 +08:00
|
|
|
a->initWithDuration(_duration, _gridSize, _waves, _amplitude, _horizontal, _vertical);
|
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-06-19 06:06:53 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Waves::update(float time)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
for (i = 0; i < _gridSize.width + 1; ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
for (j = 0; j < _gridSize.height + 1; ++j)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2019-09-25 14:32:26 +08:00
|
|
|
Vec2 pos((float)i, (float)j);
|
|
|
|
Vec3 v = getOriginalVertex(pos);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_vertical)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_horizontal)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2019-09-25 14:32:26 +08:00
|
|
|
setVertex(pos, v);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// implementation of Twirl
|
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
Twirl* Twirl::create(float duration, const Vec2& gridSize, const Vec2& position, unsigned int twirls, float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
Twirl* action = new Twirl();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2021-12-08 00:11:53 +08:00
|
|
|
if (action->initWithDuration(duration, gridSize, position, twirls, amplitude))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
action->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(action);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-11-16 21:08:00 +08:00
|
|
|
return action;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool Twirl::initWithDuration(float duration,
|
|
|
|
const Vec2& gridSize,
|
|
|
|
const Vec2& position,
|
|
|
|
unsigned int twirls,
|
|
|
|
float amplitude)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
if (Grid3DAction::initWithDuration(duration, gridSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-12-26 18:59:31 +08:00
|
|
|
setPosition(position);
|
2021-12-25 10:04:45 +08:00
|
|
|
_twirls = twirls;
|
|
|
|
_amplitude = amplitude;
|
2013-06-15 14:03:30 +08:00
|
|
|
_amplitudeRate = 1.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
void Twirl::setPosition(const Vec2& position)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_position = position;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
Twirl* Twirl::clone() const
|
2013-06-19 06:06:53 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
// no copy constructor
|
2021-12-08 00:11:53 +08:00
|
|
|
auto a = new Twirl();
|
2015-01-08 10:22:45 +08:00
|
|
|
a->initWithDuration(_duration, _gridSize, _position, _twirls, _amplitude);
|
|
|
|
a->autorelease();
|
|
|
|
return a;
|
2013-06-19 06:06:53 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void Twirl::update(float time)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
2021-12-25 10:04:45 +08:00
|
|
|
Vec2 c = _position;
|
|
|
|
|
|
|
|
for (i = 0; i < (_gridSize.width + 1); ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
for (j = 0; j < (_gridSize.height + 1); ++j)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2019-09-25 14:32:26 +08:00
|
|
|
Vec2 pos((float)i, (float)j);
|
|
|
|
Vec3 v = getOriginalVertex(pos);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
Vec2 avg(i - (_gridSize.width / 2.0f), j - (_gridSize.height / 2.0f));
|
2013-07-11 16:38:58 +08:00
|
|
|
float r = avg.getLength();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
float amp = 0.1f * _amplitude * _amplitudeRate;
|
2021-12-25 10:04:45 +08:00
|
|
|
float a = r * cosf((float)M_PI / 2.0f + time * (float)M_PI * _twirls * 2) * amp;
|
|
|
|
|
|
|
|
Vec2 d(sinf(a) * (v.y - c.y) + cosf(a) * (v.x - c.x), cosf(a) * (v.y - c.y) - sinf(a) * (v.x - c.x));
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
v.x = c.x + d.x;
|
|
|
|
v.y = c.y + d.y;
|
|
|
|
|
2019-09-25 14:32:26 +08:00
|
|
|
setVertex(pos, v);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|