Sign in to follow this  

[DX10] Mesh rotation

This topic is 2299 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 [img]http://public.gamedev.net/public/style_emoticons/default/rolleyes.gif[/img]. Problem? Must rotate that vectors, cuz blender's up axis is Z.

So i made this, but isnt working properly [img]http://public.gamedev.net/public/style_emoticons/default/blink.gif[/img]
[code]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;
}[/code]



[img]http://public.gamedev.net/public/style_emoticons/default/dry.gif[/img] 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][color=#000000] mul [/color][color=#666600]=[]([/color][color=#000000]D3DXVECTOR3[/color][color=#666600]&[/color][color=#000000] [/color][color=#000088]out[/color][color=#666600],[/color][color=#000000]D3DXMATRIX[/color][color=#666600]&[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600])[/color][color=#000000]
[/color][color=#666600]{[/color][color=#000000]
[/color][color=#000088]float[/color][color=#000000] w [/color][color=#666600]=[/color][color=#000000] [/color][color=#006666]1.0f[/color][color=#666600];[/color][color=#000000]
D3DXVECTOR3 tmp[/color][color=#666600];[/color][color=#000000]
tmp[/color][color=#666600].[/color][color=#000000]x [/color][color=#666600]=[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]x [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_11 [/color][color=#666600]+[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]y [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_12 [/color][color=#666600]+[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]z [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_13 [/color][color=#666600]+[/color][color=#000000]
w [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_14[/color][color=#666600];[/color][color=#000000]
tmp[/color][color=#666600].[/color][color=#000000]y [/color][color=#666600]=[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]x [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_21 [/color][color=#666600]+[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]y [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_22 [/color][color=#666600]+[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]z [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_23 [/color][color=#666600]+[/color][color=#000000]
w [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_24[/color][color=#666600];[/color][color=#000000]
tmp[/color][color=#666600].[/color][color=#000000]z [/color][color=#666600]=[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]x [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_31 [/color][color=#666600]+[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]y [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_32 [/color][color=#666600]+[/color][color=#000000]
[/color][color=#000088]out[/color][color=#666600].[/color][color=#000000]z [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_33 [/color][color=#666600]+[/color][color=#000000]
w [/color][color=#666600]*[/color][color=#000000] [/color][color=#000088]in[/color][color=#666600].[/color][color=#000000]_34[/color][color=#666600];[/color][color=#000000]
[/color][color=#000088]out[/color][color=#000000] [/color][color=#666600]=[/color][color=#000000] tmp[/color][color=#666600];[/color][color=#000000]
[/color][color=#666600]};[/color][/font][/color]
[/spoiler] Edited by papi

Share this post


Link to post
Share on other sites
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

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