|
|

楼主 |
发表于 2005-11-7 16:58:00
|
显示全部楼层
Re:问个基本的问题,渲染函数的问题
恩,有道理,
主要我最近看Advanced Animation with DirectX那本书,里面的关键帧函数有点半懂不懂的
void DoFrame()
{
static DWORD StartTime = timeGetTime();
DWORD ThisTime = timeGetTime();
// Update the animation (convert to 30 fps)
g_Anim.Update(NULL, (ThisTime-StartTime)*3, TRUE);
// Rebuild the frame hierarchy transformations
if(g_Frame)
g_Frame->UpdateHierarchy();
// Build the skinned mesh
UpdateMesh(g_Mesh);
// Calculate a view transformation matrix
// Using the mesh's bounding radius to position the viewer
float Distance = g_MeshRadius * 3.0f;
float Angle = (float)timeGetTime() / 2000.0f;
D3DXMATRIX matView;
D3DXMatrixLookAtLH(&matView,
&D3DXVECTOR3((float)cos(Angle) * Distance, g_MeshRadius, (float)sin(Angle) * Distance),
&D3DXVECTOR3(0.0f, 0.0f, 0.0f),
&D3DXVECTOR3(0.0f, 1.0f, 0.0f));
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(NULL, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(0,0,64,255), 1.0f, 0);
if(SUCCEEDED(g_pD3DDevice->BeginScene())) {
// Render skinned mesh
DrawMesh(g_Mesh);
// End the scene
g_pD3DDevice->EndScene();
}
// Present the scene to the user
g_pD3DDevice-> resent(NULL, NULL, NULL, NULL);
}
|
|