Sign in to follow this  
user88

Plane.Transform in SlimDX is not the same as in MDX??

Recommended Posts

Hi All. I'm doing some migration my project from MDX to SlimDX. Currently i have found out that Plane.Transform result is not the same in both libraries. For instance, there are two code snipeds. First in MDX and works good, the second in SlimDX:
for (int i = 0; i < 6; i++)
{
   Plane clipPlane = device.ClipPlanes[i].Plane;
   clipPlane.Transform(Matrix.TransposeMatrix(Matrix.Invert(device.Transform.View * device.Transform.Projection)));
   device.ClipPlanes[i].Plane = clipPlane;
}


Matrix vp = device.GetTransform(TransformState.View) * device.GetTransform(TransformState.Projection);
vp.Invert();
Matrix trspsInvVP;
Matrix.Transpose(ref vp, out trspsInvVP);
for (int i = 0; i < 6; i++)
{
   Plane plane = device.GetClipPlane(i);
   Plane trspsInvVPPlane;
   Plane.Transform(ref plane, ref trspsInvVP, out trspsInvVPPlane);
   device.SetClipPlane(i, trspsInvVPPlane); 
}


Note that transformation matrices is the same. Example: Transformation matrix: 0.41 0.0 -40 40 0.0 0.41 -25 25 0.0 0.0 -147.08 146.09 0.0 0.0 -0.02 0.02 Plane to transform: A:0 B:0 C:-1 D:-237 (MDX) Normal:X:0 Y:0 Z:-1; D:-237 (SlimDX) Results: A:0 B:0 C:151.82 D:-150.83 (MDX) Normal:X:1164082 Y:715221.4 Z:-1731198; D:-1742990 (SlimDX) Question: where is my mistake? [Edited by - user88 on March 5, 2010 3:16:28 AM]

Share this post


Link to post
Share on other sites
From a quick glance, the second code snippet wouldn't even compile due to line 9.

Secondly, the SetTransform method of the device is a set accessor which doesn't actually return a transform. So the whole line 9 doesn't make sense at all even though it would be syntatically correct (which it isn't).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this