-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkinnedModel.cpp
More file actions
executable file
·40 lines (31 loc) · 1.16 KB
/
SkinnedModel.cpp
File metadata and controls
executable file
·40 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "SkinnedModel.h"
#include "LoadM3d.h"
SkinnedModel::SkinnedModel(ID3D11Device* device, TextureMgr& texMgr, const std::string& modelFilename, const std::wstring& texturePath)
{
std::vector<M3dMaterial> mats;
LoadM3der m3dLoader;
m3dLoader.LoadM3d(modelFilename, Vertices, Indices, Subsets, mats, SkinnedData);
ModelMesh.SetVertices(device, &Vertices[0], Vertices.size());
ModelMesh.SetIndices(device, &Indices[0], Indices.size());
ModelMesh.SetSubsetTable(Subsets);
SubsetCount = mats.size();
for(UINT i = 0; i < SubsetCount; ++i)
{
Mat.push_back(mats[i].Mat);
ID3D11ShaderResourceView* diffuseMapSRV = texMgr.CreateTexture(texturePath + mats[i].DiffuseMapName);
DiffuseMapSRV.push_back(diffuseMapSRV);
ID3D11ShaderResourceView* normalMapSRV = texMgr.CreateTexture(texturePath + mats[i].NormalMapName);
NormalMapSRV.push_back(normalMapSRV);
}
}
SkinnedModel::~SkinnedModel()
{
}
void SkinnedModelInstance::Update(float dt)
{
TimePos += dt;
Model->SkinnedData.GetFinalTransform(ClipName, TimePos, FinalTransforms);
// Loop animation
if(TimePos > Model->SkinnedData.GetClipEndTime(ClipName))
TimePos = 0.0f;
}