• Advertisement
Sign in to follow this  

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

This topic is 2881 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

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.Plane;
   clipPlane.Transform(Matrix.TransposeMatrix(Matrix.Invert(device.Transform.View * device.Transform.Projection)));
   device.ClipPlanes.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
Advertisement
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
Sorry. 9 line is the part of commented line which i tried to remove. I will modify my post right now. Please have a look one more time.

Share this post


Link to post
Share on other sites
Try to step thru both versions and see where the values begin to differ.

In particular, are the clip planes of the device the same before you enter this block?

Share this post


Link to post
Share on other sites
Yes, clip planes are the same. The values begin to differ right after Plane.Transform..

[Edited by - user88 on March 5, 2010 4:55:53 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement