#Frustum backwards?

5 messages · Page 1 of 1 (latest)

hallow flint
#

I followed a bit of this tutorial: http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-extracting-the-planes/

Calculations:

drx::util::SPOT nCenter = this->position.Subs(this->front.Multiply(drx::gfx::ogl::n));
drx::util::SPOT fCenter = this->position.Subs(this->front.Multiply(drx::gfx::ogl::f));

double nHeight = 2.0 * tan(drx::math::Radians(this->zoom) * 0.5) * drx::gfx::ogl::n;
double fHeight = 2.0 * tan(drx::math::Radians(this->zoom) * 0.5) * drx::gfx::ogl::f;
double nWidth = nHeight * drx::gfx::ogl::ar;
double fWidth = fHeight * drx::gfx::ogl::ar;

frustum.backLeftTop = fCenter.Add(this->up.Multiply(fHeight * 0.5)).Subs(this->right.Multiply(fWidth * 0.5));
frustum.backRightTop = fCenter.Add(this->up.Multiply(fHeight * 0.5)).Add(this->right.Multiply(fWidth * 0.5));
frustum.backLeftBottom = fCenter.Subs(this->up.Multiply(fHeight * 0.5)).Subs(this->right.Multiply(fWidth * 0.5));
frustum.backRightBottom = fCenter.Subs(this->up.Multiply(fHeight * 0.5)).Add(this->right.Multiply(fWidth * 0.5));
frustum.frontLeftTop = nCenter.Add(this->up.Multiply(nHeight * 0.5)).Subs(this->right.Multiply(nWidth * 0.5));
frustum.frontRightTop = nCenter.Add(this->up.Multiply(nHeight * 0.5)).Add(this->right.Multiply(nWidth * 0.5));
frustum.frontLeftBottom = nCenter.Subs(this->up.Multiply(nHeight * 0.5)).Subs(this->right.Multiply(nWidth * 0.5));
frustum.frontRightBottom = nCenter.Subs(this->up.Multiply(nHeight * 0.5)).Add(this->right.Multiply(nWidth * 0.5));

Front of the frustum appears as a small, really small rectangle in front as it should, but back plane is like, behind the camera? Not sure my calculations are correct?

The geometric approach operates in world space and uses the information from the shape of the view frustum to extract the six planes that define the boundaries of the frustum’s volume: near, …

warm treeBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

hallow flint
#

Front of the frustum, blue rectangle. Wee bit zoomed in to see it.

#

I can get it to reverse, by dividing the back plane with their respective W values and then multiplying by for example the far Z ( 2000.0 ), then it shows up correctly, but I'm not sure I should do that?

#

Corner dumps:

// back
> X 525.469, Y 1945.39, Z 2060.18, W -1413.21
> X 1094.35, Y 482.475, Z 2590.67, W -1413.21
> X 2600.98, Y 482.475, Z 975.009, W -1413.21
> X 2032.1, Y 1945.39, Z 444.519, W -1413.21
---
// front
> X 649.994, Y 550.07, Z 666.07, W 0.929289
> X 650.022, Y 549.997, Z 666.096, W 0.929289
> X 650.098, Y 549.997, Z 666.015, W 0.929289
> X 650.069, Y 550.07, Z 665.989, W 0.929289