Getting Camera Information from .irr file

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jawdy
Posts: 14
Joined: Wed Jan 13, 2010 4:20 pm

Getting Camera Information from .irr file

Post by jawdy »

Hi All,

I've been learning Irrlicht for a few days, along with irrb and Blender, and most things are going great.
The problem that I'm currently having, and can't seem to find a solution for, is how to get the Camera information out of the irrb generated .irr file and into my Irrlicht "game".

The "iwalktest.exe" does it perfectly, but I can't for the life of me figure out how it's implemented... can anyone point me in the right direction?

Thanks!
jawdy
Posts: 14
Joined: Wed Jan 13, 2010 4:20 pm

[Solved] with thanks to randomMesh

Post by jawdy »

Talking this through with randomMesh on the IRC chan, it's actually a pretty simple fix!

In tutorial 15 (loading the .irr file) there's a switch statement. By adding an extra case to search for a camera, you can then set that to a camera object and you're away.

Code: Select all

scene::ICameraSceneNode * camera;
...
case scene::ESNT_CAMERA:
camera = smgr->addCameraSceneNode((scene::ICameraSceneNode*)node);
The first part is declared outside the Switch, so you have a camera instance that the .irr camera can be bound to, and the second part goes anywhere (before the default) in the switch.

Hope that helps someone else!
jawdy
Posts: 14
Joined: Wed Jan 13, 2010 4:20 pm

[Solved] using an FPS cam :-)

Post by jawdy »

When initialising the camera, you can set it as an FPS cam with the minimum details (speed etc).
A slight change to the case statement (adding some squiggly brackets) and you can set the position, rotation and any other details that the camera contains in there.

Code: Select all

scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 50.f, 0.05f);
...
case scene::ESNT_CAMERA:
	{
		const irr::core::vector3df& camPosition = ((scene::ICameraSceneNode*)node)->getPosition();
		const irr::core::vector3df& camRotation = ((scene::ICameraSceneNode*)node)->getRotation();
		camera->setPosition(camPosition);
		camera->setRotation(camRotation);
	}
The first part creates our FPS camera, then within the Switch statement we modify the case so that we can get the camera position and rotation from the array, and finally set it to our active camera!
Post Reply