[Q] 2. Child Camera with loaded Meshes

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
MetaMapper
Posts: 18
Joined: Mon Aug 27, 2007 5:40 am
Location: Vienna, Austria

[Q] 2. Child Camera with loaded Meshes

Post by MetaMapper »

Hi there,
i have a question... i made a hud with tutorial 6 (2d) so far so good... now i want a weapon too, but not as a pic (.bmp/2d hud)! i want to load a weapon model...
Well i read some threads and found out that this is possible with a
"second (i m using a FPS camera) child camera with a loded mesh"...?

Well... i ve never coded child stuff (dunno what this means)... could u help
me?
Nope.
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

This should be fairly easy, and irrlicht makes adding nodes to others as children very simple.

What you need to do is create a pointer to your camera, then load your model, and set it's parent to the camera.

Here's some sudo-code

Code: Select all

scene::ICameraSceneNode* camera = smgr->getActiveCamera();
IAnimatedMesh* mesh = smgr->getMesh("Filenameofmesh");
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh->getMesh(0),camera <--This is the parent);
Then just add a texture and treat the node as normal.
MetaMapper
Posts: 18
Joined: Mon Aug 27, 2007 5:40 am
Location: Vienna, Austria

Post by MetaMapper »

So if i understand right...

this is my parent-cam (my main FPS cam):

Code: Select all

scene::ICameraSceneNode* camera;

camera = smgr->addCameraSceneNodeFPS(0, 100.0f, 280, -1, keyMap, 9, false, 0.35);

camera->setPosition(core::vector3df(-100,50,-150));
and i need to make a child cam with ur code:

Code: Select all

camera = smgr->getActiveCamera();
IAnimatedMesh* mesh = smgr->getMesh("Filenameofmesh");
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh->getMesh(0),camera); 
is this correct?
if yeah, there comes an error...
it says that it cant convert parameter 1 (imesh) to parameter 2
(animatedmesh) or something like this... it occures in this line:

"smgr->addAnimatedMeshSceneNode(mesh->getMesh(0),camera);"

greetz, hope 4 help
Nope.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you want to add an *Animated*MeshSceneNode you habe to use an animated mesh as the first parameter. Don't use getMesh(0). Or add an IMeshSceneNode...
MetaMapper
Posts: 18
Joined: Mon Aug 27, 2007 5:40 am
Location: Vienna, Austria

Post by MetaMapper »

u mean:

Code: Select all

camera = smgr->getActiveCamera();
IAnimatedMesh* mesh;
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode("PathofModel" ,camera); 
?? :?
Nope.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No. Use smgr->addAnimatedMeshSceneNode(mesh, camera) with mesh containing the animated mesh as in your first example. I said don't use getMesh(0); the getMesh("filename") is ok.
MetaMapper
Posts: 18
Joined: Mon Aug 27, 2007 5:40 am
Location: Vienna, Austria

Post by MetaMapper »

thx =)...
um... my last question is... how can i fix this cild cam (node) in front of the main fps-cam?

greetz
Nope.
MetaMapper
Posts: 18
Joined: Mon Aug 27, 2007 5:40 am
Location: Vienna, Austria

Post by MetaMapper »

can i fix it with this lines:

Code: Select all

           node->setPosition(vector3df(0, 0, 0));
           node->setScale(vector3df(1, 1, 1)); 
?
Nope.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, because those are the default values. You have to play with the position until it happens to have the correct place. Just remember that positive z is into the plane (further away from the cam) and positive y is up (positive x is to the right, but one's used to that).
MetaMapper
Posts: 18
Joined: Mon Aug 27, 2007 5:40 am
Location: Vienna, Austria

Post by MetaMapper »

Yea i know that i need to change the values first but are the commands right:

Code: Select all

           node->setPosition(vector3df(x, x, x));
           node->setScale(vector3df(x, x, x)); 
i mean setposition and setscanle x_x'

greetz
Nope.
Post Reply