Sign in to follow this  

Frustum Culling with Direct3D #2

This topic is 4747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Could somebody explain to me why this doesn't work? Here is my plane extraction code (VB.NET): Public Sub ExtractFrustumPlanes(Optional ByVal Normalize As Boolean = True) Dim comboMatrix As Matrix = Matrix.Multiply(ccCore.Device.Transform.View, ccCore.Device.Transform.Projection) 'Left clipping plane ccFrustum(0).A = comboMatrix.M14 + comboMatrix.M11 ccFrustum(0).B = -(comboMatrix.M24 + comboMatrix.M21) ccFrustum(0).C = -(comboMatrix.M34 + comboMatrix.M31) ccFrustum(0).D = -(comboMatrix.M44 + comboMatrix.M41) 'Right clipping plane ccFrustum(1).A = -(comboMatrix.M14 - comboMatrix.M11) ccFrustum(1).B = -(comboMatrix.M24 - comboMatrix.M21) ccFrustum(1).C = -(comboMatrix.M34 - comboMatrix.M31) ccFrustum(1).D = -(comboMatrix.M44 - comboMatrix.M41) 'Top clipping plane ccFrustum(2).A = -(comboMatrix.M14 - comboMatrix.M12) ccFrustum(2).B = -(comboMatrix.M24 - comboMatrix.M22) ccFrustum(2).C = -(comboMatrix.M34 - comboMatrix.M32) ccFrustum(2).D = -(comboMatrix.M44 - comboMatrix.M42) 'Bottom clipping plane ccFrustum(3).A = -(comboMatrix.M14 + comboMatrix.M12) ccFrustum(3).B = -(comboMatrix.M24 + comboMatrix.M22) ccFrustum(3).C = -(comboMatrix.M34 + comboMatrix.M32) ccFrustum(3).D = -(comboMatrix.M44 + comboMatrix.M42) 'Near clipping plane ccFrustum(4).A = -(comboMatrix.M14 + comboMatrix.M13) ccFrustum(4).B = -(comboMatrix.M24 + comboMatrix.M23) ccFrustum(4).C = -(comboMatrix.M34 + comboMatrix.M33) ccFrustum(4).D = -(comboMatrix.M44 + comboMatrix.M43) 'Far clipping plane ccFrustum(5).A = -(comboMatrix.M14 - comboMatrix.M13) ccFrustum(5).B = -(comboMatrix.M24 - comboMatrix.M23) ccFrustum(5).C = -(comboMatrix.M34 - comboMatrix.M33) ccFrustum(5).D = -(comboMatrix.M44 - comboMatrix.M43) If Normalize Then For I As Integer = 0 To 5 ccFrustum(I).Normalize() 'NormalizePlane(ccFrustum(I)) Next End If End Sub And my sphere testing code (of course, also VB.NET): Public Function FrustumTestSphere(ByVal vCenter As m3dVector3D, ByVal Radius As Single) As Boolean Dim Distance As Single Dim tCenter As Vector3 tCenter = vCenter.ToVector3 tCenter.TransformCoordinate(ccCore.Device.Transform.World) For I As Integer = 0 To 5 Distance = Plane.DotNormal(ccFrustum(I), tCenter) Debug.WriteLine(Distance) If Distance < -Radius Then Return False End If Next Return True End Function Thanks!

Share this post


Link to post
Share on other sites

This topic is 4747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this