Author |
Fulstrum Bug... |
Faustus Marshal Palestar
Joined: May 29, 2001 Posts: 2748 From: Austin, Texas
| Posted: 2003-07-29 11:19  
I just finished adding code to check if a zone's hull is visible, which increase the rendering speed ALOT... but I've got some bug in my boxVisible() routine. I suspect the problem is actually how I create my viewing fulstrums for clip testing. I'm working on the problem, but if any of you happen to know alot about planes and viewing fulstrums take a look at the following code to see if you spot my problem...
I suspect setting the distance to 0 for the right, left, top, and bottom planes is not right.
void RenderContext::setProjection( const RectInt & window,
float fov, float front, float back )
{
ASSERT( m_Display.valid() );
if ( window.valid() )
m_Window = window;
else
m_Window = m_Display->renderWindow();
m_Fov = fov;
m_Front = front;
m_Back = back;
// perspective projection
m_Fulstrum[FRONT].set(Vector3(0,0,1),m_Front);
m_Fulstrum[BACK].set(Vector3(0,0,-1),m_Back);
float cosine = cos(m_Fov);
float icosine = 1.0 - cosine;
m_Fulstrum[RIGHT].set(Vector3(-cosine, 0, icosine),0.0f);
m_Fulstrum[LEFT].set(Vector3(cosine, 0, icosine),0.0f);
m_Fulstrum[TOP].set(Vector3(0, -cosine, icosine),0.0f);
m_Fulstrum[BOTTOM].set(Vector3(0, cosine, icosine),0.0f);
// used by project and unProject
m_Center = PointFloat( (m_Window.right + m_Window.left) >> 1, (m_Window.top + m_Window.bottom) >> 1 );
m_D = float( m_Window.width() >> 1 ) / tan( m_Fov * 0.5f );
m_W = 1.0f / (m_Back - m_Front);
// set the projection
PrimitiveSetProjection::createGlobalPush( m_Display, m_Window, m_Fov, m_Front, m_Back );
}
_________________
Richard -Faustus- Lyle
Lead Programmer - DarkSpace
www.darkspace.net / www.palestar.com
[ This Message was edited by: Faustus on 2003-07-29 11:20 ]
_________________
|
Faustus Marshal Palestar
Joined: May 29, 2001 Posts: 2748 From: Austin, Texas
| Posted: 2003-07-29 12:36  
Ok, nevermind it's now fixed.
_________________
|