Page 1 of 1

Switching from fps View to 3rd person view

Posted: Wed Oct 29, 2008 8:43 pm
by Daystar
In my game one of the key features is switching from FPS mode to 3rd Person mode with a click of a key. I'm trying to add that feature to my code now but I am totally lost. As a test I'm using the ninja model from another post. I know that you would add a camera using

Code: Select all

ICameraSceneNode* camera = SceneManager->addCameraSceneNode();
But from there I can't figure out:
1) where to put the camera for the FPS mode on the ninja model
2) How to set up a 3rd person cam
3) How to switch from one to the other
4)Switch controls for the separate modes

Can anyone give me a hand here please?

Re: Switching from fps View to 3rd person view

Posted: Wed Oct 29, 2008 9:10 pm
by Acki
Daystar wrote:1) where to put the camera for the FPS mode on the ninja model
at it's head's position and set node's visibility to false...
Daystar wrote:2) How to set up a 3rd person cam
behind and above the head's position and set node's visibility to true...
Daystar wrote:3) How to switch from one to the other
react on the key stroke and perform 1) or 2)...
Daystar wrote:4)Switch controls for the separate modes
set the keys depending on the state you're in (1 or 2)...

maybe a better solution is to create 2 cameras (one for state 1 and another for state 2) with different key maps and switch between the cameras depending on the curren state (1 or 2)...

Posted: Wed Oct 29, 2008 9:12 pm
by jddevnet
I think the splitview tutorial will help you out. It demonstrates switching between cameras and using a few types of them.

http://irrlicht.sourceforge.net/tut017.html

This would provide a first person camera:

Code: Select all

ICameraSceneNode* camera2 = smgr->addCameraSceneNodeFPS();
Also check out the Maya camera:

Code: Select all

ICameraSceneNode* camera3 = smgr->addCameraSceneNodeMaya();

Posted: Wed Oct 29, 2008 10:13 pm
by Daystar
Would I set the camera as a parent to the models scene node?

Posted: Wed Oct 29, 2008 11:10 pm
by Acki
Daystar wrote:Would I set the camera as a parent to the models scene node?
not neccassarily, it depends on how you want to do the moving... ;)
if you want to use the camera's build in moving than I would do so...

Posted: Wed Oct 29, 2008 11:18 pm
by Daystar
How will I edit the models position by using the event receiver using w to go forward instead of the using the built in function.

Posted: Wed Oct 29, 2008 11:26 pm
by Acki
there are some threads about this, just search the forum... ;)

but if you use the camera as parent then why not using its movement, you can specify the keys for moving when creating the camera (look at the api for addCameraSceneNodeFPS, there is a demonstration for setting the key map for the camera)...