How to get object position?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Magnet
Posts: 101
Joined: Wed Sep 27, 2006 7:32 pm

How to get object position?

Post by Magnet »

I have model with 2 objects.
How to get position of one of the objects in the sceene?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
CodeDog
Posts: 106
Joined: Sat Oct 07, 2006 8:00 pm
Location: CA. USA
Contact:

Post 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
	}
Magnet
Posts: 101
Joined: Wed Sep 27, 2006 7:32 pm

Post by Magnet »

Hm. I am not found getB3DJointNode function.
I view cvs but not found it :-(
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

It's not CVS anymore, it's SVN.
Magnet
Posts: 101
Joined: Wed Sep 27, 2006 7:32 pm

Post by Magnet »

Yes. I am download it from SVN.
But I have errors with compile IrrLicht :-(

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