The 99% of the scenes have 1 mesh per node => for simplicity we only check the 1st one.
Also: the 3D models we are going to use for this demo, have flat structure (no hierarchy)
but just in case we need to replace them later, we calculate the transform by assuming that we
- have a node hierarchy. This => that each object's modelling transformation is the
+ have a node hierarchy. This => that each object's modelling transformation is the
product of its local transformation (mTransformation) with the acc parent nodes transformations
(parent_transform)
*/
}
mesh->name = std::string(amesh->mName.data);
- mesh->which_mask = 0;
for(unsigned int i=0; i<amesh->mNumVertices; ++i) {
/* vertices */
if(amesh->HasPositions()) {
- mesh->which_mask |= MESH_VERTEX;
Vec3 vertex = Vec3(amesh->mVertices[i].x, amesh->mVertices[i].y,
amesh->mVertices[i].z);
/* normals */
if(amesh->HasNormals()) {
- mesh->which_mask |= MESH_NORMAL;
Vec3 normal = Vec3(amesh->mNormals[i].x, amesh->mNormals[i].y,
amesh->mNormals[i].z);
mesh->normals.push_back(normal);
/* texture coordinates */
if(amesh->mTextureCoords[0]) {
- mesh->which_mask |= MESH_TEXTURE;
Vec2 tex_coord = Vec2(amesh->mTextureCoords[0][i].x, amesh->mTextureCoords[0][i].y);
mesh->tex_coords.push_back(tex_coord);
}
}
/* tangents */
- if(amesh->mTangents) {
- mesh->which_mask |= MESH_TANGENT;
- Vec3 tangent = Vec3(amesh->mTangents[i].x, amesh->mTangents[i].y,
- amesh->mTangents[i].z);
- mesh->tangents.push_back(tangent);
- }
- else {
- mesh->tangents.push_back(Vec3(1, 0, 0));
- }
+ // if(amesh->mTangents) {
+ // mesh->which_mask |= MESH_TANGENT;
+ // Vec3 tangent = Vec3(amesh->mTangents[i].x, amesh->mTangents[i].y,
+ // amesh->mTangents[i].z);
+ // mesh->tangents.push_back(tangent);
+ // }
+ // else {
+ // mesh->tangents.push_back(Vec3(1, 0, 0));
+ // }
}
/* indices (called faces in assimp) */
if(amesh->HasFaces()) {
- mesh->which_mask |= MESH_INDEX;
for(unsigned int i=0; i<amesh->mNumFaces; ++i) {
mesh->indices.push_back(amesh->mFaces[i].mIndices[0]);
mesh->indices.push_back(amesh->mFaces[i].mIndices[1]);