axmol/cocos/3d/CCAnimate3D.h

102 lines
3.4 KiB
C
Raw Normal View History

2014-06-04 18:17:09 +08:00
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
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.
****************************************************************************/
#ifndef __CCANIMATE3D_H__
#define __CCANIMATE3D_H__
#include <map>
2014-06-17 10:49:52 +08:00
#include "3d/CCAnimation3D.h"
2014-06-04 18:17:09 +08:00
#include "base/ccMacros.h"
#include "base/CCRef.h"
#include "base/ccTypes.h"
2014-07-09 14:07:33 +08:00
#include "base/CCPlatformMacros.h"
2014-06-04 18:17:09 +08:00
#include "2d/CCActionInterval.h"
#include "3d/3dExport.h"
2014-06-04 18:17:09 +08:00
NS_CC_BEGIN
class Animation3D;
2014-07-11 10:17:36 +08:00
class Bone3D;
2014-06-04 18:17:09 +08:00
/**
2014-06-19 14:11:14 +08:00
* Animate3D, Animates a Sprite3D given with an Animation3D
2014-06-04 18:17:09 +08:00
*/
class CC_3D_DLL Animate3D: public ActionInterval
2014-06-04 18:17:09 +08:00
{
public:
2014-06-19 14:11:14 +08:00
/**create Animate3D using Animation.*/
2014-06-09 18:37:58 +08:00
static Animate3D* create(Animation3D* animation);
2014-06-04 18:17:09 +08:00
2014-06-20 12:01:54 +08:00
/**
2014-06-20 18:54:09 +08:00
* create Animate3D
* @param animation used to generate animate3D
2014-06-20 12:01:54 +08:00
* @param formTime
* @param duration Time the Animate3D lasts
* @return Animate3D created using animate
*/
2014-06-20 18:54:09 +08:00
static Animate3D* create(Animation3D* animation, float fromTime, float duration);
2014-06-04 18:17:09 +08:00
//
// Overrides
//
virtual void step(float dt) override;
virtual void startWithTarget(Node *target) override;
virtual Animate3D* reverse() const override;
2014-06-17 19:18:56 +08:00
virtual Animate3D *clone() const override;
2014-06-04 18:17:09 +08:00
virtual void update(float t) override;
2014-07-09 09:53:15 +08:00
/**get & set speed, negative speed means playing reverse */
float getSpeed() const;
void setSpeed(float speed);
2014-07-09 09:53:15 +08:00
/**get & set blend weight, weight must positive*/
2014-06-20 17:55:25 +08:00
float getWeight() const { return _weight; }
2014-07-09 09:53:15 +08:00
void setWeight(float weight);
2014-06-17 19:18:56 +08:00
2014-07-10 11:05:48 +08:00
/**get & set play reverse, these are deprecated, use set negative speed instead*/
2014-07-09 14:07:33 +08:00
CC_DEPRECATED_ATTRIBUTE bool getPlayBack() const { return _playReverse; }
CC_DEPRECATED_ATTRIBUTE void setPlayBack(bool reverse) { _playReverse = reverse; }
2014-06-17 19:18:56 +08:00
CC_CONSTRUCTOR_ACCESS:
2014-06-04 18:17:09 +08:00
Animate3D();
virtual ~Animate3D();
2014-06-19 14:11:14 +08:00
protected:
Animation3D* _animation; //animation data
2014-06-04 18:17:09 +08:00
2014-07-09 09:53:15 +08:00
float _absSpeed; //playing speed
2014-06-19 14:11:14 +08:00
float _weight; //blend weight
2014-06-20 12:01:54 +08:00
float _start; //start time 0 - 1, used to generate sub Animate3D
float _last; //last time 0 - 1, used to generate sub Animate3D
2014-07-09 09:53:15 +08:00
bool _playReverse; // is playing reverse
2014-07-11 10:17:36 +08:00
std::map<Bone3D*, Animation3D::Curve*> _boneCurves; //weak ref
2014-06-04 18:17:09 +08:00
};
NS_CC_END
#endif // __CCANIMATE3D_H__