few corrections
ADD
include/ISceneNodeAnimatorCameraModifiedMaya.h
+// Copyright (C) 2002-2012 Nikolaus Gebhardt
+// This file is part of the "Irrlicht Engine".
+// For conditions of distribution and use, see copyright notice in irrlicht.h
+
+#ifndef __I_SCENE_NODE_ANIMATOR_CAMERA_MODIFIED_MAYA_H_INCLUDED__
+#define __I_SCENE_NODE_ANIMATOR_CAMERA_MODIFIED_MAYA_H_INCLUDED__
+
+#include "ISceneNodeAnimator.h"
+
+namespace irr
+{
+
+namespace scene
+{
+
+ //! Special scene node animator for Maya-style cameras
+ /** This scene node animator can be attached to a camera to make it act like a 3d
+ modelling tool.
+ The camera is moving relative to the target with the mouse, by pressing either
+ 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 ISceneNodeAnimatorCameraModifiedMaya : public ISceneNodeAnimator
+ {
+ public:
+
+ //! Returns the speed of movement
+ virtual float getMoveSpeed() const = 0;
+
+ //! Sets the speed of movement
+ virtual void setMoveSpeed(float moveSpeed) = 0;
+
+ //! Returns the rotation speed
+ virtual float getRotateSpeed() const = 0;
+
+ //! Set the rotation speed
+ virtual void setRotateSpeed(float rotateSpeed) = 0;
+
+ //! Returns the zoom speed
+ virtual float getZoomSpeed() const = 0;
+
+ //! Returns the step zoom speed
+ virtual float getStepZoomSpeed() const = 0;
+
+ //! Set the zoom speed
+ virtual void setZoomSpeed(float zoomSpeed) = 0;
+
+ //! Set the zoom speed
+ virtual void setStepZoomSpeed(float stepZoomSpeed) = 0;
+
+ //! Returns the current distance, i.e. orbit radius
+ virtual float getDistance() const = 0;
+
+ // Enable/disable zooming when right button is pressed
+ virtual void toggleZoomWithRightButton() = 0;
+
+ //! Set the distance
+ virtual void setDistance(float distance) = 0;
+ };
+
+} // end namespace scene
+} // end namespace irr
+
+#endif
+

MODIFY
source/Irrlicht/CSceneNodeAnimatorCameraModifiedMaya.cpp
source/Irrlicht/CSceneNodeAnimatorCameraModifiedMaya.cpp
@@ -117,11 +117,6 @@ namespace irr
//! OnAnimate() is called just before rendering the whole scene.
void CSceneNodeAnimatorCameraModifiedMaya::animateNode(IDummyTransformationSceneNode* node, uint32_t timeMs)
{
-
- //Alt + LM = Rotate around camera pivot
- //Alt + LM + MM = Dolly forth/back in view direction (speed % distance camera pivot - max distance to pivot)
- //Alt + MM = Move on camera plane (Screen center is about the mouse pointer, depending on move speed)
-
if (!node || node->getType() != ESNT_CAMERA)
return;
@@ -141,7 +136,9 @@ namespace irr
float nRotY = RotY;
// Check for zooming with right-button
- if (ZoomWithRMB && isMouseKeyDown(2)) //if zoomWithRMB is enabled and RMB is pressed
+
+ if(!MouseShift)
+ if (ZoomWithRMB && isMouseKeyDown(2))
{
if (!Zooming)
{
@@ -156,24 +153,26 @@ namespace irr
ZoomStart = MousePos;
}
- else if (Zooming) //if zoomWithRMB is not enabled and RMB is not pressed and zooming has been performed in previous invocation
+ else if (Zooming)
{
Zooming = false;
-
}
// Zoom the cam
- core::vector3df zoomTarget(0, 0, 0); // move target to allow further zooming
+ core::vector3df zoomTarget(0.0f, 0.0f, 0.0f); // move target to allow further zooming
if (StepZooming || Zooming)
{
- CurrentZoom += (ZoomDelta * ZoomSpeed);
+ if (StepZooming)
+ CurrentZoom -= ZoomDelta * ScrllZoomSpeed;
+ else
+ CurrentZoom += ZoomDelta * ZoomSpeed;
- const float minDistance = 1.f;
+ const float minDistance = 1.0f;
if (CurrentZoom < minDistance)
{
zoomTarget = camera->getTarget() - camera->getPosition();
zoomTarget.setLength(-CurrentZoom + minDistance);
- CurrentZoom = 1.f;
+ CurrentZoom = 1.0f;
}
StepZooming = false;
}
@@ -290,9 +289,9 @@ namespace irr
// jox: fixed bug: jitter when rotating to the top and bottom of y
- core::vector3df UpVector(0, 1, 0);
- UpVector.rotateXYBy(-nRotY, core::vector3df(0, 0, 0));
- UpVector.rotateXZBy(-nRotX + 180.f, core::vector3df(0, 0, 0));
+ core::vector3df UpVector(0.0f, 1.0f, 0.0f);
+ UpVector.rotateXYBy(-nRotY, core::vector3df(0.0f, 0.0f, 0.0f));
+ UpVector.rotateXZBy(-nRotX + 180.0f, core::vector3df(0.0f, 0.0f, 0.0f));
camera->setUpVector(UpVector);
}
@@ -331,6 +330,11 @@ namespace irr
ZoomSpeed = speed;
}
+ //! Sets the zoom speed
+ void CSceneNodeAnimatorCameraModifiedMaya::setStepZoomSpeed(float speed)
+ {
+ ScrllZoomSpeed = speed;
+ }
//! Set the distance
void CSceneNodeAnimatorCameraModifiedMaya::setDistance(float distance)
@@ -359,6 +363,11 @@ namespace irr
return ZoomSpeed;
}
+ //! Gets the step zoom speed
+ float CSceneNodeAnimatorCameraModifiedMaya::getStepZoomSpeed() const
+ {
+ return ScrllZoomSpeed;
+ }
//! Returns the current distance, i.e. orbit radius
float CSceneNodeAnimatorCameraModifiedMaya::getDistance() const
@@ -366,6 +375,11 @@ namespace irr
return CurrentZoom;
}
+ void CSceneNodeAnimatorCameraModifiedMaya::toggleZoomWithRightButton()
+ {
+ ZoomWithRMB = !ZoomWithRMB;
+ }
+
ISceneNodeAnimator* CSceneNodeAnimatorCameraModifiedMaya::createClone(IDummyTransformationSceneNode * node, ISceneManager * newManager)
{

MODIFY
source/Irrlicht/CSceneNodeAnimatorCameraModifiedMaya.h
source/Irrlicht/CSceneNodeAnimatorCameraModifiedMaya.h
#ifndef __C_SCENE_NODE_ANIMATOR_CAMERA_MODIFIED_MAYA_H_INCLUDED__
#define __C_SCENE_NODE_ANIMATOR_CAMERA_MODIFIED_MAYA_H_INCLUDED__
-#include "ISceneNodeAnimatorCameraMaya.h"
+#include "ISceneNodeAnimatorCameraModifiedMaya.h"
#include "ICameraSceneNode.h"
#include "vector2d.h"
@@ -24,7 +24,7 @@ namespace irr
/** This scene node animator can be attached to a camera to make it act
like a 3d modelling tool camera
*/
- class CSceneNodeAnimatorCameraModifiedMaya : public ISceneNodeAnimatorCameraMaya
+ class CSceneNodeAnimatorCameraModifiedMaya : public ISceneNodeAnimatorCameraModifiedMaya
{
protected:
//! Destructor
@@ -37,43 +37,52 @@ namespace irr
float scrollZoomSpeed = 10.0f, bool zoomWithRBM = false);
//! Animates the scene node, currently only works on cameras
- virtual void animateNode(IDummyTransformationSceneNode* node, uint32_t timeMs);
+ virtual void animateNode(IDummyTransformationSceneNode* node, uint32_t timeMs) override;
//! Event receiver
- virtual bool OnEvent(const SEvent& event);
+ virtual bool OnEvent(const SEvent& event) override;
//! Returns the speed of movement in units per millisecond
- virtual float getMoveSpeed() const;
+ virtual float getMoveSpeed() const override;
//! Sets the speed of movement in units per millisecond
- virtual void setMoveSpeed(float moveSpeed);
+ virtual void setMoveSpeed(float moveSpeed) override;
//! Returns the rotation speed
- virtual float getRotateSpeed() const;
+ virtual float getRotateSpeed() const override;
//! Set the rotation speed
- virtual void setRotateSpeed(float rotateSpeed);
+ virtual void setRotateSpeed(float rotateSpeed) override;
//! Returns the zoom speed
- virtual float getZoomSpeed() const;
+ virtual float getZoomSpeed() const override;
+
+ //! Returns the step zoom speed
+ virtual float getStepZoomSpeed() const override;
//! Set the zoom speed
- virtual void setZoomSpeed(float zoomSpeed);
+ virtual void setZoomSpeed(float zoomSpeed) override;
+
+ //! Set the step zoom speed
+ virtual void setStepZoomSpeed(float zoomSpeed) override;
//! Returns the current distance, i.e. orbit radius
- virtual float getDistance() const;
+ virtual float getDistance() const override;
//! Set the distance
- virtual void setDistance(float distance);
+ virtual void setDistance(float distance) override;
//! This animator will receive events when attached to the active camera
- virtual bool isEventReceiverEnabled() const
+ virtual bool isEventReceiverEnabled() const override
{
return true;
}
+ //! Enable/disable zooming when right button is pressed
+ virtual void toggleZoomWithRightButton() override;
+
//! Returns type of the scene node
- virtual ESCENE_NODE_ANIMATOR_TYPE getType() const
+ virtual ESCENE_NODE_ANIMATOR_TYPE getType() const override
{
return ESNAT_CAMERA_MODIFIED_MAYA;
}
@@ -82,7 +91,7 @@ namespace irr
/** Please note that you will have to drop
(IReferenceCounted::drop()) the returned pointer after calling
this. */
- virtual ISceneNodeAnimator* createClone(IDummyTransformationSceneNode* node, ISceneManager* newManager = 0);
+ virtual ISceneNodeAnimator* createClone(IDummyTransformationSceneNode* node, ISceneManager* newManager = 0) override;
private:
void allKeysUp();

few corrections