Jump to content
  • Advertisement
Sign in to follow this  
DwarvesH

I love all the random crap when porting from XNA to SharpDX

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

Advertisement

It seems that this is due to the fact that DirectX uses a left-handed coordinate system and XNA a right-handed one.

 

For now I have multiplied the Z axis by -1 to fix this, but I might have to change the order of vertices in triangles. And I need to update my binary mesh importers to do the same.

 

Do I need tot do this to the translation matrices of bones too?

Share this post


Link to post
Share on other sites

It seems that this is due to the fact that DirectX uses a left-handed coordinate system and XNA a right-handed one.

 

Actually, as far as I know, no part of DirectX is intrinsically left- or right-handed, you can use the system you prefer. The math functions in XNA are right-handed, but SharpDX provides both left- and right-handed versions. If you always use MathUtil.FooRH you shouldn't have to change anything more dramatic.

 

However, I'm not sure what rasterizer state XNA defaults to. Make sure to set the appropriate cull mode (clockwise or counter-clockwise). That should take care of models being displayed "inside out".

Share this post


Link to post
Share on other sites

Thanks! Indeed, I did a test and switching the math from LH to RH and modifying the sign of the camera offset had the same effect as modifying the sign of the Z axis in the mesh. So I can do LH or RH.

 

The question is which one to do? I want to maximize compatibility with existing DirectX components, especially since I'm planning on buying a few expensive packages, like SpeedTree.

 

This is probably my 10 billionth engine that I'm writing and this time everything must be perfect :). After this I'm planning only one more engine...

Share this post


Link to post
Share on other sites

Well if this one is perfect, the one you right after this will surely be a real let-down ;)

 

Yes, that surely would be the case!

 

Fortunately, I have though of that! My next engine is going to be a C++ port of my current engine, so they will both have the same features and they will both be perfect! :).

 

I'll continue to stick with LH for now. I have found that I need to invert the Z component of normals and also do this in a few shaders, but otherwise the change from RH seems to be quite painless.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!