Sign in to follow this  

convert a right-handed matrix to a left handed matrix

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

I'm using an older engine that uses dx7 and transforms + lights in software. But I want to convert it to use the fixed function TnL dx7 calls. So I did this: [quote]Flip the order of triangle vertices so that the system traverses them clockwise from the front. In other words, if the vertices are v0, v1, v2, pass them to Direct3D as v0, v2, v1. Use the view matrix to scale world space by –1 in the z-direction. To do this, flip the sign of the _31, _32, _33, and _34 member of the D3DMATRIX structure that you use for your view matrix. (Likewise, Visual Basic applications can perform this operation on the corresponding members of the D3DMATRIX type.)[\quote] But I also had modify the matrix's (bones) for my models. for example: right handed (rotate x): 1 0 0 0 0 cos -sin 0 0 sin cos 0 0 0 0 1 left handed (rotate x): 1 0 0 0 0 cos sin 0 0 -sin cos 0 0 0 0 1 So I simply grab all the matrices at render time and swap the "sin" values in the matrix. This works on some models but not all. There must be a better way to do this. My goal is to leave the application "thinking" it's right handed but at render time convert it to left handed. This way I only have to touch the the rendering portion of the code.

Share this post


Link to post
Share on other sites
You know, the "handedness" of your application mainly has to do with your view and projection matrices.

To continue to use the right-handed matrices that the engine already has, all you need to do is compute your view matrix using D3DXMatrixLookAtRH and compute your projection matrix using D3DXMatrixPerspectiveFovRH (or one of the other similar functions for creating a projection matrix).

neneboricua

Share this post


Link to post
Share on other sites
Quote:
Original post by wxb1
thanks... you've helped... It shows that there is more than one way to do this... unfortunately I don't want to use the d3dx functions...

That's totally up to you but may I ask why? If it's because you think that the D3DX functions are not very efficient, just try them out. I think you'll be surprised.

In any event, those D3DX functions I mentioned earlier don't do anything magical. They just set up the matrices. The math that each implements is even in the SDK docs. Just look up each function and see the math that it does. If you want to, you could just take the math from the docs and write your own versions of the functions.

neneboricua

Share this post


Link to post
Share on other sites
Quote:
Original post by neneboricua19
Quote:
Original post by wxb1
thanks... you've helped... It shows that there is more than one way to do this... unfortunately I don't want to use the d3dx functions...

That's totally up to you but may I ask why? If it's because you think that the D3DX functions are not very efficient, just try them out. I think you'll be surprised.

In any event, those D3DX functions I mentioned earlier don't do anything magical. They just set up the matrices. The math that each implements is even in the SDK docs. Just look up each function and see the math that it does. If you want to, you could just take the math from the docs and write your own versions of the functions.

neneboricua



Well I was hoping I could get at the source for some of these functions. But I don't think they come with dx7. I assume your talking about dx9 docs? I'll take a look those... There's nothing wrong with d3dx.... I simply want to do it myself and don't want to add d3dx functions now since there is no d3dx functions in my code now...

Share this post


Link to post
Share on other sites

This topic is 4709 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.

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