changes in API to support 3D

This commit is contained in:
Ricardo Quesada 2014-02-22 19:16:42 -08:00
parent 94977930b5
commit fe1160cd8c
10 changed files with 396 additions and 172 deletions

View File

@ -747,7 +747,7 @@ void RotateTo::startWithTarget(Node *target)
ActionInterval::startWithTarget(target);
// Calculate X
_startAngleX = target->getRotationX();
_startAngleX = target->getRotationSkewX();
if (_startAngleX > 0)
{
_startAngleX = fmodf(_startAngleX, 360.0f);
@ -768,7 +768,7 @@ void RotateTo::startWithTarget(Node *target)
}
//Calculate Y: It's duplicated from calculating X since the rotation wrap should be the same
_startAngleY = _target->getRotationY();
_startAngleY = _target->getRotationSkewY();
if (_startAngleY > 0)
{
@ -795,8 +795,8 @@ void RotateTo::update(float time)
{
if (_target)
{
_target->setRotationX(_startAngleX + _diffAngleX * time);
_target->setRotationY(_startAngleY + _diffAngleY * time);
_target->setRotationSkewX(_startAngleX + _diffAngleX * time);
_target->setRotationSkewY(_startAngleY + _diffAngleY * time);
}
}
@ -819,17 +819,6 @@ RotateBy* RotateBy::create(float duration, float deltaAngle)
return rotateBy;
}
bool RotateBy::initWithDuration(float duration, float deltaAngle)
{
if (ActionInterval::initWithDuration(duration))
{
_angleX = _angleY = deltaAngle;
return true;
}
return false;
}
RotateBy* RotateBy::create(float duration, float deltaAngleX, float deltaAngleY)
{
RotateBy *rotateBy = new RotateBy();
@ -839,23 +828,64 @@ RotateBy* RotateBy::create(float duration, float deltaAngleX, float deltaAngleY)
return rotateBy;
}
RotateBy* RotateBy::create(float duration, const Vertex3F& deltaAngle3D)
{
RotateBy *rotateBy = new RotateBy();
rotateBy->initWithDuration(duration, deltaAngle3D);
rotateBy->autorelease();
return rotateBy;
}
RotateBy::RotateBy()
: _is3D(false)
{
}
bool RotateBy::initWithDuration(float duration, float deltaAngle)
{
if (ActionInterval::initWithDuration(duration))
{
_angleZ_X = _angleZ_Y = deltaAngle;
return true;
}
return false;
}
bool RotateBy::initWithDuration(float duration, float deltaAngleX, float deltaAngleY)
{
if (ActionInterval::initWithDuration(duration))
{
_angleX = deltaAngleX;
_angleY = deltaAngleY;
_angleZ_X = deltaAngleX;
_angleZ_Y = deltaAngleY;
return true;
}
return false;
}
bool RotateBy::initWithDuration(float duration, const Vertex3F& deltaAngle3D)
{
if (ActionInterval::initWithDuration(duration))
{
_angle3D = deltaAngle3D;
_is3D = true;
return true;
}
return false;
}
RotateBy* RotateBy::clone(void) const
{
// no copy constructor
auto a = new RotateBy();
a->initWithDuration(_duration, _angleX, _angleY);
if(_is3D)
a->initWithDuration(_duration, _angle3D);
else
a->initWithDuration(_duration, _angleZ_X, _angleZ_Y);
a->autorelease();
return a;
}
@ -863,8 +893,15 @@ RotateBy* RotateBy::clone(void) const
void RotateBy::startWithTarget(Node *target)
{
ActionInterval::startWithTarget(target);
_startAngleX = target->getRotationX();
_startAngleY = target->getRotationY();
if(_is3D)
{
_startAngle3D = target->getRotation3D();
}
else
{
_startAngleZ_X = target->getRotationSkewX();
_startAngleZ_Y = target->getRotationSkewY();
}
}
void RotateBy::update(float time)
@ -872,14 +909,33 @@ void RotateBy::update(float time)
// XXX: shall I add % 360
if (_target)
{
_target->setRotationX(_startAngleX + _angleX * time);
_target->setRotationY(_startAngleY + _angleY * time);
if(_is3D)
{
Vertex3F v;
v.x = _startAngle3D.x + _angle3D.x * time;
v.y = _startAngle3D.y + _angle3D.y * time;
v.z = _startAngle3D.z + _angle3D.z * time;
_target->setRotation3D(v);
}
else
{
_target->setRotationSkewX(_startAngleZ_X + _angleZ_X * time);
_target->setRotationSkewY(_startAngleZ_Y + _angleZ_Y * time);
}
}
}
RotateBy* RotateBy::reverse() const
{
return RotateBy::create(_duration, -_angleX, -_angleY);
if(_is3D)
{
Vertex3F v;
v.x = - _angle3D.x;
v.y = - _angle3D.y;
v.z = - _angle3D.z;
return RotateBy::create(_duration, v);
}
return RotateBy::create(_duration, -_angleZ_X, -_angleZ_Y);
}
//

