Page 1 of 1

Problem on getBoundingBox() (Newton´s integration)

Posted: Thu Jun 01, 2006 5:10 pm
by hoffhoff
Hello, I don´t knwo if this is the right forum to ask it, but anyway
I´m trying to integrate irrlicht with newton, and then I did this:


IrrToNewton = 1/32
//creating the Box
core::aabbox3d<f32> box;
vector3df size;
box = this->meshscenenode->getBoundingBox();
size = box.getExtent() * IrrToNewton;
ncollision = NewtonCreateBox(my_nworld, size.X, size.Y, size.Z, NULL);

Well, the collision do works, but it is not happening where it is supposed to.
For example, if I create a box in a high position, it will fall, but the collision with the ground will happen before the mesh touch the ground, and then the box will be floating a few centimeters over the ground.

Is this the right way to read the size of the mesh?

Thanks!

Posted: Thu Jun 01, 2006 5:18 pm
by Hirte
I have

core::aabbox3d<f32> box = node->getBoundingBox();
core::vector3df size = box.MaxEdge - box.getCenter();
collision3 = NewtonCreateBox(nWorld, size.X*2,size.Y*2,size.Z*2, NULL);


forget this 1/32 irrtonewton... seem to be not necessary...

Posted: Thu Jun 01, 2006 5:36 pm
by hoffhoff
Hey
Thank you for replying
I did this, but I still have the same problem.

Do you know wheresle I could be making some mistake?

Posted: Thu Jun 01, 2006 6:17 pm
by Hirte
Nope, I'm a noob;)

What mesh do you have? Maybe false boundingbox... or you have this irrtonewton in your terraincollision, too.

Posted: Thu Jun 01, 2006 7:28 pm
by etcaptor
Your problem is not in Irrlicht bounding box, but in bounding box offset.
You can correct this in your 3d modeling program or just calculate offset position and use it like a parameter:

NewtonCreateBox(my_nworld, size.X, size.Y, size.Z, offset);

Posted: Thu Jun 01, 2006 10:52 pm
by dhenton9000
I have a small demo that you might be able to snarf code from:

http://s-fonline.com/webhosting/dhenton ... erdemo.php

Its a bunch of boxes flying in a big box. The big box is created in a separate subroutine, and you might be able to strip the code out to fit your needs. Also, the little flying things use code similar to yours. If you grep the code for "getextent" it might prove useful

HTH

Posted: Thu Jun 01, 2006 11:01 pm
by hoffhoff
etcaptor: Thank you!
I´ll check that out with the guy that created the model for me.


dhenton9000: Hey, I already got your code. That´s pretty cool and I learned a lot from it. But the getboundingbox stuff is very similar, and so I didn´t know what to do.

By the way, what is OpenSteer?
I took a look at their website, but I didn´t get what is it for (my English is not so good).


Thank you all!

Posted: Thu Jun 01, 2006 11:22 pm
by etcaptor
My personal choice was to use calculations of offset by bounding box center. That is useful because you can apply it for many free models.
That is not only related with newton. See this screen:
We have a two Irrlicht models - sydney.md2 and DWARF.X with coordinates by x, y, z. Z is !=0 only for second model for good vision

Image

From this view you can foresee immediately what behaviour will get your newton box collision for these meshes.

Posted: Thu Jun 01, 2006 11:28 pm
by hoffhoff
That´s nice!
How can you obtain that image?
I mean.. how to let the bounding box visible (with the white box)?
Is there any function for it?

Posted: Thu Jun 01, 2006 11:34 pm
by etcaptor
Because sometime I'm lazy for coding, for this goal use my VisualEditor - it's free.
You can draw bounding boxes by using of irrlicht function void irr::scene::ISceneNode::setDebugDataVisible ( bool visible )
like
yournode->setDebugDataVisible(true) ;
But this is not related with newton.
You can see dhenton9000 example. There are a functions for drawing of newton collision boxes. Just use it for debuging of your newton collision.

Here is an example with newton debug functions via convexhull collision:

Image

Posted: Fri Jun 02, 2006 3:19 am
by hoffhoff
Thanks
The bounding boxes are ok, but now I think that I got the problem:
When I do the MeshTransformEvent, I must make a little translation, because the newton is drawing the center of the mesh in the corner of the Newton´s body. So that´s why it is not touching the ground.
Thank you all!