void ModelShape::Draw(IGraphicsDevice *device, RenderState &state) { int animationFrame = mModel->GetCurrentAnimationFrame(); TMeshList &meshes = mModel->GetMeshes(); TBoneList &bones = mModel->GetBones(); for(int i = 0; i < meshes.size(); i++) { ModelMesh *mesh = meshes[i]; Material *material = mMeshMaterials[i]; ModelAnimationMaterialProperties *properties = dynamic_cast<ModelAnimationMaterialProperties *>(material->GetProperties()); if(properties) { int i = 0; for(int i = 0; i < bones.size(); i++) { ModelBone *bone = bones[i]; properties->SetBoneMatrix(i, bone->GetKeyframeTransform(animationFrame)); } ITexture *texture = mTextures[mesh->GetMaterial()]; properties->SetTexture(texture); } state.SetMaterial(material); ITechnique *technique = material->GetTechnique(0); technique->Begin(); while(technique->HasNextPass()) { technique->ProcessNextPass(device, state); mMeshVertexBuffers[i]->Activate(); device->Draw(PrimitiveTypeTriangleList, mesh->GetTotalFaces(), 0); } } }