View File

@ -322,7 +322,8 @@ class CC_DLL RotateBy : public ActionInterval
public:
/** creates the action */
static RotateBy* create(float duration, float deltaAngle);
static RotateBy* create(float duration, float deltaAngleX, float deltaAngleY);
static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
static RotateBy* create(float duration, const Vertex3F& deltaAngle3D);
//
// Override
@ -333,16 +334,21 @@ public:
virtual void update(float time) override;
protected:
RotateBy() {}
RotateBy();
virtual ~RotateBy() {}
/** initializes the action */
bool initWithDuration(float duration, float deltaAngle);
bool initWithDuration(float duration, float deltaAngleX, float deltaAngleY);
bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
bool initWithDuration(float duration, const Vertex3F& deltaAngle3D);
float _angleX;
float _startAngleX;
float _angleY;
float _startAngleY;
float _angleZ_X;
float _startAngleZ_X;
float _angleZ_Y;
float _startAngleZ_Y;
bool _is3D;
Vertex3F _angle3D;
Vertex3F _startAngle3D;
private:
CC_DISALLOW_COPY_AND_ASSIGN(RotateBy);

View File

@ -59,6 +59,7 @@ THE SOFTWARE.
#include "CCEventCustom.h"
#include "CCFontFreeType.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCFrustum.h"
#include "CCConsole.h"
#include "kazmath/kazmath.h"
@ -446,7 +447,7 @@ void Director::setProjection(Projection projection)
kmGLLoadIdentity();
// issue #1334
kmMat4PerspectiveProjection(&matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2);
kmMat4PerspectiveProjection(&matrixPerspective, 60, (GLfloat)size.width/size.height, 10, zeye+size.height/2);
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500);
kmGLMultMatrix(&matrixPerspective);

View File

@ -590,7 +590,7 @@ void LayerColor::draw()
for(int i = 0; i < 4; ++i)
{
kmVec3 pos;
pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _vertexZ;
pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _positionZ;
kmVec3TransformCoord(&pos, &pos, &_modelViewTransform);
_noMVPVertices[i] = Vertex3F(pos.x,pos.y,pos.z);
}

View File

