Page 1 of 1

How to get object position?

Posted: Fri Nov 03, 2006 10:27 pm
by Magnet
I have model with 2 objects.
How to get position of one of the objects in the sceene?

Posted: Fri Nov 03, 2006 11:46 pm
by bitplane
you can't. mesh buffers inside a mesh object don't have their own transformation matrix, so there's no offset, rotation etc. you can get the bounding box of a buffer, but otherwise you'll have to load them as separate meshes.

Posted: Sat Nov 04, 2006 6:01 am
by CodeDog
Use a model type that supports bones and has a get[modeltype]Node("nodename") B3D example: getB3DJointNode
Then attach an invisible node using addChild(nodename) to the target bone and then use getAbsolutePositionon on the invisible node.

Code Example:

Code: Select all

//add b3d animated gremlin
	scene::IAnimatedMeshSceneNode* anode = 0;
	scene::IAnimatedMesh* mesh = 0;
	mesh = smgr->getMesh("../media/gremlin.b3d");
	anode = smgr->addAnimatedMeshSceneNode(mesh);
	anode->setPosition(core::vector3df(50,5,-75));
	anode->setAnimationSpeed(1000);
	anode->setLoopMode(true);
	anode->setScale(core::vector3df(1,1,1));
	scene::ISceneNode* hand = 0;
	hand = anode->getB3DJointNode("thumbR1");
	scene::IAnimatedMeshSceneNode* smfairy = 0;
	smfairy = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../media//faerie.md2"));
	smfairy->setMaterialTexture(0, driver->getTexture("../media/faerie2.bmp")); // set diffuse texture	
	smfairy->setScale(core::vector3df(0.5,0.5,0.5));//makes it small
	smfairy->setMD2Animation(scene::EMAT_SALUTE);
	if(hand != 0)
	{
		//put the little fairy in the gremlins hand
		hand->addChild(smfairy);
		//smfairy->getAbsolutePosition
	}

Posted: Sat Nov 04, 2006 11:28 am
by Magnet
Hm. I am not found getB3DJointNode function.
I view cvs but not found it :-(

Posted: Sat Nov 04, 2006 3:56 pm
by hybrid
It's not CVS anymore, it's SVN.

Posted: Sat Nov 04, 2006 8:00 pm
by Magnet
Yes. I am download it from SVN.
But I have errors with compile IrrLicht :-(

http://irrlicht.sourceforge.net/phpBB2/ ... 4709#94709
:?: :cry: