Bounding box in animated scene nodes

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!
G3LO
Posts: 16
Joined: Mon Aug 20, 2007 10:37 am
Location: Poland

Bounding box in animated scene nodes

Post by G3LO »

Hi, i`ve got problem with bounding boxes in skeletal-animated .x files.
X file was created in 3ds max 9 with X format exporter it includes skeletal animation. Running following program occurs in wrongly placed bounding box. Bounding box does not change during animation.

Code: Select all

#include <irrlicht.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

int main()
{
	IrrlichtDevice *device =
		createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 16,
			false, false, false, 0);

	device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();


	IAnimatedMesh* mesh = smgr->getMesh("test.x");
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode ( mesh );

	if (node)
	{
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setFrameLoop(0, 24);
		node->setAnimationSpeed (25);
	}	
    node->setDebugDataVisible ( EDS_BBOX );
	smgr->addCameraSceneNodeFPS();
	while(device->run())
	{
        driver->beginScene(true, true, SColor(0,200,200,200));
		smgr->drawAll();
		driver->endScene();
	}
	device->drop();
	return 0;
}
What happens:
http://www.geocities.com/analitycznie/edit/bug.JPG


What should i do? i need proper bounding boxes
h4ck d4 5y5t3m
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Surely you agree that it's better to have the wrong bounding boxes calculated rapidly than the right ones calculated slowly?

Wait... I may have dropped a bit too much acid tonight. ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
G3LO
Posts: 16
Joined: Mon Aug 20, 2007 10:37 am
Location: Poland

Post by G3LO »

Ok. I get it. Recalculating bounding boxes would slown down any game, but i would like recalculate bounding box once at begining and use more proper then shown at picture. Is it possible?
h4ck d4 5y5t3m
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, we will work on this issue. There should be an initially correct bbox, and the possibility to update the bbox during animation. This part was skipped in the new animation system as of now due to some difficulties which came from the new structure and algorithm.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

hybrid wrote:Yes, we will work on this issue.
Great. It's very important for right collision and physics.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
qez111
Posts: 54
Joined: Mon Apr 28, 2008 9:44 pm

Post by qez111 »

Sorry for bringing this problem back to limelight, but I am wondering if a solution exists for the bounding box problems for .x meshes.
Other formats like .3ds displays correct bounding box, but for the .x the bounding box is incorrectly placed. it shows up somewhere near 0,0,0 origin, whereas my object is located far away from the bounding box.
Also I the bounding box doesn't change while the .x file is animating.

Due to the above problem, my collisions don't work with Bullet properly.

Thanks.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Are you using getBoundingBox or getTransformedBoundingBox? the first one will always give you a bounding box around the origin, the latter should give you a correct bounding box for your model (not necessarily animated though)
Image Image Image
qez111
Posts: 54
Joined: Mon Apr 28, 2008 9:44 pm

Post by qez111 »

The issue is that I can see that the bb is incorrect just by setting node->setDebugDataVisible(scene::EDS_BBOX);
(This is not even in bullet. Its just plain Irrlicht). That too, the actual mesh is visible at, 0,2,5, but the bounding box is somewhere at 0,0,0. So clearly, there's no relationship between the object and bounding box. And as I said earlier, the same mesh gets correct bounding box if its a .3ds file (non-animated). But if I use .x, it shows incorrect bounding box (both static and animated .x meshes have this problem.) I use Panda Exporter for exporting .x
qez111
Posts: 54
Joined: Mon Apr 28, 2008 9:44 pm

Post by qez111 »

I am wondering if recalculateBoundingBox() will help solve this problem..? If so, is there a particular way I need to adopt to make it work properly?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Try it yourself and see if it helps ;)
Image Image Image
qez111
Posts: 54
Joined: Mon Apr 28, 2008 9:44 pm

Post by qez111 »

I tried that before and I didn't help, and that's why I actually posted that question because I thought I may not have used that function properly, and thus I wanted to know if that will help solve the problem.

At this point, I am still confused.. Has anybody else faced such a problem with .X mesh? Or is it only me? If its only me, then what could be the issue?
tprochownik
Posts: 7
Joined: Wed Sep 10, 2008 10:19 am

Post by tprochownik »

not only You. I have the same problem, but I export X mesh with scale(100%, 100%, 100%) and use bullet physic to get correctly boundingbox with animation. I had problem with correctly render mesh if I use different (like -100%) scale values.
charles88
Posts: 29
Joined: Tue Nov 04, 2008 10:02 am

Post by charles88 »

Could someone tell me whether this issue has been fixed? I am currently having problem with .x file too, :( the bounding box is below my animated node. :(

Thanks.
darkmaster83
Posts: 24
Joined: Tue Oct 14, 2008 7:41 am

Post by darkmaster83 »

I have the same problem with .ms3d file!
Files .md2 don't have this problem, but they have too many limitations, as you can see in this thread: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=31047
Any suggestions?
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

Code: Select all

IAnimatedMeshSceneNode* RepairBoundingBox(IAnimatedMeshSceneNode* node)
{
	IAnimatedMesh * mesh = node->getMesh();
		
	aabbox3df box;
	for (u32 i = 0; i < mesh->getMeshBufferCount(); i++)
	{
		mesh->getMesh(1)->getMeshBuffer(i)->recalculateBoundingBox();
		box.addInternalBox(mesh->getMesh(1)->getMeshBuffer(i)->getBoundingBox());
	}
	mesh->setBoundingBox(box);
	node->setMesh(mesh);
	return node;
}
dont know it helps, i used it for make the bounding box equal to the first frame's bounding box.
try it maybe it'll solve your problem
Image
Image
Post Reply