Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / render biped bones (D3D9) Account Manager
 
Anddos

September 23, 2012, 10:03 AM

what i am trying todo is render these bones as a point_list

Bip01_R_UpperArm 0
Bip01_Spine3 1
Bip01_Neck 2
Bip01_Spine2 3
Bip01_Spine1 4
Bip01_R_Clavicle 5
Bip01_Spine 6
Bip01_L_UpperArm 7
Bip01_L_Clavicle 8
Bip01_Pelvis 9
Bip01_R_Thigh 10
Bip01_L_Thigh 11
Bip01_R_Calf 12
Bip01_R_Foot 13
Bip01_R_Toe0 14
Bip01_L_Calf 15
Bip01_L_Foot 16
Bip01_L_Toe0 17
Bip01_L_Forearm 18
Bip01_L_Hand 19
Bip01_L_Finger1 20
Bip01_L_Finger11 21
Bip01_L_Finger0 22
Bip01_L_Finger01 23
Bip01_L_Finger02 24
Bip01_L_Finger12 25
Bip01_R_Forearm 26
Bip01_R_Hand 27
Bip01_R_Finger1 28
Bip01_R_Finger11 29
Bip01_R_Finger0 30
Bip01_R_Finger01 31
Bip01_R_Finger02 32
Bip01_R_Finger12 33
Bip01_Head 34

here is my update bone matrix function,

[code]
void update_mesh_containers(CUSTOM_FRAME* pFrame)
{
// cast the pFrame's mesh container pointer to a CUSTOM_MESHCONTAINER*
CUSTOM_MESHCONTAINER* pMeshContainer = (CUSTOM_MESHCONTAINER*)pFrame->pMeshContainer;

if(pMeshContainer && pMeshContainer->pSkinInfo)
{


UINT NumFrames = pMeshContainer->pSkinInfo->GetNumBones(); // find how many frames

sprintf_s(Buffer,"%s %dn","NumFrames",NumFrames);
//fputs(Buffer,d3dlog);

sprintf_s(Buffer,"%s %sn","*pMeshContainer->Name",*pMeshContainer->Name);
//fputs(Buffer,d3dlog);

// for each frame in the mesh container...
for(UINT i = 0; i < NumFrames; i++)
{
// set FinalMatrices to that frame's offset matrix
FinalMatrices = *pMeshContainer->pSkinInfo->GetBoneOffsetMatrix(i); sprintf_s(Buffer,"%s %dn",pMeshContainer->pSkinInfo->GetBoneName(i),i); fputs(Buffer,d3dlog); sprintf_s(Buffer,"%s %s %fn","before","FinalMatrices._11",FinalMatrices._11); // fputs(Buffer,d3dlog); //sprintf_s(Buffer,"%s %fn","FinalMatrices._11",FinalMatrices._11); //fputs(Buffer,d3dlog); //sprintf_s(Buffer,"%s %fn","FinalMatrices._12",FinalMatrices._12); //fputs(Buffer,d3dlog); // multiply that by the animated frame matrix FinalMatrices *= *pMeshContainer->ppFrameMatrices; sprintf_s(Buffer,"%s %s %fn","after","FinalMatrices._11",FinalMatrices._11); //fputs(Buffer,d3dlog); //matIdent = matIdent * FinalMatrices[0]; D3DXVec3TransformCoord(&Vec3ArrayDst,&Vec3ArraySrc,&(FinalMatrices[29]*matRotateY*matScale)); D3DXMatrixIdentity(&matIdent); matIdent._41 = Vec3ArrayDst.x; matIdent._42 = Vec3ArrayDst.y; matIdent._43 = Vec3ArrayDst.z; sprintf_s(Buffer,"%s %fn","Vec3ArrayDst.x",Vec3ArrayDst.x); //fputs(Buffer,d3dlog); } void* pSrc = NULL; // a void pointer for the original mesh void* pDst = NULL; // a void pointer for the modified mesh // lock the two meshes pMeshContainer->MeshData.pMesh->LockVertexBuffer(NULL, &pSrc); pMeshContainer->pFinalMesh->LockVertexBuffer(NULL, &pDst); // store the animated mesh into FinalMesh pMeshContainer->pSkinInfo->UpdateSkinnedMesh(FinalMatrices, NULL, pSrc, pDst); // unlock the two meshes pMeshContainer->pFinalMesh->UnlockVertexBuffer(); pMeshContainer->MeshData.pMesh->UnlockVertexBuffer(); } // run for all siblings if(pFrame->pFrameSibling) update_mesh_containers((CUSTOM_FRAME*)pFrame->pFrameSibling); // run for the first child (which will then run all other children) if(pFrame->pFrameFirstChild) update_mesh_containers((CUSTOM_FRAME*)pFrame->pFrameFirstChild); } [/code] here is the render bones function void init_graphics_runtime(D3DXVECTOR3 vec3Point) { // create the vertices using the CUSTOMVERTEX struct CUSTOMVERTEX vertices[] = { { vec3Point.x, vec3Point.y, vec3Point.z, D3DCOLOR_XRGB(0, 0, 255), }, //{ 0.0f, 3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), }, //{ -3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; // create a vertex buffer interface called v_buffer d3ddev->CreateVertexBuffer(1*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; // a void pointer // lock v_buffer and load the vertices into it v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); v_buffer->Unlock(); effect->SetMatrix("View", &matView); effect->SetMatrix("Projection", &matProjection); effect->SetMatrix("World", &matRotateY); d3ddev->SetFVF(CUSTOMFVF); // select the vertex buffer to display d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); effect->Begin(NULL, NULL); // begin using the effect effect->BeginPass(0); // begin the pass // copy the vertex buffer to the back buffer d3ddev->DrawPrimitive(D3DPT_POINTLIST, 0, 1); effect->EndPass(); // end the pass effect->End(); // end the effect }

 
This thread contains 1 message.
 

If you'd like to post a comment on this discussion thread, please log in or create an account.

 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.