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!
Getting Camera Information from .irr file
[Solved] with thanks to randomMesh
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.
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!
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);
Hope that helps someone else!
[Solved] using an FPS cam :-)
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.
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!
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);
}