Object on camera ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
PC-XT

Object on camera ?

Post by PC-XT »

Is there a way i can knoe if object or entities is currently
on screen or not.

I mean if it is seen by active camera or not.

thanks in avanced for any respond.
Munku
Posts: 66
Joined: Tue Nov 30, 2004 4:04 pm

yes

Post by Munku »

Grab the node and use the fucntion isVisible() :)
Umm, don't look at me that way. I'M not the dead one here.

--The One True Marshmellow
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

no, that won't work. isVisible only returns false if you have previously called setVisible(false). The engine does not call setVisible(false) on culled nodes. Here is the function that the SceneManager uses to tell if a node is culled

Code: Select all

bool CSceneManager::isCulled(ISceneNode* node)
{
	if (!node->getAutomaticCulling())
		return false;

	ICameraSceneNode* cam = getActiveCamera();
	if (!cam)
		return false;

    core::aabbox3d<f32> tbox = node->getBoundingBox();
	node->getAbsoluteTransformation().transformBox(tbox);
	return !(tbox.intersectsWithBox(cam->getViewFrustrum()->boundingBox));

	// This is a slower but more exact version:
	// SViewFrustrum f = *cam->getViewFrustrum();
	// core::matrix4 invTrans;
	// AbsoluteTransformation.getInverse(invTrans);
	// f.transform(invTrans);
	// culled = !(f.boundingBox.intersectsWithBox(Mesh->getBoundingBox()));
}
Note that this is a very rough and inacurate culling function. A much better test (though admittedly somewhat slower to compute) would be to test the objects against the planes of the view frustum rather than simply the aabb of the view frustum.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
PC-XT

Post by PC-XT »

Thanks, but i dont know how implement this one


if ( smgr->isCulled( myscene ) )
{

}


is this the right implementation of isCulled
i got some error on this.


is says isCulled is not part of smgr

please show me how to implement the isCulled()
function.

thx
Post Reply