mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-18 06:03:48 +00:00
Just the functional assimp lib rather than the entire assimp repository unnecessarily.
This commit is contained in:
parent
0f7641a282
commit
e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions
|
|
@ -72,16 +72,18 @@ using namespace std;
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Default constructor
|
||||
MMDImporter::MMDImporter()
|
||||
: m_Buffer()
|
||||
, m_strAbsPath("") {
|
||||
DefaultIOSystem io;
|
||||
m_strAbsPath = io.getOsSeparator();
|
||||
: m_Buffer(),
|
||||
// m_pRootObject( NULL ),
|
||||
m_strAbsPath("") {
|
||||
DefaultIOSystem io;
|
||||
m_strAbsPath = io.getOsSeparator();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor.
|
||||
MMDImporter::~MMDImporter() {
|
||||
// empty
|
||||
// delete m_pRootObject;
|
||||
// m_pRootObject = NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -94,7 +96,8 @@ bool MMDImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler,
|
|||
} else // Check file Header
|
||||
{
|
||||
static const char *pTokens[] = {"PMX "};
|
||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens, 1);
|
||||
return BaseImporter::SearchFileHeaderForToken(pIOHandler, pFile, pTokens,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,6 +141,8 @@ void MMDImporter::CreateDataFromImport(const pmx::PmxModel *pModel,
|
|||
aiNode *pNode = new aiNode;
|
||||
if (!pModel->model_name.empty()) {
|
||||
pNode->mName.Set(pModel->model_name);
|
||||
} else {
|
||||
ai_assert(false);
|
||||
}
|
||||
|
||||
pScene->mRootNode = pNode;
|
||||
|
|
@ -165,7 +170,7 @@ void MMDImporter::CreateDataFromImport(const pmx::PmxModel *pModel,
|
|||
}
|
||||
|
||||
// create node hierarchy for bone position
|
||||
std::unique_ptr<aiNode *[]> ppNode(new aiNode *[pModel->bone_count]);
|
||||
aiNode **ppNode = new aiNode *[pModel->bone_count];
|
||||
for (auto i = 0; i < pModel->bone_count; i++) {
|
||||
ppNode[i] = new aiNode(pModel->bones[i].bone_name);
|
||||
}
|
||||
|
|
@ -174,9 +179,9 @@ void MMDImporter::CreateDataFromImport(const pmx::PmxModel *pModel,
|
|||
const pmx::PmxBone &bone = pModel->bones[i];
|
||||
|
||||
if (bone.parent_index < 0) {
|
||||
pScene->mRootNode->addChildren(1, ppNode.get() + i);
|
||||
pScene->mRootNode->addChildren(1, ppNode + i);
|
||||
} else {
|
||||
ppNode[bone.parent_index]->addChildren(1, ppNode.get() + i);
|
||||
ppNode[bone.parent_index]->addChildren(1, ppNode + i);
|
||||
|
||||
aiVector3D v3 = aiVector3D(
|
||||
bone.position[0] - pModel->bones[bone.parent_index].position[0],
|
||||
|
|
@ -214,7 +219,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
|
|||
pMesh->mNumFaces = indexCount / 3;
|
||||
pMesh->mFaces = new aiFace[pMesh->mNumFaces];
|
||||
|
||||
const int numIndices = 3; // triangular face
|
||||
const int numIndices = 3; // trianglular face
|
||||
for (unsigned int index = 0; index < pMesh->mNumFaces; index++) {
|
||||
pMesh->mFaces[index].mNumIndices = numIndices;
|
||||
unsigned int *indices = new unsigned int[numIndices];
|
||||
|
|
@ -321,10 +326,8 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
|
|||
auto it = bone_vertex_map.find(ii);
|
||||
if (it != bone_vertex_map.end()) {
|
||||
pBone->mNumWeights = static_cast<unsigned int>(it->second.size());
|
||||
pBone->mWeights = new aiVertexWeight[pBone->mNumWeights];
|
||||
for (unsigned int j = 0; j < pBone->mNumWeights; j++) {
|
||||
pBone->mWeights[j] = it->second[j];
|
||||
}
|
||||
pBone->mWeights = it->second.data();
|
||||
it->second.swap(*(new vector<aiVertexWeight>));
|
||||
}
|
||||
bone_ptr_ptr[ii] = pBone;
|
||||
}
|
||||
|
|
@ -351,11 +354,8 @@ aiMaterial *MMDImporter::CreateMaterial(const pmx::PmxMaterial *pMat,
|
|||
float shininess = pMat->specularlity;
|
||||
mat->AddProperty(&shininess, 1, AI_MATKEY_SHININESS_STRENGTH);
|
||||
|
||||
if(pMat->diffuse_texture_index >= 0) {
|
||||
aiString texture_path(pModel->textures[pMat->diffuse_texture_index]);
|
||||
mat->AddProperty(&texture_path, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));
|
||||
}
|
||||
|
||||
aiString texture_path(pModel->textures[pMat->diffuse_texture_index]);
|
||||
mat->AddProperty(&texture_path, AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0));
|
||||
int mapping_uvwsrc = 0;
|
||||
mat->AddProperty(&mapping_uvwsrc, 1,
|
||||
AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE, 0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue