AABB movement

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
en51nm
Posts: 26
Joined: Thu May 17, 2012 7:31 pm

AABB movement

Post by en51nm »

Hello, I'm having some more problems with movement of my Mesh Node and AABB.

Here is a video of my problem.

I create the node like this:

Code: Select all

 
irr_node = smgr->addMeshSceneNode(smgr->getMesh("sphere.3ds")->getMesh(0));
 
Then I get my AABB inside my draw loop, and draw four edges:

Code: Select all

 
vector3d<f32> edges[8];
irr_node->getTransformedBoundingBox().getEdges(edges);
for(int i=0;i<8;i+=2)
{
        driver->draw3DLine(edges[i],edges[i+1],SColor(255,0,0,0));
}
 
The movement is done in exactly the same way as in tutorial 4

For some reason, my AABB doesn't move with the mesh properly (as shown in video), this causes problems with my AABB collision detection.

Interestingly, if I add another scene node in the same way, the first scene node moves the AABB of both of them but the second scene node and AABB both move in unison as they should do.
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: AABB movement

Post by zerochen »

hi

if you set

Code: Select all

 irr_node->setDebugDataVisible(true);


you can see also the box. maybe different results?
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: AABB movement

Post by CuteAlien »

I suppose the problem is that the you have the wrong transformation before the draw3DLine call. You might need a call like that first:

Code: Select all

 
 driver->setTransform(video::ETS_WORLD, core::matrix4());
 
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
en51nm
Posts: 26
Joined: Thu May 17, 2012 7:31 pm

Re: AABB movement

Post by en51nm »

Thanks CuteAlient, that worked like a treat =D

Having problems with collision detection now though, it works up until I try to rotate the objects.

EDIT: All working now. I have a question though. Is it possible to alter the position of a scene nodes rotation centre?
Post Reply