Page 1 of 1

[SOLVED]intersectsWith strange behaviour

Posted: Fri Oct 07, 2011 1:15 pm
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?

Re: intersectsWith strange behaviour

Posted: Fri Oct 07, 2011 2:23 pm
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()));
 

Re: intersectsWith strange behaviour

Posted: Fri Oct 07, 2011 2:34 pm
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.