[SOLVED]intersectsWith strange behaviour

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
onesixtyfourth
Posts: 21
Joined: Mon Nov 03, 2008 10:18 am

[SOLVED]intersectsWith strange behaviour

Post by onesixtyfourth »

I have the following code:

Code: Select all

 
//detect a collision with the camera
            if(camera->getTransformedBoundingBox().intersectsWithBox(
                                        cubeOne->getTransformedBoundingBox()))
            {//set cube invisible if intersecting with camera
                cubeOne->setVisible(false);
            }
 
but it does not work correctly. As is the cube is always invisible. Commenting it out allows the cube to remain visisble. Negating the check allows the cube to remain visible until the camera moves. What am I missing here?
Last edited by onesixtyfourth on Fri Oct 07, 2011 2:43 pm, edited 1 time in total.
Glasys
Noli illegitimi carborundum
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: intersectsWith strange behaviour

Post by shadowslair »

My assumption is that the camera doesn`t have any bbox? If you need to check against some bbox around the camera origin you can do sth like:

Code: Select all

 
f32 camHalfsize = 1.0f; // how big?!
core::vector3df camExtent(camHalfsize);
core::vector3df camPos(camera->getAbsolutePosition());
core::aabbox3df camBox; // camera aabbox in WS
camBox.MinEdge = camPos - camExtent;
camBox.MaxEdge = camPos + camExtent;
 
//set cube invisible if intersecting with camera or visible if not
cubeOne->setVisible(!camBox.intersectsWithBox(cubeOne->getTransformedBoundingBox()));
 
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
onesixtyfourth
Posts: 21
Joined: Mon Nov 03, 2008 10:18 am

Re: intersectsWith strange behaviour

Post by onesixtyfourth »

Thank you for replying. Does that mean that the addCameraSceneNodeFPS creates a node without dimension?

[edit] you were absolutely correct and I now have the effect I was after so I gues that the camera node doesn't have any dimension to it.
Glasys
Noli illegitimi carborundum
Post Reply