[solved (no bug)] BoundingBox bug?

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
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

[solved (no bug)] BoundingBox bug?

Post by moriwo »

I discovered the strangeness of boundingbox.

When octree node is added, boundingbox doesn't follow to the position of
the character node.

Is this a Irrlicht bug?

this worked correctly.

Code: Select all

/*	//create ground mesh
	IAnimatedMesh* mesh = Scene->getMesh("ground.x");
	ISceneNode* otNode = Scene->addOctTreeSceneNode(mesh->getMesh(0));
	ITriangleSelector* selector= Scene->createOctTreeTriangleSelector(mesh,otNode,32);
	otNode->setTriangleSelector(selector);
	otNode->setPosition(vector3df(3,0,-3));
*/

	//create character mesh 
	IAnimatedMesh* charMesh = Scene->getMesh("mypc.x"); 
	IAnimatedMeshSceneNode* charNode = Scene->addAnimatedMeshSceneNode(charMesh); 
	charNode->setAnimationSpeed(5000); 

	while(Device->run()) 
	{   
		charNode->setPosition(charNode->getPosition() + vector3df(0,0,0.01f));
		charNode->getMesh()->getMeshBuffer(0)->recalculateBoundingBox();
		aabbox3df aabb = charNode->getMesh()->getMeshBuffer(0)->getBoundingBox();

		//render 
		Driver->beginScene(true, true, SColor(0,100,100,160)); 
		Scene->drawAll(); 
		Driver->draw3DBox(aabb);
		Driver->endScene(); 
	} 
This did not work correctly.
The difference only added octreenode.

Code: Select all

	//create ground mesh
	IAnimatedMesh* mesh = Scene->getMesh("ground.x");
	ISceneNode* otNode = Scene->addOctTreeSceneNode(mesh->getMesh(0));
	ITriangleSelector* selector= Scene->createOctTreeTriangleSelector(mesh,otNode,32);
	otNode->setTriangleSelector(selector);
	otNode->setPosition(vector3df(3,0,-3));

	//create character mesh 
	IAnimatedMesh* charMesh = Scene->getMesh("mypc.x"); 
	IAnimatedMeshSceneNode* charNode = Scene->addAnimatedMeshSceneNode(charMesh); 
	charNode->setAnimationSpeed(5000); 

	while(Device->run()) 
	{   
		charNode->setPosition(charNode->getPosition() + vector3df(0,0,0.01f));
		charNode->getMesh()->getMeshBuffer(0)->recalculateBoundingBox();
		aabbox3df aabb = charNode->getMesh()->getMeshBuffer(0)->getBoundingBox();

		//render 
		Driver->beginScene(true, true, SColor(0,100,100,160)); 
		Scene->drawAll(); 
		Driver->draw3DBox(aabb);
		Driver->endScene(); 
	} 
Last edited by moriwo on Sat Aug 09, 2008 1:14 pm, edited 2 times in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Excerpt from the API docs for draw3DBox:
/** This method simply calls draw3DLine for the edges of the
box. Note that the box is drawn using the current transformation
matrix and material. So if you need to draw it independently of
the current transformation, use
\code
driver->setMaterial(unlitMaterial);
driver->setTransform(video::ETS_WORLD, core::matrix4());
\endcode
for some properly set up material before drawing the box.
\param box The axis aligned box to draw
\param color Color to use while drawing the box. */
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

maybe it's better to use setDebugDataVisible(...) on the node ??? ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
moriwo
Posts: 40
Joined: Fri Jul 04, 2008 9:29 pm

Post by moriwo »

>hybrid

oh, i'm sorry. i see it now.

>Acki

it looks good. thanks Acki.
Post Reply