Hi there,
im working on furstum culling at the moment but i'm a little stuck with some tutorials...
hope anyone can help me...
i'm trying to check if a sphere is inide my frustum.
the problem is here: Distance := NormalizePlane(i, Center) )+m_plane[i].Distance(); <-- How can I get the distacne of the plane? (i got it from a tutorial, (C++ code)
[pascal]
function TFrustrum.ContainsSphere(Center: TD3DVector;
Radius: single): boolean;
var Distance : single; // various distances
i : integer;
begin
// calculate our distances to each of the planes
for i := 0 to 5 do
begin
// find the distance to this plane
Distance := NormalizePlane(i, Center) )+m_plane[i].Distance();
// if this distance is < -sphere.radius, we are outside
if Distance < -Radius then
begin
Result := FRUSTRUM_OUT;
Exit;
end else
if Abs(Distance) < Radius then
begin
Result := FRUSTRUM_INTERSECT;
Exit;
end;
end;
// otherwise we are fully in view
result := FRUSTRUM_IN;
end;
[/pascal]
the next step is the bounding box, but that souldn't be a prob when I got this working...
Thnxz in advance!!
tutorials:
http://www.flipcode.com/articles/art...mculling.shtml
http://www.gamedev.net/community/for...=11&gforum_id=
http://p214.ezboard.com/fmrgamemaker...cID=3801.topic
Bookmarks