1 // Copyright (C) 2002-2012 Nikolaus Gebhardt 2 // This file is part of the "Irrlicht Engine". 3 // For conditions of distribution and use, see copyright notice in irrlicht.h 4 5 #ifndef __C_SCENE_NODE_ANIMATOR_CAMERA_MAYA_H_INCLUDED__ 6 #define __C_SCENE_NODE_ANIMATOR_CAMERA_MAYA_H_INCLUDED__ 7 8 #include "ISceneNodeAnimatorCameraMaya.h" 9 #include "ICameraSceneNode.h" 10 #include "vector2d.h" 11 12 namespace irr 13 { 14 15 namespace gui 16 { 17 class ICursorControl; 18 } 19 20 namespace scene 21 { 22 23 //! Special scene node animator for FPS cameras 24 /** This scene node animator can be attached to a camera to make it act 25 like a 3d modelling tool camera 26 */ 27 class CSceneNodeAnimatorCameraMaya : public ISceneNodeAnimatorCameraMaya 28 { 29 public: 30 //! Constructor 31 CSceneNodeAnimatorCameraMaya(gui::ICursorControl* cursor, f32 rotateSpeed = -1500.f, 32 f32 zoomSpeed = 200.f, f32 translationSpeed = 1500.f, f32 distance=70.f); 33 34 //! Destructor 35 virtual ~CSceneNodeAnimatorCameraMaya(); 36 37 //! Animates the scene node, currently only works on cameras 38 virtual void animateNode(ISceneNode* node, u32 timeMs); 39 40 //! Event receiver 41 virtual bool OnEvent(const SEvent& event); 42 43 //! Returns the speed of movement in units per millisecond 44 virtual f32 getMoveSpeed() const; 45 46 //! Sets the speed of movement in units per millisecond 47 virtual void setMoveSpeed(f32 moveSpeed); 48 49 //! Returns the rotation speed 50 virtual f32 getRotateSpeed() const; 51 52 //! Set the rotation speed 53 virtual void setRotateSpeed(f32 rotateSpeed); 54 55 //! Returns the zoom speed 56 virtual f32 getZoomSpeed() const; 57 58 //! Set the zoom speed 59 virtual void setZoomSpeed(f32 zoomSpeed); 60 61 //! Returns the current distance, i.e. orbit radius 62 virtual f32 getDistance() const; 63 64 //! Set the distance 65 virtual void setDistance(f32 distance); 66 67 //! This animator will receive events when attached to the active camera isEventReceiverEnabled()68 virtual bool isEventReceiverEnabled() const 69 { 70 return true; 71 } 72 73 //! Returns type of the scene node getType()74 virtual ESCENE_NODE_ANIMATOR_TYPE getType() const 75 { 76 return ESNAT_CAMERA_MAYA; 77 } 78 79 //! Creates a clone of this animator. 80 /** Please note that you will have to drop 81 (IReferenceCounted::drop()) the returned pointer after calling 82 this. */ 83 virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0); 84 85 private: 86 87 void allKeysUp(); 88 void animate(); 89 bool isMouseKeyDown(s32 key) const; 90 91 bool MouseKeys[3]; 92 93 gui::ICursorControl *CursorControl; 94 scene::ICameraSceneNode* OldCamera; 95 core::vector3df OldTarget; 96 core::vector3df LastCameraTarget; // to find out if the camera target was moved outside this animator 97 core::position2df RotateStart; 98 core::position2df ZoomStart; 99 core::position2df TranslateStart; 100 core::position2df MousePos; 101 f32 ZoomSpeed; 102 f32 RotateSpeed; 103 f32 TranslateSpeed; 104 f32 CurrentZoom; 105 f32 RotX, RotY; 106 bool Zooming; 107 bool Rotating; 108 bool Moving; 109 bool Translating; 110 }; 111 112 } // end namespace scene 113 } // end namespace irr 114 115 #endif 116 117