Jump to content
  • Advertisement
Sign in to follow this  
papi

[DX10] Mesh rotation

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

Hi im learing D3D10. To be easy i have split the game in some classes (like camera input model etc..) that all.
Now i have a problem, i made a parse that convert files (x3d blender) in my own format wich contains vertices, texture coords and texture (image) all in one rolleyes.gif. Problem? Must rotate that vectors, cuz blender's up axis is Z.

So i made this, but isnt working properly blink.gif
bool __stdcall RotateX_Vertex_clsA(std::vector<VERTEX_CLASS_A>& vecs, float r)
{
if(vecs.empty())
return false;

auto mul =[](D3DXVECTOR3& out,D3DXMATRIX& in)
{
out.x =
out.x * in._11 +
out.y * in._12 +
out.z * in._13;
out.y =
out.x * in._21 +
out.y * in._22 +
out.z * in._23 ;
out.z =
out.x * in._31 +
out.y * in._32 +
out.z * in._33 ;
};
D3DXMATRIX matRx;
D3DXMatrixIdentity(&matRx);
D3DXMatrixRotationX(&matRx,r);

std::for_each(vecs.begin(),vecs.end(),[&matRx,&mul](VERTEX_CLASS_A& clsa)
{
mul(clsa.pos,matRx);

});

return true;
}




dry.gif 300 line of code and i missed a temporary variable.
calc(x) = ok
calc(y) = fail.. cuz x is calculated
[spoiler]
[color=#1C2837][font=verdana, geneva, lucida,][color=#000088]auto[color=#000000] mul [color=#666600]=[]([color=#000000]D3DXVECTOR3[color=#666600]&[color=#000000] [color=#000088]out[color=#666600],[color=#000000]D3DXMATRIX[color=#666600]&[color=#000000] [color=#000088]in[color=#666600])[color=#000000]
[color=#666600]{[color=#000000]
[color=#000088]float[color=#000000] w [color=#666600]=[color=#000000] [color=#006666]1.0f[color=#666600];[color=#000000]
D3DXVECTOR3 tmp[color=#666600];[color=#000000]
tmp[color=#666600].[color=#000000]x [color=#666600]=[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]x [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_11 [color=#666600]+[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]y [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_12 [color=#666600]+[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]z [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_13 [color=#666600]+[color=#000000]
w [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_14[color=#666600];[color=#000000]
tmp[color=#666600].[color=#000000]y [color=#666600]=[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]x [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_21 [color=#666600]+[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]y [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_22 [color=#666600]+[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]z [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_23 [color=#666600]+[color=#000000]
w [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_24[color=#666600];[color=#000000]
tmp[color=#666600].[color=#000000]z [color=#666600]=[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]x [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_31 [color=#666600]+[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]y [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_32 [color=#666600]+[color=#000000]
[color=#000088]out[color=#666600].[color=#000000]z [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_33 [color=#666600]+[color=#000000]
w [color=#666600]*[color=#000000] [color=#000088]in[color=#666600].[color=#000000]_34[color=#666600];[color=#000000]
[color=#000088]out[color=#000000] [color=#666600]=[color=#000000] tmp[color=#666600];[color=#000000]
[color=#666600]};[/font]
[/spoiler] Edited by papi

Share this post


Link to post
Share on other sites
Advertisement
I'm a novice but currently learning matrix stuff. I think you need the SetTransform() function somewhere after every change (rotation, translation, scaling) for matirces.

Sometihng like

d3dDevice->SetTransform( D3DTS_WORLD, &(matRx) );

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!