Jump to content
  • Advertisement
Sign in to follow this  
giugio

LHcoord and RHcoord coord collada

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

Hy. I'm created a collada importer , now i must apply the transformation of the node scene for the meshes in my file. I read about the directx is a RhCoord system , so i flip the triangles with this function:
for (pos =0;pos < CountIndexes/3 ;pos ++ )
{
   int swap = m_CurrMeshIndexes[pos * 3 + 1];
   m_CurrMeshIndexes[pos * 3 + 1] = m_CurrMeshIndexes[pos * 3 + 2];
   m_CurrMeshIndexes[pos * 3 + 2] = swap;

}


is sufficent to transform to a lhcoord? And the transform matrix that use is calculate with: dxMAtrix = dxTranslateParent *dxRotate * scale; is correct? and.. i read 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.
how i scale hte view matrix by -1? or flip the sign of 31 32 33 ecc..? THanks. [Edited by - giugio on January 10, 2009 1:16:22 PM]

Share this post


Link to post
Share on other sites
Advertisement
i do this:


D3DXVECTOR3 pos(0.0f, 0.f,5.0f);
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);

D3DXMATRIX V;
D3DXMatrixLookAtLH(
&V,
&pos,
&target,
&up);

D3DXMatrixScaling(&V,0,0,-1);

Device->SetTransform(D3DTS_VIEW, &V);
D3DXMATRIX dxMat;



is correct?
Thanks.

Share this post


Link to post
Share on other sites
D3DXMatrixLookAtLH, D3DXMatrixScaling will generate a new matrix, overriding the old one. To apply them both you would have to multiply them.

Share this post


Link to post
Share on other sites
Now i'm see nothing
i'm a little frustrated, this is the code , where i do the mistake?

D3DXVECTOR3 pos(0.0f, 0.f,5.0f);
D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);

D3DXMATRIX V;
D3DXMatrixLookAtLH(
&V,
&pos,
&target,
&up);


D3DXMATRIX V1;
D3DXMatrixIdentity(&V1);
D3DXMatrixScaling(&V1,0,0,-1);
V*=V1;
Device->SetTransform(D3DTS_VIEW, &V);
D3DXMATRIX dxMat;
/*D3DXMatrixIdentity(&dxMat);
D3DXMatrixScaling(&dxMat,1,1,-1);
Device->SetTransform(D3DTS_VIEW,&dxMat);*/


D3DXMATRIX proj;
D3DXMatrixPerspectiveLH(
&proj,
D3DX_PI * 0.5f, // 90 - degree
(float)Width / (float)Height,
1.0f,
10000.0f);
Device->SetTransform(D3DTS_PROJECTION, &proj);

thanks again

Share this post


Link to post
Share on other sites

D3DXMATRIX V;
D3DXMatrixLookAtLH(
&V,
&pos,
&target,
&up);


D3DXMATRIX V1,result;
D3DXMatrixScaling(&V1,0,0,-1);
D3DXMatrixMultiply(result,V,V1);
Device->SetTransform(D3DTS_VIEW, &result);
...





Not tested. Also note that D3DXMatrixLookAtLH will generate a left hand coordinate system so it is possible you can skip the scaling part...
And out of curiosity I'm starting to implement a Collada importer myself, so do you have a good description or source on how to do it other than the Specs?

Share this post


Link to post
Share on other sites
I read this :
http://msdn.microsoft.com/en-us/library/bb204853(VS.85).aspx
says that the order of the triangles must flipped(i do this)

and :
Quote:
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.


when i apply a scale to -1 to the view matrix i see nothing!

but the transform must do to the view or the world matrix?

And, is the same use D3DXMatrixMultiply or the * operator?
Thanks.

Share this post


Link to post
Share on other sites
Quote:

* 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.


As it says you also need to negate _34. Just flip the signs of the matrix components.

view._31=-view._31;
view._32=-view._32;
view._33=-view._33;
view._34=-view._34;


EDIT: scaling by -1 will also flip _34... Try disabling back-face culling and see if this helps.

Share this post


Link to post
Share on other sites
but this transformation must be apply at definition of the view (the camera)or always on each transform?
And how find the mesh in the word after this transform ? i don't see nothing!

and i not understand if is the same thing set the view matrix(that i presume is a d3dxmatrix but i can't find it)to a value or transform it with a matrix

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!