@ -77,9 +77,12 @@ static int s_globalOrderOfArrival = 1;
Node::Node(void)
: _rotationX(0.0f)
, _rotationY(0.0f)
, _rotationZ_X(0.0f)
, _rotationZ_Y(0.0f)
, _scaleX(1.0f)
, _scaleY(1.0f)
, _vertexZ(0.0f)
, _scaleZ(1.0f)
, _positionZ(0.0f)
, _position(Point::ZERO)
, _skewX(0.0f)
, _skewY(0.0f)
@ -230,32 +233,17 @@ void Node::setGlobalZOrder(float globalZOrder)
}
}
/// vertexZ getter
float Node::getVertexZ() const
{
return _vertexZ;
}
/// vertexZ setter
void Node::setVertexZ(float zOrder)
{
_vertexZ = zOrder;
setGlobalZOrder(zOrder);
}
/// rotation getter
float Node::getRotation() const
{
CCASSERT(_rotationX == _rotationY, "CCNode#rotation. RotationX != RotationY. Don't know which one to return");
return _rotationX;
CCASSERT(_rotationZ_X == _rotationZ_Y, "CCNode#rotation. RotationX != RotationY. Don't know which one to return");
return _rotationZ_X;
}
/// rotation setter
void Node::setRotation(float newRotation)
{
_rotationX = _rotationY = newRotation;
_rotationZ_X = _rotationZ_Y = newRotation;
_transformDirty = _inverseDirty = true;
#if CC_USE_PHYSICS
@ -266,25 +254,51 @@ void Node::setRotation(float newRotation)
#endif
}
float Node::getRotationX() const
float Node::getRotationSkewX() const
{
return _rotationX;
return _rotationZ_X;
}
void Node::setRotationX(float fRotationX)
void Node::setRotation3D(const Vertex3F& rotation)
{
_rotationX = fRotationX;
_transformDirty = _inverseDirty = true;
_rotationX = rotation.x;
_rotationY = rotation.y;
// rotation Z is decomposed in 2 to simulate Skew for Flash animations
_rotationZ_Y = _rotationZ_X = rotation.z;
#if CC_USE_PHYSICS
if (_physicsBody)
{
_physicsBody->setRotation(_rotationZ_X);
}
#endif
}
Vertex3F Node::getRotation3D() const
{
// rotation Z is decomposed in 2 to simulate Skew for Flash animations
CCASSERT(_rotationZ_X == _rotationZ_Y, "_rotationZ_X != _rotationZ_Y");
return Vertex3F(_rotationX,_rotationY,_rotationZ_X);
}
void Node::setRotationSkewX(float fRotationX)
{
_rotationZ_X = fRotationX;
_transformDirty = _inverseDirty = true;
}
float Node::getRotationY() const
float Node::getRotationSkewY() const
{
return _rotationY;
return _rotationZ_Y;
}
void Node::setRotationY(float rotationY)
void Node::setRotationSkewY(float rotationY)
{
_rotationY = rotationY;
_rotationZ_Y = rotationY;
_transformDirty = _inverseDirty = true;
}
@ -329,6 +343,19 @@ float Node::getScaleY() const
return _scaleY;
}
/// scaleY setter
void Node::setScaleZ(float newScaleZ)
{
_scaleZ = newScaleZ;
_transformDirty = _inverseDirty = true;
}
/// scaleY getter
float Node::getScaleZ() const
{
return _scaleZ;
}
/// scaleY setter
void Node::setScaleY(float newScaleY)
{
@ -336,6 +363,7 @@ void Node::setScaleY(float newScaleY)
_transformDirty = _inverseDirty = true;
}
/// position getter
const Point& Node::getPosition() const
{
@ -367,26 +395,72 @@ void Node::setPosition(float x, float y)
setPosition(Point(x, y));
}
void Node::setPosition3D(const Vertex3F& position)
{
_positionZ = position.z;
setPosition(Point(position.x, position.y));
}
Vertex3F Node::getPosition3D() const
{
Vertex3F ret;
ret.x = _position.x;
ret.y = _position.y;
ret.z = _positionZ;
return ret;
}
float Node::getPositionX() const
{
return _position.x;
}
float Node::getPositionY() const
{
return _position.y;
}
void Node::setPositionX(float x)
{
setPosition(Point(x, _position.y));
}
float Node::getPositionY() const
{
return _position.y;
}
void Node::setPositionY(float y)
{
setPosition(Point(_position.x, y));
}
float Node::getPositionZ() const
{
return _positionZ;
}
void Node::setPositionZ(float positionZ)
{
_transformDirty = _inverseDirty = true;
_positionZ = positionZ;
// XXX BUG
// Global Z Order should based on the modelViewTransform
setGlobalZOrder(positionZ);
}
void Node::setNormalizedPosition(const cocos2d::Point &position)
{
_normalizedPosition = position;
Size s = Director::getInstance()->getVisibleSize();
Point p;
p.x = s.width * position.x;
p.y = s.height * position.y;
setPosition(p);
}
const Point& Node::getNormalizedPosition() const
{
return _normalizedPosition;
}
ssize_t Node::getChildrenCount() const
{
return _children.size();
@ -1139,6 +1213,7 @@ const kmMat4& Node::getNodeToParentTransform() const
// Translate values
float x = _position.x;
float y = _position.y;
float z = _positionZ;
if (_ignoreAnchorPointForPosition)
{
@ -1150,10 +1225,10 @@ const kmMat4& Node::getNodeToParentTransform() const
// Change rotation code to handle X and Y
// If we skew with the exact same value for both x and y then we're simply just rotating
float cx = 1, sx = 0, cy = 1, sy = 0;
if (_rotationX || _rotationY)
if (_rotationZ_X || _rotationZ_Y)
{
float radiansX = -CC_DEGREES_TO_RADIANS(_rotationX);
float radiansY = -CC_DEGREES_TO_RADIANS(_rotationY);
float radiansX = -CC_DEGREES_TO_RADIANS(_rotationZ_X);
float radiansY = -CC_DEGREES_TO_RADIANS(_rotationZ_Y);
cx = cosf(radiansX);
sx = sinf(radiansX);
cy = cosf(radiansY);
@ -1175,13 +1250,28 @@ const kmMat4& Node::getNodeToParentTransform() const
// Build Transform Matrix
// Adjusted transform calculation for rotational skew
kmScalar mat[] = { cy * _scaleX, sy * _scaleX, 0, 0,
-sx * _scaleY, cx * _scaleY, 0, 0,
0, 0, 1, 0,
x, y, 0, 1 };
kmScalar mat[] = {
cy * _scaleX, sy * _scaleX, 0, 0,
-sx * _scaleY, cx * _scaleY, 0, 0,
0, 0, _scaleZ, 0,
x, y, z, 1 };
kmMat4Fill(&_transform, mat);
// XXX
// FIX ME: Expensive operation.
// FIX ME: It should be done together with the rotationZ
if(_rotationY) {
kmMat4 rotY;
kmMat4RotationY(&rotY,CC_DEGREES_TO_RADIANS(_rotationY));
kmMat4Multiply(&_transform, &_transform, &rotY);
}
if(_rotationX) {
kmMat4 rotX;
kmMat4RotationX(&rotX,CC_DEGREES_TO_RADIANS(_rotationX));
kmMat4Multiply(&_transform, &_transform, &rotX);
}
// XXX: Try to inline skew
// If skew is needed, apply skew and then anchor point
if (needsSkewMatrix)
@ -1203,9 +1293,6 @@ const kmMat4& Node::getNodeToParentTransform() const
}
}
// vertex Z
_transform.mat[14] = _vertexZ;
if (_useAdditionalTransform)
{
kmMat4Multiply(&_transform, &_transform, &_additionalTransform);
@ -1348,7 +1435,7 @@ bool Node::updatePhysicsTransform()
if (_physicsBody != nullptr && _physicsBody->getWorld() != nullptr && !_physicsBody->isResting())
{
_position = _physicsBody->getPosition();
_rotationX = _rotationY = _physicsBody->getRotation();
_rotationZ_X = _rotationZ_Y = _physicsBody->getRotation();
_transformDirty = _inverseDirty = true;
return true;
}

View File

@ -35,7 +35,6 @@
#include "CCGL.h"
#include "ccGLStateCache.h"
#include "CCGLProgram.h"
#include "kazmath/kazmath.h"
#include "CCScriptSupport.h"
#include "CCProtocols.h"
#include "CCEventDispatcher.h"
@ -214,29 +213,6 @@ public:
*/
virtual float getGlobalZOrder() const { return _globalZOrder; }
/**
* Sets the 'z' value in the OpenGL Depth Buffer.
*
* The OpenGL depth buffer and depth testing are disabled by default. You need to turn them on
* in order to use this property correctly.
*
* `setVertexZ()` also sets the `setGlobalZValue()` with the vertexZ value.
*
* @see `setGlobalZValue()`
*
* @param vertexZ OpenGL Z vertex of this node.
*/
virtual void setVertexZ(float vertexZ);
/**
* Gets OpenGL Z vertex of this node.
*
* @see setVertexZ(float)
*
* @return OpenGL Z vertex of this node
*/
virtual float getVertexZ() const;
/**
* Changes the scale factor on X axis of this node
*
@ -272,6 +248,23 @@ public:
*/
virtual float getScaleY() const;
/**
* Changes the scale factor on Z axis of this node
*
* The Default value is 1.0 if you haven't changed it before.
*
* @param scaleY The scale factor on Y axis.
*/
virtual void setScaleZ(float scaleZ);
/**
* Returns the scale factor on Z axis of this node
*
* @see `setScaleZ(float)`
*
* @return The scale factor on Z axis.
*/
virtual float getScaleZ() const;
/**
* Changes both X and Y scale factor of the node.
@ -359,6 +352,41 @@ public:
virtual void setPositionY(float y);
virtual float getPositionY(void) const;
virtual void setPosition3D(const Vertex3F& position);
virtual Vertex3F getPosition3D() const;
/**
* Sets the 'z' axis in the position. It is the OpenGL Z vertex value.
*
* The OpenGL depth buffer and depth testing are disabled by default. You need to turn them on
* in order to use this property correctly.
*
* `setPositionZ()` also sets the `setGlobalZValue()` with the positionZ as value.
*
* @see `setGlobalZValue()`
*
* @param vertexZ OpenGL Z vertex of this node.
*/
virtual void setPositionZ(float positionZ);
CC_DEPRECATED_ATTRIBUTE virtual void setVertexZ(float vertexZ) { setPositionZ(vertexZ); }
/**
* Gets position Z axis of this node.
*
* @see setPositionZ(float)
*
* @return the position Z axis of this node.
*/
virtual float getPositionZ() const;
CC_DEPRECATED_ATTRIBUTE virtual float getVertexZ() const { return getPositionZ(); }
/** Sets the position using normalized coordinates.
- (0,0) means bottom,left corner
- (1,1) means top,right corner
- (0.5,0.5) means center
*/
virtual void setNormalizedPosition(const Point& position);
/** returns the normalized position */
const Point& getNormalizedPosition() const;
/**
* Changes the X skew angle of the node in degrees.
@ -486,6 +514,8 @@ public:
*/
virtual float getRotation() const;
virtual void setRotation3D(const Vertex3F& rotation);
virtual Vertex3F getRotation3D() const;
/**
* Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew.
@ -495,16 +525,18 @@ public:
*
* @param rotationX The X rotation in degrees which performs a horizontal rotational skew.
*/
virtual void setRotationX(float rotationX);
virtual void setRotationSkewX(float rotationX);
CC_DEPRECATED_ATTRIBUTE virtual void setRotationX(float rotationX) { return setRotationSkewX(rotationX); }
/**
* Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew.
*
* @see `setRotationX(float)`
* @see `setRotationSkewX(float)`
*
* @return The X rotation in degrees.
*/
virtual float getRotationX() const;
virtual float getRotationSkewX() const;
CC_DEPRECATED_ATTRIBUTE virtual float getRotationX() const { return getRotationSkewX(); }
/**
* Sets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew.
@ -514,16 +546,18 @@ public:
*
* @param rotationY The Y rotation in degrees.
*/
virtual void setRotationY(float rotationY);
virtual void setRotationSkewY(float rotationY);
CC_DEPRECATED_ATTRIBUTE virtual void setRotationY(float rotationY) { return setRotationSkewY(rotationY); }
/**
* Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew.
*
* @see `setRotationY(float)`
* @see `setRotationSkewY(float)`
*
* @return The Y rotation in degrees.
*/
virtual float getRotationY() const;
virtual float getRotationSkewY() const;
CC_DEPRECATED_ATTRIBUTE virtual float getRotationY() const { return getRotationSkewY(); }
/**
* Sets the arrival order when this node has a same ZOrder with other children.
@ -1429,18 +1463,23 @@ protected:
virtual void disableCascadeColor();
virtual void updateColor() {}
float _rotationX; ///< rotation on the X-axis
float _rotationY; ///< rotation on the Y-axis
float _rotationX; ///< rotation angle on x-axis
float _rotationY; ///< rotation angle on y-axis
// rotation Z is decomposed in 2 to simulate Skew for Flash animations
float _rotationZ_X; ///< rotation angle on Z-axis, component X
float _rotationZ_Y; ///< rotation angle on Z-axis, component Y
float _scaleX; ///< scaling factor on x-axis
float _scaleY; ///< scaling factor on y-axis
float _scaleX; ///< scaling factor on x-axis
float _scaleY; ///< scaling factor on y-axis
float _scaleZ; ///< scaling factor on z-axis
Point _position; ///< position of the node
float _positionZ; ///< OpenGL real Z position
Point _normalizedPosition; ///< position in normalized coordinates
Point _position; ///< position of the node
float _skewX; ///< skew angle on x-axis
float _skewY; ///< skew angle on y-axis
float _skewX; ///< skew angle on x-axis
float _skewY; ///< skew angle on y-axis
Point _anchorPointInPoints; ///< anchor point in points
Point _anchorPoint; ///< anchor point normalized (NOT in points)
@ -1460,8 +1499,6 @@ protected:
int _localZOrder; ///< Local order (relative to its siblings) used to sort the node
float _globalZOrder; ///< Global order used to sort the node
float _vertexZ; ///< OpenGL real Z vertex
Vector<Node*> _children; ///< array of children nodes
Node *_parent; ///< weak reference to parent node

View File

@ -565,10 +565,10 @@ void Sprite::updateTransform(void)
float dx = x1 * cr - y2 * sr2 + x;
float dy = x1 * sr + y2 * cr2 + y;
_quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
_quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
_quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
_quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
_quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ );
_quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ );
_quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ );
_quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ );
}
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS

View File

@ -188,10 +188,10 @@ void Skin::updateTransform()
float dx = x1 * cr - y2 * sr2 + x;
float dy = x1 * sr + y2 * cr2 + y;
SET_VERTEX3F( _quad.bl.vertices, RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
SET_VERTEX3F( _quad.br.vertices, RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
SET_VERTEX3F( _quad.tl.vertices, RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
SET_VERTEX3F( _quad.tr.vertices, RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
SET_VERTEX3F( _quad.bl.vertices, RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ );
SET_VERTEX3F( _quad.br.vertices, RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ );
SET_VERTEX3F( _quad.tl.vertices, RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ );
SET_VERTEX3F( _quad.tr.vertices, RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ );
}
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS

View File

@ -33,9 +33,12 @@
static std::function<Layer*()> createFunctions[] = {
CL(ActionRotateBy3D),
CL(ActionManual),
CL(ActionMove),
CL(ActionRotate),
CL(ActionRotateBy3D),
CL(ActionScale),
CL(ActionSkew),
CL(ActionRotationalSkew),
@ -501,6 +504,31 @@ std::string ActionRotate::subtitle() const
return "RotateTo / RotateBy";
}
//------------------------------------------------------------------
//
// ActionRotateBy3D
//
//------------------------------------------------------------------
void ActionRotateBy3D::onEnter()
{
ActionsDemo::onEnter();
centerSprites(3);
auto actionBy1 = RotateBy::create(4, Vertex3F(360, 0, 0));
auto actionBy2 = RotateBy::create(4, Vertex3F(0, 360, 0));
auto actionBy3 = RotateBy::create(4 ,Vertex3F(0, 0, 360));
_tamara->runAction( Sequence::create(actionBy1, actionBy1->reverse(), nullptr));
_grossini->runAction( Sequence::create(actionBy2, actionBy2->reverse(), nullptr));
_kathia->runAction( Sequence::create(actionBy3, actionBy3->reverse(), nullptr));
}
std::string ActionRotateBy3D::subtitle() const
{
return "RotateBy in 3D";
}
//------------------------------------------------------------------
//
// ActionJump

View File

@ -49,7 +49,7 @@ protected:
Sprite* _tamara;
Sprite* _kathia;
public:
virtual void onEnter();
virtual void onEnter() override;
virtual void onExit();
void centerSprites(unsigned int numberOfSprites);
@ -67,7 +67,7 @@ class ActionManual : public ActionsDemo
public:
CREATE_FUNC(ActionManual);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -76,7 +76,7 @@ class ActionMove : public ActionsDemo
public:
CREATE_FUNC(ActionMove);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -85,7 +85,7 @@ class ActionScale : public ActionsDemo
public:
CREATE_FUNC(ActionScale);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -94,7 +94,7 @@ class ActionSkew : public ActionsDemo
public:
CREATE_FUNC(ActionSkew);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -103,7 +103,7 @@ class ActionRotationalSkew : public ActionsDemo
public:
CREATE_FUNC(ActionRotationalSkew);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -112,7 +112,7 @@ class ActionRotationalSkewVSStandardSkew : public ActionsDemo
public:
CREATE_FUNC(ActionRotationalSkewVSStandardSkew);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -121,7 +121,7 @@ class ActionSkewRotateScale : public ActionsDemo
public:
CREATE_FUNC(ActionSkewRotateScale);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -130,7 +130,16 @@ class ActionRotate : public ActionsDemo
public:
CREATE_FUNC(ActionRotate);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
class ActionRotateBy3D : public ActionsDemo
{
public:
CREATE_FUNC(ActionRotateBy3D);
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -139,7 +148,7 @@ class ActionJump : public ActionsDemo
public:
CREATE_FUNC(ActionJump);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -148,7 +157,7 @@ class ActionBezier : public ActionsDemo
public:
CREATE_FUNC(ActionBezier);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -157,7 +166,7 @@ class ActionBlink : public ActionsDemo
public:
CREATE_FUNC(ActionBlink);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -166,7 +175,7 @@ class ActionFade : public ActionsDemo
public:
CREATE_FUNC(ActionFade);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -175,7 +184,7 @@ class ActionTint : public ActionsDemo
public:
CREATE_FUNC(ActionTint);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -184,7 +193,7 @@ class ActionAnimate : public ActionsDemo
public:
CREATE_FUNC(ActionAnimate);
virtual void onEnter();
virtual void onEnter() override;
virtual void onExit();
virtual std::string title() const override;
virtual std::string subtitle() const override;
@ -195,7 +204,7 @@ class ActionSequence : public ActionsDemo
public:
CREATE_FUNC(ActionSequence);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -204,7 +213,7 @@ class ActionSequence2 : public ActionsDemo
public:
CREATE_FUNC(ActionSequence2);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
void callback1();
@ -217,7 +226,7 @@ class ActionSpawn : public ActionsDemo
public:
CREATE_FUNC(ActionSpawn);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -226,7 +235,7 @@ class ActionReverse : public ActionsDemo
public:
CREATE_FUNC(ActionReverse);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -235,7 +244,7 @@ class ActionRepeat : public ActionsDemo
public:
CREATE_FUNC(ActionRepeat);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -244,7 +253,7 @@ class ActionDelayTime : public ActionsDemo
public:
CREATE_FUNC(ActionDelayTime);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -253,7 +262,7 @@ class ActionReverseSequence : public ActionsDemo
public:
CREATE_FUNC(ActionReverseSequence);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -262,7 +271,7 @@ class ActionReverseSequence2 : public ActionsDemo
public:
CREATE_FUNC(ActionReverseSequence2);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -271,7 +280,7 @@ class ActionOrbit : public ActionsDemo
public:
CREATE_FUNC(ActionOrbit);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -280,7 +289,7 @@ class ActionRemoveSelf : public ActionsDemo
public:
CREATE_FUNC(ActionRemoveSelf);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -289,7 +298,7 @@ class ActionRepeatForever : public ActionsDemo
public:
CREATE_FUNC(ActionRepeatForever);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
void repeatForever(Node* pTarget);
@ -300,7 +309,7 @@ class ActionRotateToRepeat : public ActionsDemo
public:
CREATE_FUNC(ActionRotateToRepeat);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -309,7 +318,7 @@ class ActionRotateJerk : public ActionsDemo
public:
CREATE_FUNC(ActionRotateJerk);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
@ -318,7 +327,7 @@ class ActionCallFuncN : public ActionsDemo
public:
CREATE_FUNC(ActionCallFuncN);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
void callback(Node* sender);
@ -329,7 +338,7 @@ class ActionCallFuncND : public ActionsDemo
public:
CREATE_FUNC(ActionCallFuncND);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
void doRemoveFromParentAndCleanup(Node* sender, bool cleanup);
@ -340,7 +349,7 @@ class ActionCallFuncO : public ActionsDemo
public:
CREATE_FUNC(ActionCallFuncO);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
void callback(Node* object, bool cleanup);
@ -351,7 +360,7 @@ class ActionCallFunction : public ActionsDemo
public:
CREATE_FUNC(ActionCallFunction);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
void callback1();
@ -365,7 +374,7 @@ class ActionFollow : public ActionsDemo
public:
CREATE_FUNC(ActionFollow);
virtual void onEnter();
virtual void onEnter() override;
virtual void draw();
virtual std::string subtitle() const override;
@ -381,7 +390,7 @@ class ActionTargeted : public ActionsDemo
public:
CREATE_FUNC(ActionTargeted);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
@ -391,7 +400,7 @@ class ActionTargetedReverse : public ActionsDemo
public:
CREATE_FUNC(ActionTargetedReverse);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
@ -401,7 +410,7 @@ class ActionStacked : public ActionsDemo
public:
CREATE_FUNC(ActionStacked);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void addNewSpriteWithCoords(Point p);
@ -443,7 +452,7 @@ public:
virtual ~ActionCatmullRomStacked();
virtual void draw();
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
@ -464,7 +473,7 @@ public:
virtual ~ActionCardinalSplineStacked();
virtual void draw();
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
@ -481,7 +490,7 @@ class Issue1305 : public ActionsDemo
public:
CREATE_FUNC(Issue1305);
virtual void onEnter();
virtual void onEnter() override;
virtual void onExit();
void log(Node* sender);
void addSprite(float dt);
@ -496,7 +505,7 @@ class Issue1305_2 : public ActionsDemo
public:
CREATE_FUNC(Issue1305_2);
virtual void onEnter();
virtual void onEnter() override;
void printLog1();
void printLog2();
void printLog3();
@ -510,7 +519,7 @@ class Issue1288 : public ActionsDemo
public:
CREATE_FUNC(Issue1288);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
@ -520,7 +529,7 @@ class Issue1288_2 : public ActionsDemo
public:
CREATE_FUNC(Issue1288_2);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
@ -530,7 +539,7 @@ class Issue1327 : public ActionsDemo
public:
CREATE_FUNC(Issue1327);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
virtual std::string title() const override;
void logSprRotation(Sprite* sender);
@ -543,7 +552,7 @@ public:
void incrementInteger();
void incrementIntegerCallback(void* data);
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
virtual std::string title() const override;
private:
@ -557,7 +566,7 @@ public:
~ActionCatmullRom();
virtual void onEnter();
virtual void onEnter() override;
virtual void draw();
virtual std::string subtitle() const override;
virtual std::string title() const override;
@ -578,7 +587,7 @@ public:
~ActionCardinalSpline();
virtual void onEnter();
virtual void onEnter() override;
virtual void draw();
virtual std::string subtitle() const override;
virtual std::string title() const override;
@ -598,7 +607,7 @@ public:
PauseResumeActions();
virtual ~PauseResumeActions();
virtual void onEnter();
virtual void onEnter() override;
virtual std::string subtitle() const override;
virtual std::string title() const override;