Skip to main content
GameDev.net gamedev.net
🔒 Locked

SkinnedMesh Input-Rotation HELP!!!

Started by GENTS May 6, 2004 at 10:38 AM 0 replies 250+ views
Original Post
GENTS
GENTS
Hi friends! I''m an italian boy, so excuse me for grammatic errors!!! I need help! I want to move the famous "tiny" model in the space! I''m reading "Advanced Animation with DirectX" by Jim Adams so great part of my code is the same of book''s one. I don''t understand how modify model matrx so that when I press arrows on my keyboard my "Tiny" could rotate in the 3D world! I try with: 1. D3DXMatrixRotationX(&g_Frame->TransformationMatrix , d); D3DXMatrixRotationX(&g_Frame->TransformationMatrix , i); g_Frame->UpdateHierarchy(); 2. D3DXMatrixRotationX(&g_Frame->TransformationMatrix , d); g_Frame->UpdateHierarchy(); D3DXMatrixRotationX(&g_Frame->TransformationMatrix , i); g_Frame->UpdateHierarchy(); 3. g_Frame->TransformationMatrix *= RotX*RotY; g_Frame->UpdateHierarchy(); and in other ways, but I can only watch a lot of problems, such as: - I could see my model only when I press arrows - My model disappears So, now I need help!!! Which is the matrix I''ve to modify?! Is the TransormationMatrix?! Which is the right way to transform my model orientation when I press any key?! I put here my last code: ////////////////////////////////////////////////////// // // GAME RENDERING // ////////////////////////////////////////////////////// void Render() { static DWORD StartTime = timeGetTime(); DWORD ThisTime = timeGetTime(); D3DXMATRIX RotY, RotX; // Clear the frames'' transformation matrices if(g_Frame) g_Frame->Reset(); if( GetAsyncKeyState( VK_RIGHT ) ){ i = i-0.1f; D3DXMatrixRotationY(&RotY, i); } if( GetAsyncKeyState( VK_LEFT ) ){ i = i+0.1f; D3DXMatrixRotationY(&RotY, i); } if( GetAsyncKeyState( VK_DOWN ) ){ d = d-0.1f; D3DXMatrixRotationX(&RotX, d); } if( GetAsyncKeyState( VK_UP ) ){ d = d+0.1f; D3DXMatrixRotationX(&RotX, d); } int QuantoVeloce = (ThisTime-StartTime)*4; // Blend the animations if(g_BlendFlags[0]){ g_Anim.Blend("left_arm", QuantoVeloce, TRUE); } if(g_BlendFlags[1]){ g_Anim.Blend("right_arm", QuantoVeloce, TRUE); } if(g_BlendFlags[2]){ g_Anim.Blend("left_leg", QuantoVeloce, TRUE); } if(g_BlendFlags[3]){ g_Anim.Blend("right_leg", QuantoVeloce, TRUE); } if(g_BlendFlags[4]){ g_Anim.Blend("body", QuantoVeloce, TRUE); } // Rebuild the frame hierarchy transformations if(g_Frame){ g_Frame->TransformationMatrix = RotX*RotY; //<--- ?! g_Frame->UpdateHierarchy(); } // Build the skinned mesh UpdateMesh(g_Mesh); // Calculate a view transformation matrix D3DXMATRIX matView; D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3( 0, 200.0f, -1000), //posizione &D3DXVECTOR3(1.0f, 0.0f, 1.0f), //inclinazione &D3DXVECTOR3(0.0f, 1.0f, 1.0f)); //direzione g_pD3DDevice->SetTransform(D3DTS_VIEW, &matView); // Set a world transformation D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld); // Clear the device and start drawing the scene g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(0,0,0,255), 1.0f, 0); ..........................continue......................... Thanks a lot for help!!! Bye, ----------------------------------------------- - GENTS - "Every man dies, not every man really lives" [William Wallace]
GENTS
GENTS
OK! I''ve found how to solve a problema but I''ve just find another one!!!

When I move in two different directions as UP and RIGHT/LEFT or DOWN and RIGHT/LEFT and after that I want to use another time only one arrow (instead of two at the same time) my model don''t react in the right way but continue to have a certain inclination!!! How to solve this problem?!

This is the piec of code to seolve prevoius:

if( GetAsyncKeyState( VK_RIGHT ) ){
i = i-0.1f;
}

if( GetAsyncKeyState( VK_LEFT ) ){
i = i+0.1f;
}

if( GetAsyncKeyState( VK_DOWN ) ){
d = d-0.1f;
}

if( GetAsyncKeyState( VK_UP ) ){
d = d+0.1f;
}

int QuantoVeloce = (ThisTime-StartTime)*4;

// Blend the animations
if(g_BlendFlags[0]){
g_Anim.Blend("left_arm", QuantoVeloce, TRUE);
}
if(g_BlendFlags[1]){
g_Anim.Blend("right_arm", QuantoVeloce, TRUE);
}
if(g_BlendFlags[2]){
g_Anim.Blend("left_leg", QuantoVeloce, TRUE);
}
if(g_BlendFlags[3]){
g_Anim.Blend("right_leg", QuantoVeloce, TRUE);
}
if(g_BlendFlags[4]){
g_Anim.Blend("body", QuantoVeloce, TRUE);
}

// Rebuild the frame hierarchy transformations
if(g_Frame){
D3DXMatrixIdentity(&g_Frame->TransformationMatrix);
D3DXMatrixRotationX(&RotX, d);
g_Frame->TransformationMatrix *= RotX;
D3DXMatrixRotationY(&RotY, i);
g_Frame->TransformationMatrix *= RotY;
g_Frame->UpdateHierarchy(&g_Frame->TransformationMatrix);
}



THANKS TO EVERYBODY!!!

-----------------------------------------------
- GENTS -

"Every man dies, not every man really lives"
[William Wallace]


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.