2011-03-19 10:59:01 +08:00
|
|
|
/****************************************************************************
|
2012-09-24 21:22:20 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2011-03-19 10:59:01 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
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-06-20 14:13:12 +08:00
|
|
|
ActionCamera()
|
2013-06-15 14:03:30 +08:00
|
|
|
:_centerXOrig(0)
|
|
|
|
,_centerYOrig(0)
|
|
|
|
,_centerZOrig(0)
|
|
|
|
,_eyeXOrig(0)
|
|
|
|
,_eyeYOrig(0)
|
|
|
|
,_eyeZOrig(0)
|
|
|
|
,_upXOrig(0)
|
|
|
|
,_upYOrig(0)
|
|
|
|
,_upZOrig(0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{}
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ~ActionCamera(){}
|
2012-04-19 14:35:52 +08:00
|
|
|
// super methods
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2013-06-16 03:38:32 +08:00
|
|
|
/** returns a new reversed action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ActionCamera * reverse() const;
|
2013-06-14 08:25:14 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual ActionCamera *clone() const;
|
2012-04-18 18:43:45 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
float _centerXOrig;
|
|
|
|
float _centerYOrig;
|
|
|
|
float _centerZOrig;
|
2010-08-09 11:03:06 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
float _eyeXOrig;
|
|
|
|
float _eyeYOrig;
|
|
|
|
float _eyeZOrig;
|
2010-08-09 10:58:48 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
float _upXOrig;
|
|
|
|
float _upYOrig;
|
|
|
|
float _upZOrig;
|
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-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-06-20 14:13:12 +08:00
|
|
|
~OrbitCamera(){}
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2013-06-20 14:13:12 +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);
|
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);
|
|
|
|
// super methods
|
2013-06-14 08:25:14 +08:00
|
|
|
/** returns a new clone of the action */
|
2013-06-20 14:13:12 +08:00
|
|
|
OrbitCamera *clone() const;
|
2013-07-08 23:05:47 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
virtual void startWithTarget(Node *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float time);
|
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__
|