Problem on getBoundingBox() (Newton´s integration)

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
hoffhoff
Posts: 17
Joined: Fri Mar 10, 2006 11:55 am

Problem on getBoundingBox() (Newton´s integration)

Post 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!
Hirte
Posts: 73
Joined: Sat Apr 01, 2006 1:32 pm

Post 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...
hoffhoff
Posts: 17
Joined: Fri Mar 10, 2006 11:55 am

Post 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?
Hirte
Posts: 73
Joined: Sat Apr 01, 2006 1:32 pm

Post by Hirte »

Nope, I'm a noob;)

What mesh do you have? Maybe false boundingbox... or you have this irrtonewton in your terraincollision, too.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post 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);
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post 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
hoffhoff
Posts: 17
Joined: Fri Mar 10, 2006 11:55 am

Post 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!
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post 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.
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
hoffhoff
Posts: 17
Joined: Fri Mar 10, 2006 11:55 am

Post 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?
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post 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
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
hoffhoff
Posts: 17
Joined: Fri Mar 10, 2006 11:55 am

Post 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!
Post Reply