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
master
bitplane 2009-01-08 01:25:22 +00:00
parent 082040520e
commit 4b01f2040f
7 changed files with 37 additions and 8 deletions

View File

@ -1,5 +1,7 @@
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.
- AntiAlias parameter in SIrrCreationParameters is now an u8 value specifying the multisampling level (0 for disabled, 4,6,8, and others for anti-aliasing)

View File

@ -591,13 +591,16 @@ namespace scene
'false', with which it is possible to fly around in space, if
no gravity is there.
\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.
This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1,
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.
/** The light will cast dynamic light on all

View File

@ -48,6 +48,11 @@ namespace scene
gravity causing camera shake. Disable this if the camera has
a collision animator with gravity enabled. */
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 irr

View File

@ -661,7 +661,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
//! like in most first person shooters (FPS):
ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
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)
parent = this;
@ -669,7 +669,7 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
ICameraSceneNode* node = new CCameraSceneNode(parent, this, id);
ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl,
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.
node->bindTargetAndRotation(true);

View File

@ -140,7 +140,7 @@ namespace scene
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1,
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
//! other scene nodes in the scene, which have the material flag video::MTF_LIGHTING

View File

@ -18,9 +18,10 @@ namespace scene
//! constructor
CSceneNodeAnimatorCameraFPS::CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
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),
MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
MoveSpeed(moveSpeed), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
MouseYDirection(invertY ? -1.0f : 1.0f),
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
{
#ifdef _DEBUG
@ -139,7 +140,7 @@ void CSceneNodeAnimatorCameraFPS::animateNode(ISceneNode* node, u32 timeMs)
if (CursorPos != CenterCursor)
{
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
@ -309,6 +310,16 @@ void CSceneNodeAnimatorCameraFPS::setVerticalMovement(bool 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)
{

View File

@ -28,7 +28,8 @@ namespace scene
//! Constructor
CSceneNodeAnimatorCameraFPS(gui::ICursorControl* cursorControl,
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
virtual ~CSceneNodeAnimatorCameraFPS();
@ -58,6 +59,11 @@ namespace scene
//! Sets whether vertical movement should be allowed.
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
virtual bool isEventReceiverEnabled() const
@ -101,6 +107,8 @@ namespace scene
f32 MoveSpeed;
f32 RotateSpeed;
f32 JumpSpeed;
// -1.0f for inverted mouse, defaults to 1.0f
f32 MouseYDirection;
s32 LastAnimationTime;