Commit 4b01f204 authored by bitplane's avatar bitplane

Added a method to invert the Y axis of the FPS camera animator. [1150796]

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2054 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 08204052
Changes in version 1.6 Changes in version 1.6
- Added a method to flip the Y movement of the FPS camera.
- The Anisotropy filter can now be set to the AF value per texture layer. So no forced MAX_ANISOTROPY anymore. .irr files will probably fail, though. - The Anisotropy filter can now be set to the AF value per texture layer. So no forced MAX_ANISOTROPY anymore. .irr files will probably fail, though.
- AntiAlias parameter in SIrrCreationParameters is now an u8 value specifying the multisampling level (0 for disabled, 4,6,8, and others for anti-aliasing) - AntiAlias parameter in SIrrCreationParameters is now an u8 value specifying the multisampling level (0 for disabled, 4,6,8, and others for anti-aliasing)
......
...@@ -591,13 +591,16 @@ namespace scene ...@@ -591,13 +591,16 @@ namespace scene
'false', with which it is possible to fly around in space, if 'false', with which it is possible to fly around in space, if
no gravity is there. no gravity is there.
\param jumpSpeed: Speed with which the camera is moved when jumping. \param jumpSpeed: Speed with which the camera is moved when jumping.
\param invertMouse: Setting this to true makes the camera look up when
the mouse is moved down and down when the mouse is moved up, the default
is 'false' which means it will follow the movement of the mouse cursor.
\return Pointer to the interface of the camera if successful, otherwise 0. \return Pointer to the interface of the camera if successful, otherwise 0.
This pointer should not be dropped. See This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */ IReferenceCounted::drop() for more information. */
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1, f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1,
SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false,
f32 jumpSpeed = 0.f) = 0; f32 jumpSpeed = 0.f, bool invertMouse=false) = 0;
//! Adds a dynamic light scene node to the scene graph. //! Adds a dynamic light scene node to the scene graph.
/** The light will cast dynamic light on all /** The light will cast dynamic light on all
......
...@@ -48,6 +48,11 @@ namespace scene ...@@ -48,6 +48,11 @@ namespace scene
gravity causing camera shake. Disable this if the camera has gravity causing camera shake. Disable this if the camera has
a collision animator with gravity enabled. */ a collision animator with gravity enabled. */
virtual void setVerticalMovement(bool allow) = 0; virtual void setVerticalMovement(bool allow) = 0;
//! Sets whether the Y axis of the mouse should be inverted.
/** If enabled then moving the mouse down will cause
the camera to look up. It is disabled by default. */
virtual void setInvertMouse(bool invert) = 0;
}; };
} // end namespace scene } // end namespace scene
} // end namespace irr } // end namespace irr
......
...@@ -661,7 +661,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, ...@@ -661,7 +661,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
//! like in most first person shooters (FPS): //! like in most first person shooters (FPS):
ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent, ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
f32 rotateSpeed, f32 moveSpeed, s32 id, f32 rotateSpeed, f32 moveSpeed, s32 id,
SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement,f32 jumpSpeed) SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY)
{ {
if (!parent) if (!parent)
parent = this; parent = this;
...@@ -669,7 +669,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent, ...@@ -669,7 +669,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
ICameraSceneNode* node = new CCameraSceneNode(parent, this, id); ICameraSceneNode* node = new CCameraSceneNode(parent, this, id);
ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl, ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl,
rotateSpeed, moveSpeed, jumpSpeed, rotateSpeed, moveSpeed, jumpSpeed,
keyMapArray, keyMapSize, noVerticalMovement); keyMapArray, keyMapSize, noVerticalMovement, invertMouseY);
// Bind the node's rotation to its target. This is consistent with 1.4.2 and below. // Bind the node's rotation to its target. This is consistent with 1.4.2 and below.
node->bindTargetAndRotation(true); node->bindTargetAndRotation(true);
......
...@@ -140,7 +140,7 @@ namespace scene ...@@ -140,7 +140,7 @@ namespace scene
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1, f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1,
SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false, SKeyMap* keyMapArray=0, s32 keyMapSize=0, bool noVerticalMovement=false,
f32 jumpSpeed = 0.f); f32 jumpSpeed = 0.f, bool invertMouseY=false);
//! Adds a dynamic light scene node. The light will cast dynamic light on all //! Adds a dynamic light scene node. The light will cast dynamic light on all
//! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING //! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING
......
...@@ -18,9 +18,10 @@ namespace scene ...@@ -18,9 +18,10 @@ namespace scene
//! constructor //! constructor
CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl, CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed, f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed,
SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement) SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement, bool invertY)
: CursorControl(cursorControl), MaxVerticalAngle(88.0f), : CursorControl(cursorControl), MaxVerticalAngle(88.0f),
MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed), MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
MouseYDirection(invertY ? -1.0f : 1.0f),
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement) LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -139,7 +140,7 @@ void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, u32 timeMs) ...@@ -139,7 +140,7 @@ void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, u32 timeMs)
if (CursorPos != CenterCursor) if (CursorPos != CenterCursor)
{ {
relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed; relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed;
relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed; relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed * MouseYDirection;
// X < MaxVerticalAngle or X > 360-MaxVerticalAngle // X < MaxVerticalAngle or X > 360-MaxVerticalAngle
...@@ -309,6 +310,16 @@ void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow) ...@@ -309,6 +310,16 @@ void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool allow)
NoVerticalMovement = !allow; NoVerticalMovement = !allow;
} }
//! Sets whether the Y axis of the mouse should be inverted.
void CSceneNodeAnimatorCameraFPS::setInvertMouse(bool invert)
{
if (invert)
MouseYDirection = -1.0f;
else
MouseYDirection = 1.0f;
}
ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager) ISceneNodeAnimator* CSceneNodeAnimatorCameraFPS::createClone(ISceneNode* node, ISceneManager* newManager)
{ {
......
...@@ -28,7 +28,8 @@ namespace scene ...@@ -28,7 +28,8 @@ namespace scene
//! Constructor //! Constructor
CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl, CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f, f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, f32 jumpSpeed=0.f,
SKeyMap* keyMapArray=0, u32 keyMapSize=0, bool noVerticalMovement=false); SKeyMap* keyMapArray=0, u32 keyMapSize=0, bool noVerticalMovement=false,
bool invertY=false);
//! Destructor //! Destructor
virtual ~CSceneNodeAnimatorCameraFPS(); virtual ~CSceneNodeAnimatorCameraFPS();
...@@ -58,6 +59,11 @@ namespace scene ...@@ -58,6 +59,11 @@ namespace scene
//! Sets whether vertical movement should be allowed. //! Sets whether vertical movement should be allowed.
virtual void setVerticalMovement(bool allow); virtual void setVerticalMovement(bool allow);
//! Sets whether the Y axis of the mouse should be inverted.
/** If enabled then moving the mouse down will cause
the camera to look up. It is disabled by default. */
virtual void setInvertMouse(bool invert);
//! 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
...@@ -101,6 +107,8 @@ namespace scene ...@@ -101,6 +107,8 @@ namespace scene
f32 MoveSpeed; f32 MoveSpeed;
f32 RotateSpeed; f32 RotateSpeed;
f32 JumpSpeed; f32 JumpSpeed;
// -1.0f for inverted mouse, defaults to 1.0f
f32 MouseYDirection;
s32 LastAnimationTime; s32 LastAnimationTime;
......
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