Changes ObjectOffset parameter name to prevent confusion/conflict with the base class member AppMesh::objectOffset.

Error checking for meshes that do not have stored normals.
Incorrect first attempt at vertex weights.
This commit is contained in:
OTHGMars 2019-03-24 06:23:58 -04:00
parent 3da8c85e92
commit 4f7806fe8e
2 changed files with 21 additions and 21 deletions

View file

@ -59,7 +59,7 @@ MatrixF AssimpAppMesh::getMeshTransform(F32 time)
return appNode->getNodeTransform(time);
}
void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objectOffset)
void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
{
// After this function, the following are expected to be populated:
// points, normals, uvs, primitives, indices
@ -74,23 +74,21 @@ void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objectOffset)
{
// Points and Normals
aiVector3D pt = mMeshData->mVertices[i];
aiVector3D nrm = mMeshData->mNormals[i];
aiVector3D nrm;
if (mMeshData->HasNormals())
nrm = mMeshData->mNormals[i];
else
nrm.Set(0, 0, 0);
Point3F tmpVert;
Point3F tmpNormal;
if (Con::getBoolVariable("$Assimp::SwapYZ", false))
{
tmpVert = Point3F(pt.x, pt.z, pt.y);
tmpNormal = Point3F(nrm.x, nrm.z, nrm.y);
}
else
{
tmpVert = Point3F(pt.x, pt.y, pt.z);
tmpNormal = Point3F(nrm.x, nrm.y, nrm.z);
}
tmpVert = Point3F(pt.x, pt.y, pt.z);
tmpNormal = Point3F(nrm.x, nrm.y, nrm.z);
//AssimpAppNode::convertPoint(tmpVert);
//AssimpAppNode::convertPoint(tmpNormal);
//objectOffset.mulP(tmpVert);
//objOffset.mulP(tmpVert);
points.push_back(tmpVert);
@ -214,20 +212,22 @@ void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objectOffset)
String name = mMeshData->mBones[b]->mName.C_Str();
MatrixF boneTransform;
boneTransform.setRow(0, Point4F(mMeshData->mBones[b]->mOffsetMatrix.a1, mMeshData->mBones[b]->mOffsetMatrix.a2, mMeshData->mBones[b]->mOffsetMatrix.a3, mMeshData->mBones[b]->mOffsetMatrix.a4));
boneTransform.setRow(1, Point4F(mMeshData->mBones[b]->mOffsetMatrix.b1, mMeshData->mBones[b]->mOffsetMatrix.b2, mMeshData->mBones[b]->mOffsetMatrix.b3, mMeshData->mBones[b]->mOffsetMatrix.b4));
boneTransform.setRow(2, Point4F(mMeshData->mBones[b]->mOffsetMatrix.c1, mMeshData->mBones[b]->mOffsetMatrix.c2, mMeshData->mBones[b]->mOffsetMatrix.c3, mMeshData->mBones[b]->mOffsetMatrix.c4));
boneTransform.setRow(3, Point4F(mMeshData->mBones[b]->mOffsetMatrix.d1, mMeshData->mBones[b]->mOffsetMatrix.d2, mMeshData->mBones[b]->mOffsetMatrix.d3, mMeshData->mBones[b]->mOffsetMatrix.d4));
for (U32 m = 0; m < 16; ++m)
{
boneTransform[m] = *mMeshData->mBones[b]->mOffsetMatrix[m];
}
//initialTransforms.push_back(boneTransform);
initialTransforms.push_back(MatrixF::Identity);
//boneTransform.inverse();
//AssimpAppNode::convertMat(boneTransform); // Will need a better animated reference shape to determine if this is needed.
//boneTransform.inverse();
initialTransforms.push_back(boneTransform);
//Weights
U32 numWeights = mMeshData->mBones[b]->mNumWeights;
weight.setSize(numWeights);
vertexIndex.setSize(numWeights);
boneIndex.setSize(numWeights);
for (U32 w = 0; w < numWeights; ++w)
{

View file

@ -107,7 +107,7 @@ public:
///
/// @param time Time at which to generate the mesh data
/// @param objectOffset Transform to apply to the generated data (bounds transform)
void lockMesh(F32 time, const MatrixF& objectOffset);
void lockMesh(F32 time, const MatrixF& objOffset);
/// Get the transform of this mesh at a certain time
///