VBGamer |
|||||||||||||||||||||||||||
Re: Triangle Culling in Direct3D8 Sylvain Dupont (1 reply, 0 views) (2001-Jan-9) Hi,
Just compute the clip planes from your fov & camera pos.
There is a ComputeClipPlane in the SDK D3DUTILS.BAs module
Then use this code to do the frustum culling :
Function CheckSphere(Center As D3DVECTOR, Radius As Single) As Integer
Dim TCenter As D3DVECTOR
Dim Matrix As D3DMATRIX, i As Long
' On Error Resume Next
Device.GetTransform D3DTS_WORLD, Matrix
TCenter = TransformCoord(Matrix, Center)
For i = 0 To 5
Dist = D3DXPlaneDotCoord(FrustumPlanes(i), TCenter)
If Dist < -Radius Then
CheckSphere = 0 'not visible
Exit Function
End If
Next i
CheckSphere = 1 'visible
End Function
Just look at the TrueVision source code to find useful stuff ;)
(TrueVisionGlobal.bas)
hope this helps
Sylvain
www.Truevision3d.Com
|