Hi.
I
still have problems with Plane.Transform when migrate my project from MDX to SlimDX.
I have prepared some little Console Application. So, you can check my issue with spend short time. Just create Console Application in VS, add such references as SlimDX, Microsoft.DirectX and paste code represented below.
using System;
namespace ConsoleApplication1
{
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("***** SlimDX's *****\n{0}", GetSlimDXTrspsInvVPPlane(0.41f, 0.0f, -40.0f, 40.0f,
0.0f, 0.41f, -25.0f, 25.0f,
0.0f, 0.0f, -147.08f, 146.09f,
0.0f, 0.0f, -0.02f, 0.02f,
0f, 0f, -1, -237));
Console.WriteLine("\n\n\n***** MDX's *****\n{0} ", GetMDXTrspsInvVPPlane(0.41f, 0.0f, -40.0f, 40.0f,
0.0f, 0.41f, -25.0f, 25.0f,
0.0f, 0.0f, -147.08f, 146.09f,
0.0f, 0.0f, -0.02f, 0.02f,
0f, 0f, -1, -237));
}
private static string GetSlimDXTrspsInvVPPlane(float m11, float m12, float m13, float m14,
float m21, float m22, float m23, float m24,
float m31, float m32, float m33, float m34,
float m41, float m42, float m43, float m44,
float a, float b, float c, float d)
{
SlimDX.Matrix vp = new SlimDX.Matrix();
vp.M11 = m11; vp.M12 = m12; vp.M13 = m13; vp.M14 = m14;
vp.M21 = m21; vp.M22 = m22; vp.M23 = m23; vp.M24 = m24;
vp.M31 = m31; vp.M32 = m32; vp.M33 = m33; vp.M34 = m34;
vp.M41 = m41; vp.M42 = m42; vp.M43 = m43; vp.M44 = m44;
vp.Invert();
SlimDX.Matrix trspsInvVP;
SlimDX.Matrix.Transpose(ref vp, out trspsInvVP);
SlimDX.Plane plane = new SlimDX.Plane(a, b, c, d);
SlimDX.Plane trspsInvVPPlane;
trspsInvVPPlane = SlimDX.Plane.Transform(plane, trspsInvVP);
return String.Format("trspsInvVPPlane: {0};\n trspsInvVP: {1};\nvp:{2}", trspsInvVPPlane, trspsInvVP, vp);
}
private static string GetMDXTrspsInvVPPlane(float m11, float m12, float m13, float m14,
float m21, float m22, float m23, float m24,
float m31, float m32, float m33, float m34,
float m41, float m42, float m43, float m44,
float a, float b, float c, float d)
{
Microsoft.DirectX.Matrix vp = new Microsoft.DirectX.Matrix();
vp.M11 = m11; vp.M12 = m12; vp.M13 = m13; vp.M14 = m14;
vp.M21 = m21; vp.M22 = m22; vp.M23 = m23; vp.M24 = m24;
vp.M31 = m31; vp.M32 = m32; vp.M33 = m33; vp.M34 = m34;
vp.M41 = m41; vp.M42 = m42; vp.M43 = m43; vp.M44 = m44;
vp.Invert();
Microsoft.DirectX.Matrix trspsInvVP;
trspsInvVP = Microsoft.DirectX.Matrix.TransposeMatrix(vp);
Microsoft.DirectX.Plane plane = new Microsoft.DirectX.Plane(a, b, c, d);
Microsoft.DirectX.Plane trspsInvVPPlane;
trspsInvVPPlane = Microsoft.DirectX.Plane.Transform(plane, trspsInvVP);
return String.Format("trspsInvVPPlane: {0};\n trspsInvVP: {1};\nvp:{2}", trspsInvVPPlane, trspsInvVP, vp);
}
}
}
If run application next result has been got:
***** SlimDX's *****
trspsInvVPPlane: Normal:X:0 Y:0 Z:151,822 D:-150,832;
trspsInvVP:
M11:2,439025 M12:0 M13:0 M14:0
M21:0 M22:2,439025 M23:0 M24:0
M31:0 M32:0 M33:-1,010092 M34:-1,010092
M41:-4878,076 M42:-3048,752 M43:7378,214 M44:7428,213
vp:
M11:2,439025 M12:0 M13:0 M14:-4878,076
M21:0 M22:2,439025 M23:0 M24:-3048,752
M31:0 M32:0 M33:-1,010092 M34:7378,214
M41:0 M42:0 M43:-1,010092 M44:7428,213
***** MDX's *****
trspsInvVPPlane: A: 1156104 B: 722554,3 C: -1748636 D: -1760486;
trspsInvVP:
M11: 2,439025 M12: 0 M13: 0 M14: 0
M21: 0 M22: 2,439025 M23: 0 M24: 0
M31: 0 M32: 0 M33: -1,010092 M34: -1,010092
M41: -4878,076 M42: -3048,752 M43: 7378,214 M44: 7428,213
vp:
M11: 2,439025 M12: 0 M13: 0 M14: -4878,076
M21: 0 M22: 2,439025 M23: 0 M24: -3048,752
M31: 0 M32: 0 M33: -1,010092 M34: 7378,214
M41: 0 M42: 0 M43: -1,010092 M44: 7428,213
Why planes in both cases are different?? Please, [help]