Razor89 Posted December 15, 2004 Posted December 15, 2004 Could anybody give me a hand on why this doesn't work? Thanks! (Code is in 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 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 Quote
Administrators PlausiblyDamp Posted December 15, 2004 Administrators Posted December 15, 2004 Could you give a hint as to what the problem is (or at least where it seems to be happening). Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.