2019-12-12 17:32:41 +01:00
|
|
|
// 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
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED
|
|
|
|
#define IRR_C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "ISceneNodeAnimatorCameraFPS.h"
|
|
|
|
#include "vector2d.h"
|
|
|
|
#include "position2d.h"
|
|
|
|
#include "SKeyMap.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
|
|
|
class ICursorControl;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace scene
|
|
|
|
{
|
|
|
|
|
|
|
|
//! Special scene node animator for FPS cameras
|
|
|
|
class CSceneNodeAnimatorCameraFPS : public ISceneNodeAnimatorCameraFPS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! 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,
|
|
|
|
bool invertY=false, float rotateSpeedKeyboard = 0.3f);
|
|
|
|
|
|
|
|
//! Destructor
|
|
|
|
virtual ~CSceneNodeAnimatorCameraFPS();
|
|
|
|
|
|
|
|
//! Animates the scene node, currently only works on cameras
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void animateNode(ISceneNode* node, u32 timeMs) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Event receiver
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool OnEvent(const SEvent& event) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the speed of movement in units per second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getMoveSpeed() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets the speed of movement in units per second
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMoveSpeed(f32 moveSpeed) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the rotation speed when moving mouse
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getRotateSpeed() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Set the rotation speed when moving mouse
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setRotateSpeed(f32 rotateSpeed) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the rotation speed when using keyboard
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual f32 getRotateSpeedKeyboard() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return RotateSpeedKeyboard;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Set the rotation speed when using keyboard
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setRotateSpeedKeyboard(f32 rotateSpeed) IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
RotateSpeedKeyboard = rotateSpeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Sets the keyboard mapping for this animator (old style)
|
|
|
|
//! \param keymap: an array of keyboard mappings, see SKeyMap
|
|
|
|
//! \param count: the size of the keyboard map array
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setKeyMap(SKeyMap *map, u32 count) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets the keyboard mapping for this animator
|
|
|
|
//! \param keymap The new keymap array
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setKeyMap(const core::array<SKeyMap>& keymap) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Gets the keyboard mapping for this animator
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::array<SKeyMap>& getKeyMap() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Sets whether vertical movement should be allowed.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setVerticalMovement(bool allow) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! 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. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setInvertMouse(bool invert) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! This animator will receive events when attached to the active camera
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool isEventReceiverEnabled() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Returns the type of this animator
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual ESCENE_NODE_ANIMATOR_TYPE getType() const IRR_OVERRIDE
|
2019-12-12 17:32:41 +01:00
|
|
|
{
|
|
|
|
return ESNAT_CAMERA_FPS;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Creates a clone of this animator.
|
|
|
|
/** Please note that you will have to drop
|
|
|
|
(IReferenceCounted::drop()) the returned pointer once you're
|
|
|
|
done with it. */
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Writes attributes of the scene node animator.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Reads attributes of the scene node animator.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
void allKeysUp();
|
|
|
|
|
|
|
|
gui::ICursorControl *CursorControl;
|
2020-10-26 20:50:18 +01:00
|
|
|
bool GrabMouse;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
f32 MaxVerticalAngle;
|
|
|
|
bool NoVerticalMovement;
|
|
|
|
|
|
|
|
f32 MoveSpeed;
|
|
|
|
f32 RotateSpeedKeyboard;
|
|
|
|
f32 RotateSpeed;
|
|
|
|
f32 JumpSpeed;
|
|
|
|
// -1.0f for inverted mouse, defaults to 1.0f
|
|
|
|
f32 MouseYDirection;
|
|
|
|
|
|
|
|
s32 LastAnimationTime;
|
|
|
|
|
|
|
|
core::array<SKeyMap> KeyMap;
|
|
|
|
core::position2d<f32> CenterCursor, CursorPos;
|
2020-10-26 20:50:18 +01:00
|
|
|
bool HadMouseEvent;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
bool CursorKeys[EKA_COUNT];
|
|
|
|
|
|
|
|
bool firstUpdate;
|
|
|
|
bool firstInput;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace scene
|
|
|
|
} // end namespace irr
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#endif // IRR_C_SCENE_NODE_ANIMATOR_CAMERA_FPS_H_INCLUDED
|