Commit 2917a988 authored by hybrid's avatar hybrid

Add possibility to add cameras without immediately making them active. Feature request by kkrizka.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2745 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 07280fa0
...@@ -537,25 +537,31 @@ namespace scene ...@@ -537,25 +537,31 @@ namespace scene
\param parent: Parent scene node of the camera. Can be null. If the parent moves, \param parent: Parent scene node of the camera. Can be null. If the parent moves,
the camera will move too. the camera will move too.
\param id: id of the camera. This id can be used to identify the camera. \param id: id of the camera. This id can be used to identify the camera.
\param makeActive Flag whether this camera should become the active one.
Make sure you always have one active camera.
\return Pointer to interface to camera if successful, otherwise 0. \return Pointer to interface to camera if successful, otherwise 0.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1) = 0; const core::vector3df& lookat = core::vector3df(0,0,100),
s32 id=-1, bool makeActive=true) = 0;
//! Adds a maya style user controlled camera scene node to the scene graph. //! Adds a maya style user controlled camera scene node to the scene graph.
/** This is a standard camera with an animator that provides mouse control similar /** This is a standard camera with an animator that provides mouse control similar
to camera in the 3D Software Maya by Alias Wavefront. to camera in the 3D Software Maya by Alias Wavefront.
\param parent: Parent scene node of the camera. Can be null. \param parent: Parent scene node of the camera. Can be null.
\param rotateSpeed: Rotation speed of the camera. \param rotateSpeed: Rotation speed of the camera.
\param zoomSpeed: Zoom speed of the camera. \param zoomSpeed: Zoom speed of the camera.
\param translationSpeed: TranslationSpeed of the camera. \param translationSpeed: TranslationSpeed of the camera.
\param id: id of the camera. This id can be used to identify the camera. \param id: id of the camera. This id can be used to identify the camera.
\return Returns a pointer to the interface of the camera if successful, otherwise 0. \param makeActive Flag whether this camera should become the active one.
This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ Make sure you always have one active camera.
\return Returns a 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* addCameraSceneNodeMaya(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0,
f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f,
f32 translationSpeed = 1500.0f, s32 id=-1) = 0; f32 translationSpeed = 1500.0f, s32 id=-1,
bool makeActive=true) = 0;
//! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS). //! Adds a camera scene node with an animator which provides mouse and keyboard control appropriate for first person shooters (FPS).
/** This FPS camera is intended to provide a demonstration of a /** This FPS camera is intended to provide a demonstration of a
...@@ -616,13 +622,16 @@ namespace scene ...@@ -616,13 +622,16 @@ namespace scene
up when the mouse is moved down and down when the mouse is 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 moved up, the default is 'false' which means it will follow the
movement of the mouse cursor. movement of the mouse cursor.
\param makeActive Flag whether this camera should become the active one.
Make sure you always have one active camera.
\return Pointer to the interface of the camera if successful, \return Pointer to the interface of the camera if successful,
otherwise 0. This pointer should not be dropped. See otherwise 0. 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 = 0.5f, s32 id=-1, f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.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, bool invertMouse=false) = 0; f32 jumpSpeed = 0.f, bool invertMouse=false,
bool makeActive=true) = 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
......
...@@ -662,14 +662,16 @@ IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* pare ...@@ -662,14 +662,16 @@ IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* pare
//! the camera will move too. //! the camera will move too.
//! \return Returns pointer to interface to camera //! \return Returns pointer to interface to camera
ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent, ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent,
const core::vector3df& position, const core::vector3df& lookat, s32 id) const core::vector3df& position, const core::vector3df& lookat, s32 id,
bool makeActive)
{ {
if (!parent) if (!parent)
parent = this; parent = this;
ICameraSceneNode* node = new CCameraSceneNode(parent, this, id, position, lookat); ICameraSceneNode* node = new CCameraSceneNode(parent, this, id, position, lookat);
setActiveCamera(node); if (makeActive)
setActiveCamera(node);
node->drop(); node->drop();
return node; return node;
...@@ -680,10 +682,11 @@ ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent, ...@@ -680,10 +682,11 @@ ICameraSceneNode* CSceneManager::addCameraSceneNode(ISceneNode* parent,
//! to in the 3D Software Maya by Alias Wavefront. //! to in the 3D Software Maya by Alias Wavefront.
//! The returned pointer must not be dropped. //! The returned pointer must not be dropped.
ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id) f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed, s32 id,
bool makeActive)
{ {
ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(), ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(),
core::vector3df(0,0,100), id); core::vector3df(0,0,100), id, makeActive);
if (node) if (node)
{ {
ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(CursorControl, ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraMaya(CursorControl,
...@@ -700,11 +703,12 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent, ...@@ -700,11 +703,12 @@ ICameraSceneNode* CSceneManager::addCameraSceneNodeMaya(ISceneNode* parent,
//! Adds a camera scene node which is able to be controlled with the mouse and keys //! Adds a camera scene node which is able to be controlled with the mouse and keys
//! 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,
SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed, bool invertMouseY) s32 keyMapSize, bool noVerticalMovement, f32 jumpSpeed,
bool invertMouseY, bool makeActive)
{ {
ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(), ICameraSceneNode* node = addCameraSceneNode(parent, core::vector3df(),
core::vector3df(0,0,100), id); core::vector3df(0,0,100), id, makeActive);
if (node) if (node)
{ {
ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl, ISceneNodeAnimator* anm = new CSceneNodeAnimatorCameraFPS(CursorControl,
......
...@@ -133,20 +133,24 @@ namespace scene ...@@ -133,20 +133,24 @@ namespace scene
//! \return Pointer to interface to camera //! \return Pointer to interface to camera
virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNode(ISceneNode* parent = 0,
const core::vector3df& position = core::vector3df(0,0,0), const core::vector3df& position = core::vector3df(0,0,0),
const core::vector3df& lookat = core::vector3df(0,0,100), s32 id=-1); const core::vector3df& lookat = core::vector3df(0,0,100),
s32 id=-1, bool makeActive=true);
//! Adds a camera scene node which is able to be controlle with the mouse similar //! Adds a camera scene node which is able to be controlle with the mouse similar
//! like in the 3D Software Maya by Alias Wavefront. //! like in the 3D Software Maya by Alias Wavefront.
//! The returned pointer must not be dropped. //! The returned pointer must not be dropped.
virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0, virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent = 0,
f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f, s32 id=-1); f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f,
f32 translationSpeed = 1500.0f, s32 id=-1,
bool makeActive=true);
//! Adds a camera scene node which is able to be controled with the mouse and keys //! Adds a camera scene node which is able to be controled with the mouse and keys
//! like in most first person shooters (FPS): //! like in most first person shooters (FPS):
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,
f32 jumpSpeed = 0.f, bool invertMouseY=false); bool noVerticalMovement=false, f32 jumpSpeed = 0.f,
bool invertMouseY=false, bool makeActive=true);
//! 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
......
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