getBoundingBox() question

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
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

getBoundingBox() question

Post by Serg Nechaeff »

I am trying to use this code to know when the balls (there are 5 balls in my games) touch the bat, but i am getting the messages all the time! it doesnt work :( what's up with that?

Code: Select all

	core::aabbox3d <f32> b=MyBat->node->getBoundingBox();
	
	for (int i=0; i<5; i++) {
			if (b.intersectsWithBox(Rooby[i]->node->getBoundingBox()))
				MessageBox(g_hWnd, "Collided!" ,"Good news", MB_OK);

	}
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Isometric God
Posts: 69
Joined: Sun Oct 12, 2003 3:42 pm
Location: Germany

Post by Isometric God »

Seems to be correct IMHO. Maybe they are colliding all the time. Can't think of anything else now...
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Post by Serg Nechaeff »

No, they are not colliding all the time, I see what's going on on the screen :)
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

From the API:
//! Returns the axis aligned, not transformed bounding box of this node.
//! This means that if this node is a animated 3d character, moving in a room,
//! the bounding box will always be around the origin. To get the box in
//! real world coordinates, just transform it with the matrix you receive with
//! getAbsoluteTransformation() or simply use getTransformedBoundingBox(),
//! which does the same.
So you must transform both the bat bounding box and the balls bounding box to see if they collide.
Serg Nechaeff
Posts: 162
Joined: Wed Nov 26, 2003 5:24 pm
Location: Europe

Post by Serg Nechaeff »

that works! thanks a lot, man...
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
Post Reply