2010-12-06 6 views
1

2つのメッシュがあります。そのうちの1つはアニメートされ、もう1つはアニメーション化されません。アニメーションメッシュがアニメーション化されているのと同じ方法で、無期限のメッシュがレンダリングされます。
アニメーションメッシュだけが戻ってくるよりも左に行くようにしてください。私の無生物メッシュは同じことをします!
これは、無生物のメッシュのコードクラスです。
メインクラスC++メッシュがアニメーション化されていると仮定しないとき

class StaticMesh 
{ 
public: 
    StaticMesh(LPDIRECT3DDEVICE9* device); 
    ~StaticMesh(void); 
    void Render(void); 
    void Load(LPCWSTR fileName); 
    void CleanUp(void); 
private: 
    LPDIRECT3DDEVICE9* d3ddev;      // the pointer to the device class 
    LPD3DXMESH mesh; // define the mesh pointer 
    D3DMATERIAL9* material; // define the material object 
    DWORD numMaterials; // stores the number of materials in the mesh 
    LPDIRECT3DTEXTURE9* texture; // a pointer to a texture 
    LPD3DXBUFFER bufMeshMaterial; 
}; 

#include "StdAfx.h" 
#include "StaticMesh.h" 


StaticMesh::StaticMesh(LPDIRECT3DDEVICE9* device) 
{ 
    d3ddev=device; 
} 


StaticMesh::~StaticMesh(void) 
{ 
} 

void StaticMesh::Render(void) 
{ 
    LPDIRECT3DDEVICE9 device=*d3ddev; 
    for(DWORD i = 0; i < numMaterials; i++) // loop through each subset 
    { 
     device->SetMaterial(&material[i]); // set the material for the subset 
     device->SetTexture(0, texture[i]); // ...then set the texture 

     mesh->DrawSubset(i); // draw the subset 
    } 
} 

void StaticMesh::Load(LPCWSTR fileName) 
{ 
    LPDIRECT3DDEVICE9 device=*d3ddev; 

    D3DXLoadMeshFromX(fileName, // load this file 
         D3DXMESH_SYSTEMMEM, // load the mesh into system memory 
         device, // the Direct3D Device 
         NULL, // we aren't using adjacency 
         &bufMeshMaterial, // put the materials here 
         NULL, // we aren't using effect instances 
         &numMaterials, // the number of materials in this model 
         &mesh); // put the mesh here 

    // retrieve the pointer to the buffer containing the material information 
    D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)bufMeshMaterial->GetBufferPointer(); 

    // create a new material buffer and texture for each material in the mesh 
    material = new D3DMATERIAL9[numMaterials]; 
    texture = new LPDIRECT3DTEXTURE9[numMaterials]; 

    for(DWORD i = 0; i < numMaterials; i++) // for each material... 
    { 
     // Copy the material 
     material[i] = tempMaterials[i].MatD3D; 

     // Set the ambient color for the material (D3DX does not do this) 
     material[i].Ambient = material[i].Diffuse; 

     // Create the texture if it exists - it may not 
     texture[i] = NULL; 
     if (tempMaterials[i].pTextureFilename) 
     { 
      D3DXCreateTextureFromFileA(device, tempMaterials[i].pTextureFilename,&texture[i]); 
     } 
    } 
} 

void StaticMesh::CleanUp(void) 
{ 
    mesh->Release(); 
} 
+1

は、あなたが与えてきたクラスの外に存在します。 StaticMeshオブジェクトに実行している操作のサンプルを含めることはできますか? – MrGomez

答えて

0

aninationは変換行列から来ています。 デバイスに直接渡すか(固定機能を使用する場合)、またはシェーダ/エフェクトに渡します。 行列が設定された後に描画するすべてのメッシュは、同じ変形を受けます。 メッシュを無人にしたい場合は、メッシュを描画する前にトランスフォームを変更する必要があります。

擬似コード:私はあなたの問題を感じている

SetTransform(world* view * projection); 
DrawMesh(); 
SetTransform(identity * view * projection); 
DrawMesh(); 
関連する問題