2011-03-19 10:59:01 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
|
2011-03-19 10:59:01 +08:00
|
|
|
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 __CCCAMERA_ACTION_H__
|
|
|
|
#define __CCCAMERA_ACTION_H__
|
2012-04-25 16:18:04 +08:00
|
|
|
|
2011-03-19 10:59:01 +08:00
|
|
|
#include "CCActionInterval.h"
|
2013-12-21 08:33:31 +08:00
|
|
|
#include "kazmath/kazmath.h"
|
2011-03-19 10:59:01 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
2010-08-09 10:58:48 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
class Camera;
|
2010-08-09 11:03:06 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup actions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief Base class for Camera actions
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL ActionCamera : public ActionInterval //<NSCopying>
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2014-01-14 04:52:07 +08:00
|
|
|
ActionCamera();
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ~ActionCamera(){}
|
2013-07-18 07:56:19 +08:00
|
|
|
|
|
|
|
// Overrides
|
|
|
|
virtual void startWithTarget(Node *target) override;
|
|
|
|
virtual ActionCamera * reverse() const override;
|
|
|
|
virtual ActionCamera *clone() const override;
|
|
|
|
|
2014-01-14 04:52:07 +08:00
|
|
|
/* sets the Eye value of the Camera */
|
|
|
|
void setEye(const kmVec3 &eye);
|
|
|
|
void setEye(float x, float y, float z);
|
|
|
|
/* returns the Eye value of the Camera */
|
|
|
|
const kmVec3& getEye() const { return _eye; }
|
|
|
|
/* sets the Center value of the Camera */
|
|
|
|
void setCenter(const kmVec3 ¢er);
|
|
|
|
/* returns the Center value of the Camera */
|
|
|
|
const kmVec3& getCenter() const { return _center; }
|
|
|
|
/* sets the Up value of the Camera */
|
|
|
|
void setUp(const kmVec3 &up);
|
|
|
|
/* Returns the Up value of the Camera */
|
|
|
|
const kmVec3& getUp() const { return _up; }
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
protected:
|
2010-08-09 11:03:06 +08:00
|
|
|
|
2013-12-21 08:33:31 +08:00
|
|
|
void restore();
|
|
|
|
void updateTransform();
|
|
|
|
|
2014-01-14 04:52:07 +08:00
|
|
|
kmVec3 _center;
|
|
|
|
kmVec3 _eye;
|
|
|
|
kmVec3 _up;
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
2010-08-09 10:58:48 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
/**
|
2013-06-20 14:13:12 +08:00
|
|
|
@brief OrbitCamera action
|
2012-04-18 18:43:45 +08:00
|
|
|
Orbits the camera around the center of the screen using spherical coordinates
|
2012-06-20 18:09:11 +08:00
|
|
|
@ingroup Actions
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL OrbitCamera : public ActionCamera //<NSCopying>
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** creates a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
|
|
|
|
static OrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
OrbitCamera()
|
2013-06-15 14:03:30 +08:00
|
|
|
: _radius(0.0)
|
|
|
|
, _deltaRadius(0.0)
|
|
|
|
, _angleZ(0.0)
|
|
|
|
, _deltaAngleZ(0.0)
|
|
|
|
, _angleX(0.0)
|
|
|
|
, _deltaAngleX(0.0)
|
|
|
|
, _radZ(0.0)
|
|
|
|
, _radDeltaZ(0.0)
|
|
|
|
, _radX(0.0)
|
|
|
|
, _radDeltaX(0.0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{}
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-12-21 08:33:31 +08:00
|
|
|
virtual ~OrbitCamera(){}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** initializes a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
|
2012-04-19 14:35:52 +08:00
|
|
|
bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
|
|
|
|
/** positions the camera according to spherical coordinates */
|
|
|
|
void sphericalRadius(float *r, float *zenith, float *azimuth);
|
2013-07-08 23:05:47 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
OrbitCamera *clone() const override;
|
|
|
|
virtual void startWithTarget(Node *target) override;
|
|
|
|
virtual void update(float time) override;
|
2010-08-09 10:58:48 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _radius;
|
|
|
|
float _deltaRadius;
|
|
|
|
float _angleZ;
|
|
|
|
float _deltaAngleZ;
|
|
|
|
float _angleX;
|
|
|
|
float _deltaAngleX;
|
|
|
|
|
|
|
|
float _radZ;
|
|
|
|
float _radDeltaZ;
|
|
|
|
float _radX;
|
|
|
|
float _radDeltaX;
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
// end of actions group
|
|
|
|
/// @}
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2011-03-19 10:59:01 +08:00
|
|
|
|
2010-08-09 10:58:48 +08:00
|
|
|
#endif //__CCCAMERA_ACTION_H__
|