Hi Kony,
On Thu, 2005-02-10 at 09:31, Kornelia Ganglbauer wrote:
> Hallo!
>
> First of all, thank you all for the information.
> I make an application to edit a scene. The camera position can be changed by
> the user (by hitting a button). So he can see all parts of the scene. But my
> scene is not endless, it has borders in all direction (for example: along
> the x -axis the highest coordinate is (12/0/0)). So I need to know how much
> can be seen with the actual camera position. So that I can stop the motion
> of the camera, if this point is reached.
> I tried many different things but I have not achieved a good result.
If you want to ensure that the viewing frustum doesn't leave the
bounding box of your scene you can make sure that none of the frustum's
corner vertices are outside the box. I cobbled together some untested
code, but it should give you an idea of how to do it:
FrustumVolume frust = camera->getFrustum(frust, viewport);
// Calc the corner points of the frustum
const Plane *pl = frust.getPlanes();
Pnt3f vertices[8];
Line lines [4];
pl[5].intersect(pl[3],lines[3]);
pl[3].intersect(pl[4],lines[2]);
pl[4].intersect(pl[2],lines[0]);
pl[2].intersect(pl[5],lines[1]);
for(UInt32 i = 0; i < 4; i++)
{
pl[0].intersectInfinite(lines[i],vertices[ i]);
pl[1].intersectInfinite(lines[i],vertices[4 + i]);
}
// Test them against the box
for(UInt32 i = 0; i < 8; i++)
{
if(!box.intersect(vertices[i]))
std::cout << "Frustum outside of box!" << std::endl;
}
Hope it helps
Dirk
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users