# [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.

## 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 . Problem? Must rotate that vectors, cuz blender's up axis is Z.

So i made this, but isnt working properly
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; }

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 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) );

1. 1
2. 2
Rutin
23
3. 3
JoeJ
20
4. 4
5. 5

• 23
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631733
• Total Posts
3001928
×