convert a right-handed matrix to a left handed matrix

Started by
5 comments, last by wxb1 19 years, 3 months ago
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:
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.
Advertisement
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
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...
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
Fix = [4x4]:

1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1

LeftHanded = RightHanded * Fix
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...
Quote:Original post by Samurai Jack
Fix = [4x4]:

1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1

LeftHanded = RightHanded * Fix


O.k. I think I saw something on the net that says this too...

This topic is closed to new replies.

Advertisement