Commit 6d9a31a0 authored by hybrid's avatar hybrid

Add functions and constructor parameter to set the distance of the maya camera...

Add functions and constructor parameter to set the distance of the maya camera from the currently used target.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4002 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 47d5711e
...@@ -618,19 +618,24 @@ namespace scene ...@@ -618,19 +618,24 @@ namespace scene
//! Adds a maya style user controlled camera scene node to the scene graph. //! Adds a maya style user controlled camera scene node to the scene graph.
/** This is a standard camera with an animator that provides mouse control similar /** This is a standard camera with an animator that provides mouse control similar
to camera in the 3D Software Maya by Alias Wavefront. to camera in the 3D Software Maya by Alias Wavefront.
The camera does not react on setPosition anymore after applying this animator. Instead
use setTarget, to fix the target the camera the camera hovers around. And setDistance
to set the current distance from that target, i.e. the radius of the orbit the camera
hovers on.
\param parent: Parent scene node of the camera. Can be null. \param parent: Parent scene node of the camera. Can be null.
\param rotateSpeed: Rotation speed of the camera. \param rotateSpeed: Rotation speed of the camera.
\param zoomSpeed: Zoom speed of the camera. \param zoomSpeed: Zoom speed of the camera.
\param translationSpeed: TranslationSpeed of the camera. \param translationSpeed: TranslationSpeed of the camera.
\param id: id of the camera. This id can be used to identify the camera. \param id: id of the camera. This id can be used to identify the camera.
\param distance Initial distance of the camera from the object
\param makeActive Flag whether this camera should become the active one. \param makeActive Flag whether this camera should become the active one.
Make sure you always have one active camera. Make sure you always have one active camera.
\return Returns a pointer to the interface of the camera if successful, otherwise 0. \return Returns a pointer to the interface of the camera if successful, otherwise 0.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent=0,
f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 rotateSpeed=-1500.f, f32 zoomSpeed=200.f,
f32 translationSpeed = 1500.0f, s32 id=-1, f32 translationSpeed=1500.f, s32 id=-1, f32 distance=70.f,
bool makeActive=true) = 0; bool makeActive=true) =0;
//! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS). //! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS).
/** This FPS camera is intended to provide a demonstration of a /** This FPS camera is intended to provide a demonstration of a
......
...@@ -18,6 +18,9 @@ namespace scene ...@@ -18,6 +18,9 @@ namespace scene
modelling tool. modelling tool.
The camera is moving relative to the target with the mouse, by pressing either The camera is moving relative to the target with the mouse, by pressing either
of the three buttons. of the three buttons.
In order to move the camera, set a new target for the camera. The distance defines
the current orbit radius the camera moves on. Distance can be changed via the setter
or by mouse events.
*/ */
class ISceneNodeAnimatorCameraMaya : public ISceneNodeAnimator class ISceneNodeAnimatorCameraMaya : public ISceneNodeAnimator
{ {
...@@ -41,6 +44,11 @@ namespace scene ...@@ -41,6 +44,11 @@ namespace scene
//! Set the zoom speed //! Set the zoom speed
virtual void setZoomSpeed(f32 zoomSpeed) = 0; virtual void setZoomSpeed(f32 zoomSpeed) = 0;
//! Returns the current distance, i.e. orbit radius
virtual f32 getDistance() const = 0;
//! Set the distance
virtual void setDistance(f32 distance) = 0;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -715,7 +715,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent, ...@@ -715,7 +715,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent,
//! to in the 3D Software Maya by Alias Wavefront. //! to in the 3D Software Maya by Alias Wavefront.
//! The returned pointer must not be dropped. //! The returned pointer must not be dropped.
ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id, f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id, f32 distance,
bool makeActive) bool makeActive)
{ {
ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(), ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(),
...@@ -723,7 +723,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, ...@@ -723,7 +723,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
if (node) if (node)
{ {
ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(CursorControl, ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(CursorControl,
rotateSpeed, zoomSpeed, translationSpeed); rotateSpeed, zoomSpeed, translationSpeed, distance);
node->addAnimator(anm); node->addAnimator(anm);
anm->drop(); anm->drop();
......
...@@ -139,9 +139,9 @@ namespace scene ...@@ -139,9 +139,9 @@ namespace scene
//! Adds a camera scene node which is able to be controlle with the mouse similar //! Adds a camera scene node which is able to be controlle with the mouse similar
//! like in the 3D Software Maya by Alias Wavefront. //! like in the 3D Software Maya by Alias Wavefront.
//! The returned pointer must not be dropped. //! The returned pointer must not be dropped.
virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent=0,
f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 rotateSpeed=-1500.f, f32 zoomSpeed=200.f,
f32 translationSpeed = 1500.0f, s32 id=-1, f32 translationSpeed=1500.f, s32 id=-1, f32 distance=70.f,
bool makeActive=true); bool makeActive=true);
//! Adds a camera scene node which is able to be controled with the mouse and keys //! Adds a camera scene node which is able to be controled with the mouse and keys
......
...@@ -14,10 +14,11 @@ namespace scene ...@@ -14,10 +14,11 @@ namespace scene
{ {
//! constructor //! constructor
CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotate, f32 zoom, f32 translate) CSceneNodeAnimatorCameraMaya::CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor,
f32 rotateSpeed, f32 zoomSpeed, f32 translateSpeed, f32 distance)
: CursorControl(cursor), OldCamera(0), MousePos(0.5f, 0.5f), : CursorControl(cursor), OldCamera(0), MousePos(0.5f, 0.5f),
ZoomSpeed(zoom), RotateSpeed(rotate), TranslateSpeed(translate), ZoomSpeed(zoomSpeed), RotateSpeed(rotateSpeed), TranslateSpeed(translateSpeed),
CurrentZoom(70.0f), RotX(0.0f), RotY(0.0f), CurrentZoom(distance), RotX(0.0f), RotY(0.0f),
Zooming(false), Rotating(false), Moving(false), Translating(false) Zooming(false), Rotating(false), Moving(false), Translating(false)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -269,6 +270,13 @@ void CSceneNodeAnimatorCameraMaya::setZoomSpeed(f32 speed) ...@@ -269,6 +270,13 @@ void CSceneNodeAnimatorCameraMaya::setZoomSpeed(f32 speed)
} }
//! Set the distance
void CSceneNodeAnimatorCameraMaya::setDistance(f32 distance)
{
CurrentZoom=distance;
}
//! Gets the rotation speed //! Gets the rotation speed
f32 CSceneNodeAnimatorCameraMaya::getRotateSpeed() const f32 CSceneNodeAnimatorCameraMaya::getRotateSpeed() const
{ {
...@@ -290,6 +298,13 @@ f32 CSceneNodeAnimatorCameraMaya::getZoomSpeed() const ...@@ -290,6 +298,13 @@ f32 CSceneNodeAnimatorCameraMaya::getZoomSpeed() const
} }
//! Returns the current distance, i.e. orbit radius
f32 CSceneNodeAnimatorCameraMaya::getDistance() const
{
return CurrentZoom;
}
ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager) ISceneNodeAnimator* CSceneNodeAnimatorCameraMaya::createClone(ISceneNode* node, ISceneManager* newManager)
{ {
CSceneNodeAnimatorCameraMaya * newAnimator = CSceneNodeAnimatorCameraMaya * newAnimator =
......
...@@ -28,8 +28,8 @@ namespace scene ...@@ -28,8 +28,8 @@ namespace scene
{ {
public: public:
//! Constructor //! Constructor
CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotateSpeed = -1500.0f, CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotateSpeed = -1500.f,
f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f); f32 zoomSpeed = 200.f, f32 translationSpeed = 1500.f, f32 distance=70.f);
//! Destructor //! Destructor
virtual ~CSceneNodeAnimatorCameraMaya(); virtual ~CSceneNodeAnimatorCameraMaya();
...@@ -58,6 +58,12 @@ namespace scene ...@@ -58,6 +58,12 @@ namespace scene
//! Set the zoom speed //! Set the zoom speed
virtual void setZoomSpeed(f32 zoomSpeed); virtual void setZoomSpeed(f32 zoomSpeed);
//! Returns the current distance, i.e. orbit radius
virtual f32 getDistance() const;
//! Set the distance
virtual void setDistance(f32 distance);
//! This animator will receive events when attached to the active camera //! This animator will receive events when attached to the active camera
virtual bool isEventReceiverEnabled() const virtual bool isEventReceiverEnabled() const
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment