mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-06 05:50:31 +00:00
Rename all member variables to follow the style guidelines (prefixed with the 'm') - class AppMesh
This commit is contained in:
parent
cf3eb26e6f
commit
aefa796056
5 changed files with 181 additions and 181 deletions
|
|
@ -319,17 +319,17 @@ public:
|
|||
ColladaAppMesh::ColladaAppMesh(const domInstance_geometry* instance, ColladaAppNode* node)
|
||||
: instanceGeom(instance), instanceCtrl(0), appNode(node), geomExt(0)
|
||||
{
|
||||
flags = 0;
|
||||
numFrames = 0;
|
||||
numMatFrames = 0;
|
||||
mFlags = 0;
|
||||
mNumFrames = 0;
|
||||
mNumMatFrames = 0;
|
||||
}
|
||||
|
||||
ColladaAppMesh::ColladaAppMesh(const domInstance_controller* instance, ColladaAppNode* node)
|
||||
: instanceGeom(0), instanceCtrl(instance), appNode(node), geomExt(0)
|
||||
{
|
||||
flags = 0;
|
||||
numFrames = 0;
|
||||
numMatFrames = 0;
|
||||
mFlags = 0;
|
||||
mNumFrames = 0;
|
||||
mNumMatFrames = 0;
|
||||
}
|
||||
|
||||
const char* ColladaAppMesh::getName(bool allowFixed)
|
||||
|
|
@ -367,8 +367,8 @@ bool ColladaAppMesh::animatesMatFrame(const AppSequence* appSeq)
|
|||
// - by animating the morph weights for morph targets with different UVs
|
||||
|
||||
// Check if the MAYA profile texture transform is animated
|
||||
for (S32 iMat = 0; iMat < appMaterials.size(); iMat++) {
|
||||
ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(appMaterials[iMat]);
|
||||
for (S32 iMat = 0; iMat < mAppMaterials.size(); iMat++) {
|
||||
ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[iMat]);
|
||||
if (appMat->effectExt &&
|
||||
appMat->effectExt->animatesTextureTransform(appSeq->getStart(), appSeq->getEnd()))
|
||||
return true;
|
||||
|
|
@ -446,17 +446,17 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
|
|||
|
||||
// Find the index of the bound material in the shape global list
|
||||
const domMaterial* mat = daeSafeCast<domMaterial>(matArray[iBind]->getTarget().getElement());
|
||||
for (matIndex = 0; matIndex < appMaterials.size(); matIndex++) {
|
||||
if (static_cast<ColladaAppMaterial*>(appMaterials[matIndex])->mat == mat)
|
||||
for (matIndex = 0; matIndex < mAppMaterials.size(); matIndex++) {
|
||||
if (static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex])->mat == mat)
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if this material needs to be added to the shape global list
|
||||
if (matIndex == appMaterials.size()) {
|
||||
if (matIndex == mAppMaterials.size()) {
|
||||
if (mat)
|
||||
appMaterials.push_back(new ColladaAppMaterial(mat));
|
||||
mAppMaterials.push_back(new ColladaAppMaterial(mat));
|
||||
else
|
||||
appMaterials.push_back(new ColladaAppMaterial(symbol));
|
||||
mAppMaterials.push_back(new ColladaAppMaterial(symbol));
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -466,7 +466,7 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
|
|||
else
|
||||
{
|
||||
// No Collada material is present for this symbol, so just create an empty one
|
||||
appMaterials.push_back(new ColladaAppMaterial(symbol));
|
||||
mAppMaterials.push_back(new ColladaAppMaterial(symbol));
|
||||
}
|
||||
|
||||
// Add this symbol to the bound list for the mesh
|
||||
|
|
@ -477,7 +477,7 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
|
|||
void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
||||
{
|
||||
// Only do this once
|
||||
if (primitives.size())
|
||||
if (mPrimitives.size())
|
||||
return;
|
||||
|
||||
// Read the <geometry> extension
|
||||
|
|
@ -517,16 +517,16 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
|||
continue;
|
||||
|
||||
// Create TSMesh primitive
|
||||
primitives.increment();
|
||||
TSDrawPrimitive& primitive = primitives.last();
|
||||
primitive.start = indices.size();
|
||||
mPrimitives.increment();
|
||||
TSDrawPrimitive& primitive = mPrimitives.last();
|
||||
primitive.start = mIndices.size();
|
||||
primitive.matIndex = (TSDrawPrimitive::Triangles | TSDrawPrimitive::Indexed) |
|
||||
addMaterial(meshPrims[iPrim]->getMaterial());
|
||||
|
||||
// Get the AppMaterial associated with this primitive
|
||||
ColladaAppMaterial* appMat = 0;
|
||||
if (!(primitive.matIndex & TSDrawPrimitive::NoMaterial))
|
||||
appMat = static_cast<ColladaAppMaterial*>(appMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
|
||||
appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
|
||||
|
||||
// Force the material to be double-sided if this geometry is double-sided.
|
||||
if (geomExt->double_sided && appMat && appMat->effectExt)
|
||||
|
|
@ -534,8 +534,8 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
|||
|
||||
// Pre-allocate triangle indices
|
||||
primitive.numElements = numTriangles * 3;
|
||||
indices.setSize(indices.size() + primitive.numElements);
|
||||
U32* dstIndex = indices.end() - primitive.numElements;
|
||||
mIndices.setSize(mIndices.size() + primitive.numElements);
|
||||
U32* dstIndex = mIndices.end() - primitive.numElements;
|
||||
|
||||
// Determine the offset for each element type in the stream, and also the
|
||||
// maximum input offset, which will be the number of indices per vertex we
|
||||
|
|
@ -569,12 +569,12 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
|||
daeErrorHandler::get()->handleWarning(avar("Splitting primitive "
|
||||
"in %s: too many verts for 16-bit indices.", _GetNameOrId(geometry)));
|
||||
|
||||
primitives.last().numElements -= indicesRemaining;
|
||||
primitives.push_back(TSDrawPrimitive(primitives.last()));
|
||||
mPrimitives.last().numElements -= indicesRemaining;
|
||||
mPrimitives.push_back(TSDrawPrimitive(mPrimitives.last()));
|
||||
}
|
||||
|
||||
primitives.last().numElements = indicesRemaining;
|
||||
primitives.last().start = indices.size() - indicesRemaining;
|
||||
mPrimitives.last().numElements = indicesRemaining;
|
||||
mPrimitives.last().start = mIndices.size() - indicesRemaining;
|
||||
|
||||
tupleMap.clear();
|
||||
}
|
||||
|
|
@ -631,7 +631,7 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
|
|||
Vector<Point2F>& v_uv2s,
|
||||
bool appendValues)
|
||||
{
|
||||
if (!primitives.size())
|
||||
if (!mPrimitives.size())
|
||||
return;
|
||||
|
||||
MeshStreams streams;
|
||||
|
|
@ -676,7 +676,7 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
|
|||
streams.readInputs(meshPrims[tuple.prim]->getInputs());
|
||||
S32 matIndex = addMaterial(meshPrims[tuple.prim]->getMaterial());
|
||||
if (matIndex != TSDrawPrimitive::NoMaterial)
|
||||
appMat = static_cast<ColladaAppMaterial*>(appMaterials[matIndex]);
|
||||
appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex]);
|
||||
else
|
||||
appMat = 0;
|
||||
|
||||
|
|
@ -923,10 +923,10 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objectOffset)
|
|||
// Now get the vertex data at the specified time
|
||||
if (geometry->getElementType() == COLLADA_TYPE::GEOMETRY) {
|
||||
getPrimitives(daeSafeCast<domGeometry>(geometry));
|
||||
getVertexData(daeSafeCast<domGeometry>(geometry), t, objectOffset, points, normals, colors, uvs, uv2s, true);
|
||||
getVertexData(daeSafeCast<domGeometry>(geometry), t, objectOffset, mPoints, mNormals, mColors, mUVs, mUV2s, true);
|
||||
}
|
||||
else if (geometry->getElementType() == COLLADA_TYPE::MORPH) {
|
||||
getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objectOffset, points, normals, colors, uvs, uv2s);
|
||||
getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objectOffset, mPoints, mNormals, mColors, mUVs, mUV2s);
|
||||
}
|
||||
else {
|
||||
daeErrorHandler::get()->handleWarning(avar("Unsupported geometry type "
|
||||
|
|
@ -937,7 +937,7 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objectOffset)
|
|||
void ColladaAppMesh::lookupSkinData()
|
||||
{
|
||||
// Only lookup skin data once
|
||||
if (!isSkin() || weight.size())
|
||||
if (!isSkin() || mWeight.size())
|
||||
return;
|
||||
|
||||
// Get the skin and vertex weight data
|
||||
|
|
@ -950,7 +950,7 @@ void ColladaAppMesh::lookupSkinData()
|
|||
streams.readInputs(skin->getJoints()->getInput_array());
|
||||
streams.readInputs(weightIndices.getInput_array());
|
||||
|
||||
MatrixF invObjOffset(objectOffset);
|
||||
MatrixF invObjOffset(mObjectOffset);
|
||||
invObjOffset.inverse();
|
||||
|
||||
// Get the bind shape matrix
|
||||
|
|
@ -971,7 +971,7 @@ void ColladaAppMesh::lookupSkinData()
|
|||
|
||||
// Set vertex weights
|
||||
bool tooManyWeightsWarning = false;
|
||||
for (S32 iVert = 0; iVert < vertsPerFrame; iVert++) {
|
||||
for (S32 iVert = 0; iVert < mVertsPerFrame; iVert++) {
|
||||
const domUint* vcount = (domUint*)weights_vcount.getRaw(0);
|
||||
const domInt* vindices = (domInt*)weights_v.getRaw(0);
|
||||
vindices += vindicesOffset[vertTuples[iVert].vertex];
|
||||
|
|
@ -1002,25 +1002,25 @@ void ColladaAppMesh::lookupSkinData()
|
|||
}
|
||||
|
||||
// Too many weights => find and replace the smallest one
|
||||
S32 minIndex = weight.size() - TSSkinMesh::BatchData::maxBonePerVert;
|
||||
F32 minWeight = weight[minIndex];
|
||||
for (S32 i = minIndex + 1; i < weight.size(); i++)
|
||||
S32 minIndex = mWeight.size() - TSSkinMesh::BatchData::maxBonePerVert;
|
||||
F32 minWeight = mWeight[minIndex];
|
||||
for (S32 i = minIndex + 1; i < mWeight.size(); i++)
|
||||
{
|
||||
if (weight[i] < minWeight)
|
||||
if (mWeight[i] < minWeight)
|
||||
{
|
||||
minWeight = weight[i];
|
||||
minWeight = mWeight[i];
|
||||
minIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
boneIndex[minIndex] = bIndex;
|
||||
weight[minIndex] = bWeight;
|
||||
mBoneIndex[minIndex] = bIndex;
|
||||
mWeight[minIndex] = bWeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertexIndex.push_back( iVert );
|
||||
boneIndex.push_back( bIndex );
|
||||
weight.push_back( bWeight );
|
||||
mVertexIndex.push_back( iVert );
|
||||
mBoneIndex.push_back( bIndex );
|
||||
mWeight.push_back( bWeight );
|
||||
nonZeroWeightCount++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1028,26 +1028,26 @@ void ColladaAppMesh::lookupSkinData()
|
|||
|
||||
// Normalize vertex weights (force weights for each vert to sum to 1)
|
||||
S32 iWeight = 0;
|
||||
while (iWeight < weight.size()) {
|
||||
while (iWeight < mWeight.size()) {
|
||||
// Find the last weight with the same vertex number, and sum all weights for
|
||||
// that vertex
|
||||
F32 invTotalWeight = 0;
|
||||
S32 iLast;
|
||||
for (iLast = iWeight; iLast < weight.size(); iLast++) {
|
||||
if (vertexIndex[iLast] != vertexIndex[iWeight])
|
||||
for (iLast = iWeight; iLast < mWeight.size(); iLast++) {
|
||||
if (mVertexIndex[iLast] != mVertexIndex[iWeight])
|
||||
break;
|
||||
invTotalWeight += weight[iLast];
|
||||
invTotalWeight += mWeight[iLast];
|
||||
}
|
||||
|
||||
// Then normalize the vertex weights
|
||||
invTotalWeight = 1.0f / invTotalWeight;
|
||||
for (; iWeight < iLast; iWeight++)
|
||||
weight[iWeight] *= invTotalWeight;
|
||||
mWeight[iWeight] *= invTotalWeight;
|
||||
}
|
||||
|
||||
// Add dummy AppNodes to allow Collada joints to be mapped to 3space nodes
|
||||
bones.setSize(streams.joints.size());
|
||||
initialTransforms.setSize(streams.joints.size());
|
||||
mBones.setSize(streams.joints.size());
|
||||
mInitialTransforms.setSize(streams.joints.size());
|
||||
for (S32 iJoint = 0; iJoint < streams.joints.size(); iJoint++)
|
||||
{
|
||||
const char* jointName = streams.joints.getStringValue(iJoint);
|
||||
|
|
@ -1075,9 +1075,9 @@ void ColladaAppMesh::lookupSkinData()
|
|||
"defaulting to instance_controller parent node '%s'", jointName, appNode->getName()));
|
||||
joint = appNode->getDomNode();
|
||||
}
|
||||
bones[iJoint] = new ColladaAppNode(joint);
|
||||
mBones[iJoint] = new ColladaAppNode(joint);
|
||||
|
||||
initialTransforms[iJoint] = objectOffset;
|
||||
mInitialTransforms[iJoint] = mObjectOffset;
|
||||
|
||||
// Bone scaling is generally ignored during import, since 3space only
|
||||
// stores default node transform and rotation. Compensate for this by
|
||||
|
|
@ -1089,16 +1089,16 @@ void ColladaAppMesh::lookupSkinData()
|
|||
invScale.x = invScale.x ? (1.0f / invScale.x) : 0;
|
||||
invScale.y = invScale.y ? (1.0f / invScale.y) : 0;
|
||||
invScale.z = invScale.z ? (1.0f / invScale.z) : 0;
|
||||
initialTransforms[iJoint].scale(invScale);
|
||||
mInitialTransforms[iJoint].scale(invScale);
|
||||
}
|
||||
|
||||
// Inverted node coordinate spaces (negative scale factor) are corrected
|
||||
// in ColladaAppNode::getNodeTransform, so need to apply the same operation
|
||||
// here to match
|
||||
if (m_matF_determinant(invBind) < 0.0f)
|
||||
initialTransforms[iJoint].scale(Point3F(1, 1, -1));
|
||||
mInitialTransforms[iJoint].scale(Point3F(1, 1, -1));
|
||||
|
||||
initialTransforms[iJoint].mul(invBind);
|
||||
initialTransforms[iJoint].mul(bindShapeMatrix);
|
||||
mInitialTransforms[iJoint].mul(invBind);
|
||||
mInitialTransforms[iJoint].mul(bindShapeMatrix);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,9 +458,9 @@ void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
|
|||
|
||||
// First see what materials we need to update
|
||||
PersistenceManager persistMgr;
|
||||
for ( U32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++ )
|
||||
for ( U32 iMat = 0; iMat < AppMesh::mAppMaterials.size(); iMat++ )
|
||||
{
|
||||
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::appMaterials[iMat] );
|
||||
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::mAppMaterials[iMat] );
|
||||
if ( mat )
|
||||
{
|
||||
Material *mappedMat;
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@
|
|||
#include "ts/loader/appMesh.h"
|
||||
#include "ts/loader/tsShapeLoader.h"
|
||||
|
||||
Vector<AppMaterial*> AppMesh::appMaterials;
|
||||
Vector<AppMaterial*> AppMesh::mAppMaterials;
|
||||
|
||||
AppMesh::AppMesh()
|
||||
: flags(0), numFrames(0), numMatFrames(0), vertsPerFrame(0)
|
||||
: mFlags(0), mNumFrames(0), mNumMatFrames(0), mVertsPerFrame(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -44,43 +44,43 @@ void AppMesh::computeBounds(Box3F& bounds)
|
|||
|
||||
// Setup bone transforms
|
||||
Vector<MatrixF> boneTransforms;
|
||||
boneTransforms.setSize( nodeIndex.size() );
|
||||
boneTransforms.setSize( mNodeIndex.size() );
|
||||
for (S32 iBone = 0; iBone < boneTransforms.size(); iBone++)
|
||||
{
|
||||
MatrixF nodeMat = bones[iBone]->getNodeTransform( TSShapeLoader::DefaultTime );
|
||||
MatrixF nodeMat = mBones[iBone]->getNodeTransform( TSShapeLoader::DefaultTime );
|
||||
TSShapeLoader::zapScale(nodeMat);
|
||||
boneTransforms[iBone].mul( nodeMat, initialTransforms[iBone] );
|
||||
boneTransforms[iBone].mul( nodeMat, mInitialTransforms[iBone] );
|
||||
}
|
||||
|
||||
// Multiply verts by weighted bone transforms
|
||||
for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
|
||||
points[iVert].set( Point3F::Zero );
|
||||
for (S32 iVert = 0; iVert < mInitialVerts.size(); iVert++)
|
||||
mPoints[iVert].set( Point3F::Zero );
|
||||
|
||||
for (S32 iWeight = 0; iWeight < vertexIndex.size(); iWeight++)
|
||||
for (S32 iWeight = 0; iWeight < mVertexIndex.size(); iWeight++)
|
||||
{
|
||||
const S32& vertIndex = vertexIndex[iWeight];
|
||||
const MatrixF& deltaTransform = boneTransforms[ boneIndex[iWeight] ];
|
||||
const S32& vertIndex = mVertexIndex[iWeight];
|
||||
const MatrixF& deltaTransform = boneTransforms[ mBoneIndex[iWeight] ];
|
||||
|
||||
Point3F v;
|
||||
deltaTransform.mulP( initialVerts[vertIndex], &v );
|
||||
v *= weight[iWeight];
|
||||
deltaTransform.mulP( mInitialVerts[vertIndex], &v );
|
||||
v *= mWeight[iWeight];
|
||||
|
||||
points[vertIndex] += v;
|
||||
mPoints[vertIndex] += v;
|
||||
}
|
||||
|
||||
// compute bounds for the skinned mesh
|
||||
for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
|
||||
bounds.extend( points[iVert] );
|
||||
for (S32 iVert = 0; iVert < mInitialVerts.size(); iVert++)
|
||||
bounds.extend( mPoints[iVert] );
|
||||
}
|
||||
else
|
||||
{
|
||||
MatrixF transform = getMeshTransform(TSShapeLoader::DefaultTime);
|
||||
TSShapeLoader::zapScale(transform);
|
||||
|
||||
for (S32 iVert = 0; iVert < points.size(); iVert++)
|
||||
for (S32 iVert = 0; iVert < mPoints.size(); iVert++)
|
||||
{
|
||||
Point3F p;
|
||||
transform.mulP(points[iVert], &p);
|
||||
transform.mulP(mPoints[iVert], &p);
|
||||
bounds.extend(p);
|
||||
}
|
||||
}
|
||||
|
|
@ -89,39 +89,39 @@ void AppMesh::computeBounds(Box3F& bounds)
|
|||
void AppMesh::computeNormals()
|
||||
{
|
||||
// Clear normals
|
||||
normals.setSize( points.size() );
|
||||
for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
|
||||
normals[iNorm] = Point3F::Zero;
|
||||
mNormals.setSize( mPoints.size() );
|
||||
for (S32 iNorm = 0; iNorm < mNormals.size(); iNorm++)
|
||||
mNormals[iNorm] = Point3F::Zero;
|
||||
|
||||
// Sum triangle normals for each vertex
|
||||
for (S32 iPrim = 0; iPrim < primitives.size(); iPrim++)
|
||||
for (S32 iPrim = 0; iPrim < mPrimitives.size(); iPrim++)
|
||||
{
|
||||
const TSDrawPrimitive& prim = primitives[iPrim];
|
||||
const TSDrawPrimitive& prim = mPrimitives[iPrim];
|
||||
|
||||
for (S32 iInd = 0; iInd < prim.numElements; iInd += 3)
|
||||
{
|
||||
// Compute the normal for this triangle
|
||||
S32 idx0 = indices[prim.start + iInd + 0];
|
||||
S32 idx1 = indices[prim.start + iInd + 1];
|
||||
S32 idx2 = indices[prim.start + iInd + 2];
|
||||
S32 idx0 = mIndices[prim.start + iInd + 0];
|
||||
S32 idx1 = mIndices[prim.start + iInd + 1];
|
||||
S32 idx2 = mIndices[prim.start + iInd + 2];
|
||||
|
||||
const Point3F& v0 = points[idx0];
|
||||
const Point3F& v1 = points[idx1];
|
||||
const Point3F& v2 = points[idx2];
|
||||
const Point3F& v0 = mPoints[idx0];
|
||||
const Point3F& v1 = mPoints[idx1];
|
||||
const Point3F& v2 = mPoints[idx2];
|
||||
|
||||
Point3F n;
|
||||
mCross(v2 - v0, v1 - v0, &n);
|
||||
n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect)
|
||||
|
||||
normals[idx0] += n;
|
||||
normals[idx1] += n;
|
||||
normals[idx2] += n;
|
||||
mNormals[idx0] += n;
|
||||
mNormals[idx1] += n;
|
||||
mNormals[idx2] += n;
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize the vertex normals (this takes care of averaging the triangle normals)
|
||||
for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
|
||||
normals[iNorm].normalize();
|
||||
for (S32 iNorm = 0; iNorm < mNormals.size(); iNorm++)
|
||||
mNormals[iNorm].normalize();
|
||||
}
|
||||
|
||||
TSMesh* AppMesh::constructTSMesh()
|
||||
|
|
@ -133,13 +133,13 @@ TSMesh* AppMesh::constructTSMesh()
|
|||
tsmesh = tsskin;
|
||||
|
||||
// Copy skin elements
|
||||
tsskin->weight = weight;
|
||||
tsskin->boneIndex = boneIndex;
|
||||
tsskin->vertexIndex = vertexIndex;
|
||||
tsskin->batchData.nodeIndex = nodeIndex;
|
||||
tsskin->batchData.initialTransforms = initialTransforms;
|
||||
tsskin->batchData.initialVerts = initialVerts;
|
||||
tsskin->batchData.initialNorms = initialNorms;
|
||||
tsskin->weight = mWeight;
|
||||
tsskin->boneIndex = mBoneIndex;
|
||||
tsskin->vertexIndex = mVertexIndex;
|
||||
tsskin->batchData.nodeIndex = mNodeIndex;
|
||||
tsskin->batchData.initialTransforms = mInitialTransforms;
|
||||
tsskin->batchData.initialVerts = mInitialVerts;
|
||||
tsskin->batchData.initialNorms = mInitialNorms;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -147,20 +147,20 @@ TSMesh* AppMesh::constructTSMesh()
|
|||
}
|
||||
|
||||
// Copy mesh elements
|
||||
tsmesh->verts = points;
|
||||
tsmesh->norms = normals;
|
||||
tsmesh->tverts = uvs;
|
||||
tsmesh->primitives = primitives;
|
||||
tsmesh->indices = indices;
|
||||
tsmesh->colors = colors;
|
||||
tsmesh->tverts2 = uv2s;
|
||||
tsmesh->verts = mPoints;
|
||||
tsmesh->norms = mNormals;
|
||||
tsmesh->tverts = mUVs;
|
||||
tsmesh->primitives = mPrimitives;
|
||||
tsmesh->indices = mIndices;
|
||||
tsmesh->colors = mColors;
|
||||
tsmesh->tverts2 = mUV2s;
|
||||
|
||||
// Finish initializing the shape
|
||||
tsmesh->setFlags(flags);
|
||||
tsmesh->setFlags(mFlags);
|
||||
tsmesh->computeBounds();
|
||||
tsmesh->numFrames = numFrames;
|
||||
tsmesh->numMatFrames = numMatFrames;
|
||||
tsmesh->vertsPerFrame = vertsPerFrame;
|
||||
tsmesh->numFrames = mNumFrames;
|
||||
tsmesh->numMatFrames = mNumMatFrames;
|
||||
tsmesh->vertsPerFrame = mVertsPerFrame;
|
||||
tsmesh->createTangents(tsmesh->verts, tsmesh->norms);
|
||||
tsmesh->encodedNorms.set(NULL,0);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,33 +42,33 @@ class AppMesh
|
|||
{
|
||||
public:
|
||||
// Mesh and skin elements
|
||||
Vector<Point3F> points;
|
||||
Vector<Point3F> normals;
|
||||
Vector<Point2F> uvs;
|
||||
Vector<Point2F> uv2s;
|
||||
Vector<ColorI> colors;
|
||||
Vector<TSDrawPrimitive> primitives;
|
||||
Vector<U32> indices;
|
||||
Vector<Point3F> mPoints;
|
||||
Vector<Point3F> mNormals;
|
||||
Vector<Point2F> mUVs;
|
||||
Vector<Point2F> mUV2s;
|
||||
Vector<ColorI> mColors;
|
||||
Vector<TSDrawPrimitive> mPrimitives;
|
||||
Vector<U32> mIndices;
|
||||
|
||||
// Skin elements
|
||||
Vector<F32> weight;
|
||||
Vector<S32> boneIndex;
|
||||
Vector<S32> vertexIndex;
|
||||
Vector<S32> nodeIndex;
|
||||
Vector<MatrixF> initialTransforms;
|
||||
Vector<Point3F> initialVerts;
|
||||
Vector<Point3F> initialNorms;
|
||||
Vector<F32> mWeight;
|
||||
Vector<S32> mBoneIndex;
|
||||
Vector<S32> mVertexIndex;
|
||||
Vector<S32> mNodeIndex;
|
||||
Vector<MatrixF> mInitialTransforms;
|
||||
Vector<Point3F> mInitialVerts;
|
||||
Vector<Point3F> mInitialNorms;
|
||||
|
||||
U32 flags;
|
||||
U32 vertsPerFrame;
|
||||
S32 numFrames;
|
||||
S32 numMatFrames;
|
||||
U32 mFlags;
|
||||
U32 mVertsPerFrame;
|
||||
S32 mNumFrames;
|
||||
S32 mNumMatFrames;
|
||||
|
||||
// Loader elements (can be discarded after loading)
|
||||
S32 detailSize;
|
||||
MatrixF objectOffset;
|
||||
Vector<AppNode*> bones;
|
||||
static Vector<AppMaterial*> appMaterials;
|
||||
S32 mDetailSize;
|
||||
MatrixF mObjectOffset;
|
||||
Vector<AppNode*> mBones;
|
||||
static Vector<AppMaterial*> mAppMaterials;
|
||||
|
||||
public:
|
||||
AppMesh();
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ bool cmpMeshNameAndSize(const String& key, const Vector<String>& names, void* ar
|
|||
{
|
||||
if (names[i].compare(key, 0, String::NoCase) == 0)
|
||||
{
|
||||
if (meshes[i]->detailSize == meshSize)
|
||||
if (meshes[i]->mDetailSize == meshSize)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -396,17 +396,17 @@ void TSShapeLoader::generateObjects()
|
|||
for (S32 iMesh = 0; iMesh < subshape->objMeshes.size(); iMesh++)
|
||||
{
|
||||
AppMesh* mesh = subshape->objMeshes[iMesh];
|
||||
mesh->detailSize = 2;
|
||||
String name = String::GetTrailingNumber( mesh->getName(), mesh->detailSize );
|
||||
name = getUniqueName( name, cmpMeshNameAndSize, meshNames, &(subshape->objMeshes), (void*)mesh->detailSize );
|
||||
mesh->mDetailSize = 2;
|
||||
String name = String::GetTrailingNumber( mesh->getName(), mesh->mDetailSize );
|
||||
name = getUniqueName( name, cmpMeshNameAndSize, meshNames, &(subshape->objMeshes), (void*)mesh->mDetailSize );
|
||||
meshNames.push_back( name );
|
||||
|
||||
// Fix up any collision details that don't have a negative detail level.
|
||||
if ( dStrStartsWith(meshNames[iMesh], "Collision") ||
|
||||
dStrStartsWith(meshNames[iMesh], "LOSCol") )
|
||||
{
|
||||
if (mesh->detailSize > 0)
|
||||
mesh->detailSize = -mesh->detailSize;
|
||||
if (mesh->mDetailSize > 0)
|
||||
mesh->mDetailSize = -mesh->mDetailSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +421,7 @@ void TSShapeLoader::generateObjects()
|
|||
{
|
||||
if ((meshNames[i].compare(meshNames[j]) < 0) ||
|
||||
((meshNames[i].compare(meshNames[j]) == 0) &&
|
||||
(subshape->objMeshes[i]->detailSize < subshape->objMeshes[j]->detailSize)))
|
||||
(subshape->objMeshes[i]->mDetailSize < subshape->objMeshes[j]->mDetailSize)))
|
||||
{
|
||||
{
|
||||
AppMesh* tmp = subshape->objMeshes[i];
|
||||
|
|
@ -463,17 +463,17 @@ void TSShapeLoader::generateObjects()
|
|||
shape->objects.last().numMeshes++;
|
||||
|
||||
// Set mesh flags
|
||||
mesh->flags = 0;
|
||||
mesh->mFlags = 0;
|
||||
if (mesh->isBillboard())
|
||||
{
|
||||
mesh->flags |= TSMesh::Billboard;
|
||||
mesh->mFlags |= TSMesh::Billboard;
|
||||
if (mesh->isBillboardZAxis())
|
||||
mesh->flags |= TSMesh::BillboardZAxis;
|
||||
mesh->mFlags |= TSMesh::BillboardZAxis;
|
||||
}
|
||||
|
||||
// Set the detail name... do fixups for collision details.
|
||||
const char* detailName = "detail";
|
||||
if ( mesh->detailSize < 0 )
|
||||
if ( mesh->mDetailSize < 0 )
|
||||
{
|
||||
if ( dStrStartsWith(meshNames[iMesh], "Collision") ||
|
||||
dStrStartsWith(meshNames[iMesh], "Col") )
|
||||
|
|
@ -484,11 +484,11 @@ void TSShapeLoader::generateObjects()
|
|||
|
||||
// Attempt to add the detail (will fail if it already exists)
|
||||
S32 oldNumDetails = shape->details.size();
|
||||
shape->addDetail(detailName, mesh->detailSize, iSub);
|
||||
shape->addDetail(detailName, mesh->mDetailSize, iSub);
|
||||
if (shape->details.size() > oldNumDetails)
|
||||
{
|
||||
Con::warnf("Object mesh \"%s\" has no matching detail (\"%s%d\" has"
|
||||
" been added automatically)", mesh->getName(false), detailName, mesh->detailSize);
|
||||
" been added automatically)", mesh->getName(false), detailName, mesh->mDetailSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -519,30 +519,30 @@ void TSShapeLoader::generateSkins()
|
|||
skin->lookupSkinData();
|
||||
|
||||
// Just copy initial verts and norms for now
|
||||
skin->initialVerts.set(skin->points.address(), skin->vertsPerFrame);
|
||||
skin->initialNorms.set(skin->normals.address(), skin->vertsPerFrame);
|
||||
skin->mInitialVerts.set(skin->mPoints.address(), skin->mVertsPerFrame);
|
||||
skin->mInitialNorms.set(skin->mNormals.address(), skin->mVertsPerFrame);
|
||||
|
||||
// Map bones to nodes
|
||||
skin->nodeIndex.setSize(skin->bones.size());
|
||||
for (S32 iBone = 0; iBone < skin->bones.size(); iBone++)
|
||||
skin->mNodeIndex.setSize(skin->mBones.size());
|
||||
for (S32 iBone = 0; iBone < skin->mBones.size(); iBone++)
|
||||
{
|
||||
// Find the node that matches this bone
|
||||
skin->nodeIndex[iBone] = -1;
|
||||
skin->mNodeIndex[iBone] = -1;
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
if (appNodes[iNode]->isEqual(skin->bones[iBone]))
|
||||
if (appNodes[iNode]->isEqual(skin->mBones[iBone]))
|
||||
{
|
||||
delete skin->bones[iBone];
|
||||
skin->bones[iBone] = appNodes[iNode];
|
||||
skin->nodeIndex[iBone] = iNode;
|
||||
delete skin->mBones[iBone];
|
||||
skin->mBones[iBone] = appNodes[iNode];
|
||||
skin->mNodeIndex[iBone] = iNode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (skin->nodeIndex[iBone] == -1)
|
||||
if (skin->mNodeIndex[iBone] == -1)
|
||||
{
|
||||
Con::warnf("Could not find bone %d. Defaulting to first node", iBone);
|
||||
skin->nodeIndex[iBone] = 0;
|
||||
skin->mNodeIndex[iBone] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -569,7 +569,7 @@ void TSShapeLoader::generateDefaultStates()
|
|||
|
||||
zapScale(nodeMat);
|
||||
|
||||
appMesh->objectOffset = nodeMat.inverse() * meshMat;
|
||||
appMesh->mObjectOffset = nodeMat.inverse() * meshMat;
|
||||
}
|
||||
|
||||
generateObjectState(shape->objects[iObject], DefaultTime, true, true);
|
||||
|
|
@ -603,8 +603,8 @@ void TSShapeLoader::generateObjectState(TSShape::Object& obj, F32 t, bool addFra
|
|||
generateFrame(obj, t, addFrame, addMatFrame);
|
||||
|
||||
// set the frame number for the object state
|
||||
state.frameIndex = appMeshes[obj.startMeshIndex]->numFrames - 1;
|
||||
state.matFrameIndex = appMeshes[obj.startMeshIndex]->numMatFrames - 1;
|
||||
state.frameIndex = appMeshes[obj.startMeshIndex]->mNumFrames - 1;
|
||||
state.matFrameIndex = appMeshes[obj.startMeshIndex]->mNumMatFrames - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -614,45 +614,45 @@ void TSShapeLoader::generateFrame(TSShape::Object& obj, F32 t, bool addFrame, bo
|
|||
{
|
||||
AppMesh* appMesh = appMeshes[obj.startMeshIndex + iMesh];
|
||||
|
||||
U32 oldNumPoints = appMesh->points.size();
|
||||
U32 oldNumUvs = appMesh->uvs.size();
|
||||
U32 oldNumPoints = appMesh->mPoints.size();
|
||||
U32 oldNumUvs = appMesh->mUVs.size();
|
||||
|
||||
// Get the mesh geometry at time, 't'
|
||||
// Geometry verts, normals and tverts can be animated (different set for
|
||||
// each frame), but the TSDrawPrimitives stay the same, so the way lockMesh
|
||||
// works is that it will only generate the primitives once, then after that
|
||||
// will just append verts, normals and tverts each time it is called.
|
||||
appMesh->lockMesh(t, appMesh->objectOffset);
|
||||
appMesh->lockMesh(t, appMesh->mObjectOffset);
|
||||
|
||||
// Calculate vertex normals if required
|
||||
if (appMesh->normals.size() != appMesh->points.size())
|
||||
if (appMesh->mNormals.size() != appMesh->mPoints.size())
|
||||
appMesh->computeNormals();
|
||||
|
||||
// If this is the first call, set the number of points per frame
|
||||
if (appMesh->numFrames == 0)
|
||||
if (appMesh->mNumFrames == 0)
|
||||
{
|
||||
appMesh->vertsPerFrame = appMesh->points.size();
|
||||
appMesh->mVertsPerFrame = appMesh->mPoints.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check frame topology => ie. that the right number of points, normals
|
||||
// and tverts was added
|
||||
if ((appMesh->points.size() - oldNumPoints) != appMesh->vertsPerFrame)
|
||||
if ((appMesh->mPoints.size() - oldNumPoints) != appMesh->mVertsPerFrame)
|
||||
{
|
||||
Con::warnf("Wrong number of points (%d) added at time=%f (expected %d)",
|
||||
appMesh->points.size() - oldNumPoints, t, appMesh->vertsPerFrame);
|
||||
appMesh->mPoints.size() - oldNumPoints, t, appMesh->mVertsPerFrame);
|
||||
addFrame = false;
|
||||
}
|
||||
if ((appMesh->normals.size() - oldNumPoints) != appMesh->vertsPerFrame)
|
||||
if ((appMesh->mNormals.size() - oldNumPoints) != appMesh->mVertsPerFrame)
|
||||
{
|
||||
Con::warnf("Wrong number of normals (%d) added at time=%f (expected %d)",
|
||||
appMesh->normals.size() - oldNumPoints, t, appMesh->vertsPerFrame);
|
||||
appMesh->mNormals.size() - oldNumPoints, t, appMesh->mVertsPerFrame);
|
||||
addFrame = false;
|
||||
}
|
||||
if ((appMesh->uvs.size() - oldNumUvs) != appMesh->vertsPerFrame)
|
||||
if ((appMesh->mUVs.size() - oldNumUvs) != appMesh->mVertsPerFrame)
|
||||
{
|
||||
Con::warnf("Wrong number of tverts (%d) added at time=%f (expected %d)",
|
||||
appMesh->uvs.size() - oldNumUvs, t, appMesh->vertsPerFrame);
|
||||
appMesh->mUVs.size() - oldNumUvs, t, appMesh->mVertsPerFrame);
|
||||
addMatFrame = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -663,21 +663,21 @@ void TSShapeLoader::generateFrame(TSShape::Object& obj, F32 t, bool addFrame, bo
|
|||
// points/normals/tverts are already in place!
|
||||
if (addFrame)
|
||||
{
|
||||
appMesh->numFrames++;
|
||||
appMesh->mNumFrames++;
|
||||
}
|
||||
else
|
||||
{
|
||||
appMesh->points.setSize(oldNumPoints);
|
||||
appMesh->normals.setSize(oldNumPoints);
|
||||
appMesh->mPoints.setSize(oldNumPoints);
|
||||
appMesh->mNormals.setSize(oldNumPoints);
|
||||
}
|
||||
|
||||
if (addMatFrame)
|
||||
{
|
||||
appMesh->numMatFrames++;
|
||||
appMesh->mNumMatFrames++;
|
||||
}
|
||||
else
|
||||
{
|
||||
appMesh->uvs.setSize(oldNumPoints);
|
||||
appMesh->mUVs.setSize(oldNumPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -690,11 +690,11 @@ void TSShapeLoader::generateMaterialList()
|
|||
{
|
||||
// Install the materials into the material list
|
||||
shape->materialList = new TSMaterialList;
|
||||
for (S32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++)
|
||||
for (S32 iMat = 0; iMat < AppMesh::mAppMaterials.size(); iMat++)
|
||||
{
|
||||
updateProgress(Load_GenerateMaterials, "Generating materials...", AppMesh::appMaterials.size(), iMat);
|
||||
updateProgress(Load_GenerateMaterials, "Generating materials...", AppMesh::mAppMaterials.size(), iMat);
|
||||
|
||||
AppMaterial* appMat = AppMesh::appMaterials[iMat];
|
||||
AppMaterial* appMat = AppMesh::mAppMaterials[iMat];
|
||||
shape->materialList->push_back(appMat->getName(), appMat->getFlags(), U32(-1), U32(-1), U32(-1), 1.0f, appMat->getReflectance());
|
||||
}
|
||||
}
|
||||
|
|
@ -1119,7 +1119,7 @@ void TSShapeLoader::sortDetails()
|
|||
// object does not already have a mesh with an equal or higher detail)
|
||||
S32 meshIndex = (iDet < object.numMeshes) ? iDet : object.numMeshes-1;
|
||||
|
||||
if (appMeshes[object.startMeshIndex + meshIndex]->detailSize < shape->details[iDet].size)
|
||||
if (appMeshes[object.startMeshIndex + meshIndex]->mDetailSize < shape->details[iDet].size)
|
||||
{
|
||||
// Add a NULL mesh
|
||||
appMeshes.insert(object.startMeshIndex + iDet, NULL);
|
||||
|
|
@ -1256,9 +1256,9 @@ TSShapeLoader::~TSShapeLoader()
|
|||
clearNodeTransformCache();
|
||||
|
||||
// Clear shared AppMaterial list
|
||||
for (S32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++)
|
||||
delete AppMesh::appMaterials[iMat];
|
||||
AppMesh::appMaterials.clear();
|
||||
for (S32 iMat = 0; iMat < AppMesh::mAppMaterials.size(); iMat++)
|
||||
delete AppMesh::mAppMaterials[iMat];
|
||||
AppMesh::mAppMaterials.clear();
|
||||
|
||||
// Delete Subshapes
|
||||
delete boundsNode;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue