A Simple question
-
siberianstar
- Posts: 11
- Joined: Wed Jun 28, 2006 5:13 pm
A Simple question
How can i see if a triangle S3DVertex2TCoords triangle[3], is interesecting the frustum view?
Code: Select all
// this is a rough estimate because the frustrum box is larger than the actual view frustrum
core::aabbox3df frustrumBox = SceneManager->getActiveCamera()->getViewFrustrum()->getBoundingBox();
const core::line3df lineA(triangles[0].Pos, triangles[1].Pos);
const core::line3df lineB(triangles[1].Pos, triangles[2].Pos);
const core::line3df lineC(triangles[2].Pos, triangles[0].Pos);
return frustrumBox.intersectsWithLine(lineA) ||
frustrumBox.intersectsWithLine(lineB) ||
frustrumBox.intersectsWithLine(lineC);
Code: Select all
// this is even worse estimate because the triangle is fit into a box and that
// is compared against the frustrum box
core::aabbox3df frustrumBox = SceneManager->getActiveCamera()->getViewFrustrum()->getBoundingBox();
core::aabbox3df triangleBox(triangles[0].Pos);
triangleBox.addInternalPoint(triangles[1].Pos);
triangleBox.addInternalPoint(triangles[2].Pos);
return frustrumBox.intersectsWithBox(triangleBox);
Code: Select all
// this should be more accurate, but slow. probably a more efficient way
scene::SViewFrustrum* frustrum = SceneManager->getActiveCamera()->getViewFrustrum();
const core::line3df lineA(triangles[0].Pos, triangles[1].Pos);
const core::line3df lineB(triangles[1].Pos, triangles[2].Pos);
const core::line3df lineC(triangles[2].Pos, triangles[0].Pos);
u32 p;
for (p = 0; p < scene::VF_PLANE_COUNT; ++p)
{
if (frustrum->planes[p].getIntersectionWithLimitedLine(triangles[0].Pos, triangles[1].Pos) ||
frustrum->planes[p].getIntersectionWithLimitedLine(triangles[1].Pos, triangles[2].Pos) ||
frustrum->planes[p].getIntersectionWithLimitedLine(triangles[2].Pos, triangles[0].Pos))
return true;
}
return false;
Last edited by vitek on Fri Jun 30, 2006 5:49 am, edited 1 time in total.
-
siberianstar
- Posts: 11
- Joined: Wed Jun 28, 2006 5:13 pm
-
siberianstar
- Posts: 11
- Joined: Wed Jun 28, 2006 5:13 pm
-
siberianstar
- Posts: 11
- Joined: Wed Jun 28, 2006 5:13 pm
i've rewritten the csoftwaredriver2 class because there were less code to delete
I'm using pspgl with the PSP Console to port irrlicht 1.0 on psp.
But the psp has got a stupid clipping algo and when a vertex goes too far from the screen it just culls the entire primitive. The result is here:
http://85.25.18.122/IM000345.jpg
But the psp has got a stupid clipping algo and when a vertex goes too far from the screen it just culls the entire primitive. The result is here:
http://85.25.18.122/IM000345.jpg
-
siberianstar
- Posts: 11
- Joined: Wed Jun 28, 2006 5:13 pm
I've rewritten the csoftwaredriver2 class because there were less code to delete. I'm using PSPGL to port Irrlicht 1.0 on the PSP. But the PSP has a stupid clip algo. And when a vertex goes too far away from the screen the psp just cull the entire primitive.
Result:
http://85.25.18.122/IM000345.jpg
So i'had to tessellate the triangles that intersect the frustum view.
Result:
http://85.25.18.122/IM000345.jpg
So i'had to tessellate the triangles that intersect the frustum view.