mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-24 21:07:46 +00:00
Export all 4 bone weights, normals and texture coordinates
This commit is contained in:
parent
19a138e114
commit
f20cb2179c
1 changed files with 12 additions and 6 deletions
|
@ -376,9 +376,14 @@ void MainWindow::exportModel(Model& model, Skeleton& skeleton, QString fileName)
|
||||||
auto mesh = scene.mMeshes[i];
|
auto mesh = scene.mMeshes[i];
|
||||||
mesh->mNumVertices = model.lods[0].parts[i].vertices.size();
|
mesh->mNumVertices = model.lods[0].parts[i].vertices.size();
|
||||||
mesh->mVertices = new aiVector3D [mesh->mNumVertices];
|
mesh->mVertices = new aiVector3D [mesh->mNumVertices];
|
||||||
|
mesh->mNormals = new aiVector3D [mesh->mNumVertices];
|
||||||
|
mesh->mTextureCoords[0] = new aiVector3D [mesh->mNumVertices];
|
||||||
|
mesh->mNumUVComponents[0] = 2;
|
||||||
for(int j = 0; j < mesh->mNumVertices; j++) {
|
for(int j = 0; j < mesh->mNumVertices; j++) {
|
||||||
auto vertex = model.lods[0].parts[i].vertices[j];
|
auto vertex = model.lods[0].parts[i].vertices[j];
|
||||||
mesh->mVertices[j] = aiVector3D(vertex.position[0], vertex.position[1], vertex.position[2]);
|
mesh->mVertices[j] = aiVector3D(vertex.position[0], vertex.position[1], vertex.position[2]);
|
||||||
|
mesh->mNormals[j] = aiVector3D (vertex.normal[0], vertex.normal[1], vertex.normal[2]);
|
||||||
|
mesh->mTextureCoords[0][j] = aiVector3D(vertex.uv[0], vertex.uv[1], 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh->mNumBones = model.affectedBoneNames.size();
|
mesh->mNumBones = model.affectedBoneNames.size();
|
||||||
|
@ -393,16 +398,17 @@ void MainWindow::exportModel(Model& model, Skeleton& skeleton, QString fileName)
|
||||||
|
|
||||||
mesh->mBones[j] = new aiBone();
|
mesh->mBones[j] = new aiBone();
|
||||||
mesh->mBones[j]->mName = model.affectedBoneNames[j];
|
mesh->mBones[j]->mName = model.affectedBoneNames[j];
|
||||||
mesh->mBones[j]->mNumWeights = mesh->mNumVertices;
|
mesh->mBones[j]->mNumWeights = mesh->mNumVertices * 4;
|
||||||
mesh->mBones[j]->mWeights = new aiVertexWeight[mesh->mBones[j]->mNumWeights];
|
mesh->mBones[j]->mWeights = new aiVertexWeight[mesh->mBones[j]->mNumWeights];
|
||||||
mesh->mBones[j]->mNode = skeleton_node->mChildren[j];
|
mesh->mBones[j]->mNode = skeleton_node->mChildren[j];
|
||||||
|
|
||||||
for(int k = 0; k < mesh->mNumVertices; k++) {
|
for(int k = 0; k < mesh->mNumVertices; k++) {
|
||||||
if(model.lods[0].parts[i].vertices[k].boneIds[0] == real_bone_id) {
|
for(int z = 0; z < 4; z++) {
|
||||||
auto& weight = mesh->mBones[j]->mWeights[k];
|
if (model.lods[0].parts[i].vertices[k].boneIds[z] == real_bone_id) {
|
||||||
|
auto &weight = mesh->mBones[j]->mWeights[k * 4 + z];
|
||||||
weight.mVertexId = k;
|
weight.mVertexId = k;
|
||||||
weight.mWeight =
|
weight.mWeight = model.lods[0].parts[i].vertices[k].boneWeights[z];
|
||||||
model.lods[0].parts[i].vertices[k].boneWeights[0];
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue