How can i check if a vertex is into the frustum view?
-
siberianstar
- Posts: 11
- Joined: Wed Jun 28, 2006 5:13 pm
How can i check if a vertex is into the frustum view?
The title is my question ^^
-
GueZt_Coders
- Posts: 44
- Joined: Tue Jan 17, 2006 4:04 am
Note that a vertex is just a point. If this is really your case
try my piece of code, this one works on me, you just have
to pass a position coordinate and your active cam. Hope this
will work on your case too.
try my piece of code, this one works on me, you just have
to pass a position coordinate and your active cam. Hope this
will work on your case too.
Code: Select all
//| CHECKING POINT POSITION FROM ACTIVE CAMERA FRUSTRUM VIEW
//|
//|--------------------------------------------------------
bool IsPointPosInFrustum
(
core::vector3df pPointPos,
scene::ICameraSceneNode* pActiveCam
)
//|--------------------------------------------------------
{
//| NEEDED LOCAL MEMVARS
//|
const scene::SViewFrustrum* mCamView = pActiveCam->getViewFrustrum();
float mPointD = float( pPointPos.getDistanceFrom( pPointPos ) );
float mNewD = 0;
//| IF OUTSIDE OF PLANE-1 RETURN FALSE
//|
mNewD = mCamView->planes[0].Normal.dotProduct( pPointPos )+mCamView->planes[0].D;
if( mNewD>mPointD )
{
return false;
}
//| IF OUTSIDE OF PLANE-2 RETURN FALSE
//|
mNewD = mCamView->planes[1].Normal.dotProduct( pPointPos )+mCamView->planes[1].D;
if( mNewD>mPointD )
{
return false;
}
//| IF OUTSIDE OF PLANE-3 RETURN FALSE
//|
mNewD = mCamView->planes[2].Normal.dotProduct( pPointPos )+mCamView->planes[2].D;
if( mNewD>mPointD )
{
return false;
}
//| IF OUTSIDE OF PLANE-4 RETURN FALSE
//|
mNewD = mCamView->planes[3].Normal.dotProduct( pPointPos )+mCamView->planes[3].D;
if( mNewD>mPointD )
{
return false;
}
//| IF OUTSIDE OF PLANE-5 RETURN FALSE
//|
mNewD = mCamView->planes[4].Normal.dotProduct( pPointPos )+mCamView->planes[4].D;
if( mNewD>mPointD )
{
return false;
}
//| IF OUTSIDE OF PLANE-6 RETURN FALSE
//|
mNewD = mCamView->planes[5].Normal.dotProduct( pPointPos )+mCamView->planes[5].D;
if( mNewD>mPointD )
{
return false;
}
//| POINT POSITION INSIDE CAMERA FRUSTRUM VIEW FROM HERE
//|
return true;
}
Just part of irrlicht related project| CLEAR CODE NOTATIONS IS LARGELY SELF CODUMENTING!
Unfortunately this guy is trying to rewrite the OpenGL driver for PSP. That means that the code in question is COpenGLDriver.cpp. Not only does he need to know if the vertex is in the frustrum, he [according to what he claims in another post] also needs to be able to clip the triangle that the vertex belongs to.
I'm going to suggest that he look at the CSoftwareDriver2 implementation for guidance. The method CSoftwareDriver2::clipToHyperPlane() and the methods that call it do exactly what he wants.
Travis
I'm going to suggest that he look at the CSoftwareDriver2 implementation for guidance. The method CSoftwareDriver2::clipToHyperPlane() and the methods that call it do exactly what he wants.
Travis
-
TheGameMaker
- Posts: 275
- Joined: Fri May 12, 2006 6:37 pm
- Location: Germany