Page 1 of 1

Avatar help->attach to camera

Posted: Sun Oct 16, 2005 4:09 pm
by MikeR
I'm using code to attach a weapon to the camera, tweaked to make it an avatar instead, but my avatar isn't loading.
The code is:

Code: Select all

//avatar test
 // need to add a camera and name it camera to use it to 
   // attach the weapon to it for movement 
   scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f); 

   // lets place an avatar in the scene 
   scene::IAnimatedMesh* avMesh = smgr->getMesh("media/defaultblueguy.dmf"); 

   // Create a node so we can attach the avatar to the camera 
   scene::IAnimatedMeshSceneNode* avNode = smgr->addAnimatedMeshSceneNode( avMesh, camera, 

-1 ); 

   // Your animation speed may be different so play with the value 
  // avNode->setAnimationSpeed(20); 

   // The next few lines are the ones that have to be hand 
   // tweaked and you may not at first see your avatar. 
   // The values below reflect my avatar setting to see 
   // it in front of me.
   avNode->setScale(core::vector3df(6,6,6)); 
   avNode->setPosition(core::vector3df(0,340,50)); 
   avNode->setRotation(core::vector3df(0,-95,0)); 

   // The final setup putting the camera in the level 
   // where it best suits the start of gameplay. 
   camera->setPosition(core::vector3df(0,350,50)); 
   camera->setRotation(core::vector3df(0,-95,0));
//Add collision responce to the camera
	scene::ISceneNodeAnimator* anim =    smgr->createCollisionResponseAnimator(
		selector, camera, core::vector3df(30,50,30),
		core::vector3df(0,-3,0),
		core::vector3df(0,50,0));
	camera->addAnimator(anim);
	anim->drop();
	
	// disable mouse cursor

	device->getCursorControl()->setVisible(false);
	
I am using the code posted by Rat here:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=1630
The scene is still rendering fine.
Camera is working as expected with collide and gravity.
No avatar.

Posted: Mon Oct 17, 2005 10:30 am
by bearSoft
would'nt a child of the camera move with the camera?
the word 'avatar' confuses me
i saw the screenshots of ur world / user interfacing project and imagine like a small animated creture as compagnion for the user as he move through the interface.
is that asumption correct?

-at least ur post was bumped up ;)

Posted: Mon Oct 17, 2005 11:01 am
by Squad
So he wants a gun to move like in a FPS with his camera? Sounds like bearSoft has the idea because if you child it then it would follow it so it would always be there should try that to see if it works.



bearSoft I love your small print :wink:

Posted: Mon Oct 17, 2005 9:39 pm
by MikeR
An avatar is just a mesh that looks kinda like a person to represent you in a virtual world.
I've been looking at adding the av as a child node.
Coding is such a headache. I love your fine print too

searching in the forum

Posted: Wed Oct 19, 2005 8:44 am
by r3i
Hi Mike,
i think that you must consider your avatar like a personalized curso for your mouse with traslated coordinates: watch here and in the forum "How to"
you can find 1000 topic explaning perfectly the procedures.

^.^ see ou soon

Posted: Thu Oct 20, 2005 12:28 am
by MikeR
Thanks. I added my av as a child node of the camera and it worked perfectly.
I did a search the other day and downloaded several examples of making the camera a child of the av and will try those soon.
Thanks for all the help. :)