Как заставить меш двигаться в DirectX 10

Я пытаюсь создать летающего тигра в DirectX 10. Я загрузил тигра и крыло зацепилось, но я хочу, чтобы крылья закрылись. На данный момент я просто пытаюсь заставить крылья двигаться, а не сам тигр. Я новичок в DirectX, и я изучаю его как хобби, поэтому я не уверен, куда идти дальше.

Вот мой код:

void CALLBACK OnD3D10FrameRender(ID3D10Device* pd3dDevice, double fTime,
float fElapsedTime, void* pUserContext)
{
//
// Clear the back buffer
//
float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; // red, green, blue,
alpha
ID3D10RenderTargetView* pRTV = DXUTGetD3D10RenderTargetView();
pd3dDevice->ClearRenderTargetView(pRTV, ClearColor);

//
// Clear the depth stencil
//
ID3D10DepthStencilView* pDSV = DXUTGetD3D10DepthStencilView();
pd3dDevice->ClearDepthStencilView(pDSV, D3D10_CLEAR_DEPTH, 1.0, 0);

//
// Update variables that change once per frame
//
g_pWorldVariable->SetMatrix((float*)&g_World);

//
// Set the Vertex Layout
//
pd3dDevice->IASetInputLayout(g_pVertexLayout);

//
// Render the mesh
//
UINT Strides[1];
UINT Offsets[1];
ID3D10Buffer* pVB[1];
pVB[0] = g_Mesh.GetVB10(0, 0);
Strides[0] = (UINT)g_Mesh.GetVertexStride(0, 0);
Offsets[0] = 0;
pd3dDevice->IASetVertexBuffers(0, 1, pVB, Strides, Offsets);
pd3dDevice->IASetIndexBuffer(g_Mesh.GetIB10(0), g_Mesh.GetIBFormat10(0),
0);

D3D10_TECHNIQUE_DESC techDesc;
g_pTechnique->GetDesc(&techDesc);
SDKMESH_SUBSET* pSubset = NULL;
ID3D10ShaderResourceView* pDiffuseRV = NULL;
D3D10_PRIMITIVE_TOPOLOGY PrimType;

for (UINT p = 0; p < techDesc.Passes; ++p)
{
for (UINT subset = 0; subset < g_Mesh.GetNumSubsets(0); ++subset)
{
pSubset = g_Mesh.GetSubset(0, subset);

PrimType =
g_Mesh.GetPrimitiveType10((SDKMESH_PRIMITIVE_TYPE)pSubset-
>PrimitiveType);
pd3dDevice->IASetPrimitiveTopology(PrimType);

pDiffuseRV = g_Mesh.GetMaterial(pSubset->MaterialID)->pDiffuseRV10;
g_ptxDiffuseVariable->SetResource(pDiffuseRV);

g_pTechnique->GetPassByIndex(p)->Apply(0);
pd3dDevice->DrawIndexed((UINT)pSubset->IndexCount, 0, (UINT)pSubset-
>VertexStart);
}
}

// Render mesh2

pVB[0] = g_Mesh2.GetVB10(0, 0);
Strides[0] = (UINT)g_Mesh2.GetVertexStride(0, 0);
Offsets[0] = 0;
pd3dDevice->IASetVertexBuffers(0, 1, pVB, Strides, Offsets);
pd3dDevice->IASetIndexBuffer(g_Mesh2.GetIB10(0), g_Mesh2.GetIBFormat10(0),
0);

g_pTechnique->GetDesc(&techDesc);

for (UINT p = 0; p < techDesc.Passes; ++p)
{
for (UINT subset = 0; subset < g_Mesh2.GetNumSubsets(0); ++subset)
{
pSubset = g_Mesh2.GetSubset(0, subset);

PrimType =
g_Mesh2.GetPrimitiveType10((SDKMESH_PRIMITIVE_TYPE)pSubset-
>PrimitiveType);
pd3dDevice->IASetPrimitiveTopology(PrimType);

pDiffuseRV = g_Mesh2.GetMaterial(pSubset->MaterialID)->pDiffuseRV10;
g_ptxDiffuseVariable->SetResource(pDiffuseRV);

g_pTechnique->GetPassByIndex(p)->Apply(0);
pd3dDevice->DrawIndexed((UINT)pSubset->IndexCount, 0, (UINT)pSubset-
>VertexStart);
}
}

// Render Mesh3

pVB[0] = g_Mesh3.GetVB10(0, 0);
Strides[0] = (UINT)g_Mesh3.GetVertexStride(0, 0);
Offsets[0] = 0;
pd3dDevice->IASetVertexBuffers(0, 1, pVB, Strides, Offsets);
pd3dDevice->IASetIndexBuffer(g_Mesh3.GetIB10(0), g_Mesh3.GetIBFormat10(0),
0);

g_pTechnique->GetDesc(&techDesc);

for (UINT p = 0; p < techDesc.Passes; ++p)
{
for (UINT subset = 0; subset < g_Mesh3.GetNumSubsets(0); ++subset)
{
pSubset = g_Mesh3.GetSubset(0, subset);

PrimType =
g_Mesh3.GetPrimitiveType10((SDKMESH_PRIMITIVE_TYPE)pSubset-
>PrimitiveType);
pd3dDevice->IASetPrimitiveTopology(PrimType);

pDiffuseRV = g_Mesh3.GetMaterial(pSubset->MaterialID)->pDiffuseRV10;
g_ptxDiffuseVariable->SetResource(pDiffuseRV);

g_pTechnique->GetPassByIndex(p)->Apply(0);
pd3dDevice->DrawIndexed((UINT)pSubset->IndexCount, 0, (UINT)pSubset-
>VertexStart);
}
}

//the mesh class also had a render method that allows rendering the mesh
with the most common options
//g_Mesh.Render( pd3dDevice, g_pTechnique, g_ptxDiffuseVariable );
}

void CALLBACK OnD3D10ReleasingSwapChain(void* pUserContext)
{
}

void CALLBACK OnD3D10DestroyDevice(void* pUserContext)
{
DXUTGetGlobalResourceCache().OnDestroyDevice();
SAFE_RELEASE(g_pVertexLayout);
SAFE_RELEASE(g_pEffect);
g_Mesh.Destroy();
g_Mesh2.Destroy();
g_Mesh3.Destroy();
}bool CALLBACK ModifyDeviceSettings(DXUTDeviceSettings* pDeviceSettings,
void* pUserContext)
{
return true;
}void CALLBACK OnFrameMove(double fTime, float fElapsedTime, void*
pUserContext)
{
// Rotate cube around the origin
D3DXMatrixRotationY(&g_World, 60.0f * DEG2RAD((float)fTime));
}LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam,
bool* pbNoFurtherProcessing,
void* pUserContext)
{
return 0;
}

void CALLBACK OnKeyboard(UINT nChar, bool bKeyDown, bool bAltDown, void*
pUserContext)
{
if (bKeyDown)
{
switch (nChar)
{
case VK_F1: // Change as needed
break;
}
}
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector