Jump to content
  • Advertisement
Sign in to follow this  
fireangel

[MDX] MC++ and C# ViewMatrix ( Fixed )

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

After almost a week of pulling my hair out, I think I have my problem down to the View Matrix. I'm using Visual Studio 2003. October 2006 Direct X SDK. I'm trying to make a View Matrix at 3189069.0, -3189068.75, and 4510023.0. Its looking at the Origin ( 0,0,0 ), and the UpVector is Z ( 0,0,1). This is a Right Handed View ( Matrix::LookAtRH ). In C++.Net, this returns the following: Determinant: 1 M11: 0.7071067 M12: -0.4999999 M13: 0.5000001 M14: 0 M21: 0.7071068 M22: 0.4999999 M23: -0.5000001 M24: 0 M31: 0 M32: 0.7071069 M33: 0.7071066 M34: 0 M41: 0.2033899 M42: -0.119957 M43: -6378137 M44: 1 In C#, I get: Determinant: 0.9999995 M11: 0.7071068 M12: -0.4999996 M13: 0.5000001 M14: 0 M21: 0.7071066 M22: 0.4999998 M23: -0.5000002 M24: 0 M31: 0 M32: 0.7071068 M33: 0.7071065 M34: 0 M41: 0 M42: 0 M43: -6378137 M44: 1 I would have expected these to return the EXACT same thing. I can deal with the very slight diff in numbers for most of these numbers. However, I think everything falls apart because of M41 and M42. So. A few Questions... 1. Which one is correct? I think its teh C# matrix, as other things work, but I'm not totally sure. 2. Why would they return differant things? 3. What exactly is M41 and M42's role in the View Matrix? 4. ( Maybe this one should be its own thread ) Would this result in Camera Position NOT being the center of the viewport screen? This is basically a Globe and the camera goes around it. When I run this, I have made code to Unproject for the Near and Far planes, and draw lines between the points. I also save the Camera as a point, and a Ray where I click. Depending where I am at on the globe, my Far Clipping plane can be tilted, the near plane slightly rotated ( IE, instead of the lines being parralell to teh edges of the drawing area, they are slightly angled ). In all cases, the point where the camera is at is NEVER in the center of the screen. The Ray between the Far and Close planes where a click has occured will always be way off. The far plane is always correct ( even when Tilted ), but the close plane is always off ( But it IS in line with the camera point, so something is working right ). I've tried to just use the UnProject with the Vector3 class is all cases. I have at one point tried to do the math to unproject it, but that yeilds the same result ( Slightly off, but at the 6th decimal place, I ain't gonna complain ). Anybody help me? DirectX Settings to look at? C# / C++ Compilers settings?? Thanks in advance Geoff Hilyard WannaBe programmer [Edited by - fireangel on November 22, 2006 12:58:25 PM]

Share this post


Link to post
Share on other sites
Advertisement

Its fixed.

Turns out with everything being floats, and with my units being meters, I was getting rouding errors. C# has "enhanced" floating point persision, while C++ doesn't. The end result is that by changing my units to Kilometers instead of Meters, the rounding isn't a problem ( Atleast until the screne width can be measured in real world CM. ).

FWIW.
CreateFlags::FpuPreserve did nothing in my case.
Changing the C++ setting to "Enhanced" presision did nothing but introduce tons of new errors ( Compiler flag /oP ). Turns out with this on,
double dTemp = 0.0;
will give you a "Constant is too big" error. Wonderful!

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!