|
@@ -40,8 +40,8 @@ namespace DictHash
|
|
|
|
|
|
using namespace ColladaUtils;
|
|
|
|
|
|
-bool ColladaAppMesh::mFixedSizeEnabled = false;
|
|
|
-S32 ColladaAppMesh::mFixedSize = 2;
|
|
|
+bool ColladaAppMesh::fixedSizeEnabled = false;
|
|
|
+S32 ColladaAppMesh::fixedSize = 2;
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// Define a VertTuple dictionary to allow fast tuple lookups
|
|
@@ -49,7 +49,7 @@ namespace DictHash
|
|
|
{
|
|
|
inline U32 hash(const VertTuple& data)
|
|
|
{
|
|
|
- return (U32)data.mVertex;
|
|
|
+ return (U32)data.vertex;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -197,27 +197,27 @@ private:
|
|
|
|
|
|
public:
|
|
|
|
|
|
- _SourceReader mPoints;
|
|
|
- _SourceReader mNormals;
|
|
|
- _SourceReader mColors;
|
|
|
- _SourceReader mUVs;
|
|
|
- _SourceReader mUV2s;
|
|
|
+ _SourceReader points;
|
|
|
+ _SourceReader normals;
|
|
|
+ _SourceReader colors;
|
|
|
+ _SourceReader uvs;
|
|
|
+ _SourceReader uv2s;
|
|
|
|
|
|
- _SourceReader mJoints;
|
|
|
- _SourceReader mWeights;
|
|
|
- _SourceReader mInvBindMatrices;
|
|
|
+ _SourceReader joints;
|
|
|
+ _SourceReader weights;
|
|
|
+ _SourceReader invBindMatrices;
|
|
|
|
|
|
/// Clear the mesh streams
|
|
|
void reset()
|
|
|
{
|
|
|
- mPoints.reset();
|
|
|
- mNormals.reset();
|
|
|
- mColors.reset();
|
|
|
- mUVs.reset();
|
|
|
- mUV2s.reset();
|
|
|
- mJoints.reset();
|
|
|
- mWeights.reset();
|
|
|
- mInvBindMatrices.reset();
|
|
|
+ points.reset();
|
|
|
+ normals.reset();
|
|
|
+ colors.reset();
|
|
|
+ uvs.reset();
|
|
|
+ uv2s.reset();
|
|
|
+ joints.reset();
|
|
|
+ weights.reset();
|
|
|
+ invBindMatrices.reset();
|
|
|
}
|
|
|
|
|
|
/// Classify a set of inputs by type and set number (needs to be a template
|
|
@@ -283,32 +283,32 @@ public:
|
|
|
|
|
|
// Attempt to initialise the SourceReaders
|
|
|
const char* vertex_params[] = { "X", "Y", "Z", "" };
|
|
|
- initSourceReader(sortedInputs[Points], Points, mPoints, vertex_params);
|
|
|
+ initSourceReader(sortedInputs[Points], Points, points, vertex_params);
|
|
|
|
|
|
const char* normal_params[] = { "X", "Y", "Z", "" };
|
|
|
- initSourceReader(sortedInputs[Normals], Normals, mNormals, normal_params);
|
|
|
+ initSourceReader(sortedInputs[Normals], Normals, normals, normal_params);
|
|
|
|
|
|
const char* color_params[] = { "R", "G", "B", "A", "" };
|
|
|
- initSourceReader(sortedInputs[Colors], Colors, mColors, color_params);
|
|
|
+ initSourceReader(sortedInputs[Colors], Colors, colors, color_params);
|
|
|
|
|
|
const char* uv_params[] = { "S", "T", "" };
|
|
|
const char* uv_params2[] = { "U", "V", "" }; // some files use the nonstandard U,V or X,Y param names
|
|
|
const char* uv_params3[] = { "X", "Y", "" };
|
|
|
- if (!initSourceReader(sortedInputs[UVs], UVs, mUVs, uv_params))
|
|
|
- if (!initSourceReader(sortedInputs[UVs], UVs, mUVs, uv_params2))
|
|
|
- initSourceReader(sortedInputs[UVs], UVs, mUVs, uv_params3);
|
|
|
- if (!initSourceReader(sortedInputs[UV2s], UV2s, mUV2s, uv_params))
|
|
|
- if (!initSourceReader(sortedInputs[UV2s], UV2s, mUV2s, uv_params2))
|
|
|
- initSourceReader(sortedInputs[UV2s], UV2s, mUV2s, uv_params3);
|
|
|
+ if (!initSourceReader(sortedInputs[UVs], UVs, uvs, uv_params))
|
|
|
+ if (!initSourceReader(sortedInputs[UVs], UVs, uvs, uv_params2))
|
|
|
+ initSourceReader(sortedInputs[UVs], UVs, uvs, uv_params3);
|
|
|
+ if (!initSourceReader(sortedInputs[UV2s], UV2s, uv2s, uv_params))
|
|
|
+ if (!initSourceReader(sortedInputs[UV2s], UV2s, uv2s, uv_params2))
|
|
|
+ initSourceReader(sortedInputs[UV2s], UV2s, uv2s, uv_params3);
|
|
|
|
|
|
const char* joint_params[] = { "JOINT", "" };
|
|
|
- initSourceReader(sortedInputs[Joints], Joints, mJoints, joint_params);
|
|
|
+ initSourceReader(sortedInputs[Joints], Joints, joints, joint_params);
|
|
|
|
|
|
const char* weight_params[] = { "WEIGHT", "" };
|
|
|
- initSourceReader(sortedInputs[Weights], Weights, mWeights, weight_params);
|
|
|
+ initSourceReader(sortedInputs[Weights], Weights, weights, weight_params);
|
|
|
|
|
|
const char* matrix_params[] = { "TRANSFORM", "" };
|
|
|
- initSourceReader(sortedInputs[InvBindMatrices], InvBindMatrices, mInvBindMatrices, matrix_params);
|
|
|
+ initSourceReader(sortedInputs[InvBindMatrices], InvBindMatrices, invBindMatrices, matrix_params);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -317,19 +317,19 @@ public:
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
ColladaAppMesh::ColladaAppMesh(const domInstance_geometry* instance, ColladaAppNode* node)
|
|
|
- : mInstanceGeom(instance), mInstanceCtrl(0), mAppNode(node), mGeomExt(0)
|
|
|
+ : instanceGeom(instance), instanceCtrl(0), appNode(node), geomExt(0)
|
|
|
{
|
|
|
- mFlags = 0;
|
|
|
- mNumFrames = 0;
|
|
|
- mNumMatFrames = 0;
|
|
|
+ flags = 0;
|
|
|
+ numFrames = 0;
|
|
|
+ numMatFrames = 0;
|
|
|
}
|
|
|
|
|
|
ColladaAppMesh::ColladaAppMesh(const domInstance_controller* instance, ColladaAppNode* node)
|
|
|
- : mInstanceGeom(0), mInstanceCtrl(instance), mAppNode(node), mGeomExt(0)
|
|
|
+ : instanceGeom(0), instanceCtrl(instance), appNode(node), geomExt(0)
|
|
|
{
|
|
|
- mFlags = 0;
|
|
|
- mNumFrames = 0;
|
|
|
- mNumMatFrames = 0;
|
|
|
+ flags = 0;
|
|
|
+ numFrames = 0;
|
|
|
+ numMatFrames = 0;
|
|
|
}
|
|
|
|
|
|
const char* ColladaAppMesh::getName(bool allowFixed)
|
|
@@ -337,27 +337,27 @@ const char* ColladaAppMesh::getName(bool allowFixed)
|
|
|
// Some exporters add a 'PIVOT' or unnamed node between the mesh and the
|
|
|
// actual object node. Detect this and return the object node name instead
|
|
|
// of the pivot node.
|
|
|
- const char* nodeName = mAppNode->getName();
|
|
|
+ const char* nodeName = appNode->getName();
|
|
|
if ( dStrEqual(nodeName, "null") || dStrEndsWith(nodeName, "PIVOT") )
|
|
|
- nodeName = mAppNode->getParentName();
|
|
|
+ nodeName = appNode->getParentName();
|
|
|
|
|
|
// If all geometry is being fixed to the same size, append the size
|
|
|
// to the name
|
|
|
- return allowFixed && mFixedSizeEnabled ? avar("%s %d", nodeName, mFixedSize) : nodeName;
|
|
|
+ return allowFixed && fixedSizeEnabled ? avar("%s %d", nodeName, fixedSize) : nodeName;
|
|
|
}
|
|
|
|
|
|
MatrixF ColladaAppMesh::getMeshTransform(F32 time)
|
|
|
{
|
|
|
- return mAppNode->getNodeTransform(time);
|
|
|
+ return appNode->getNodeTransform(time);
|
|
|
}
|
|
|
|
|
|
bool ColladaAppMesh::animatesVis(const AppSequence* appSeq)
|
|
|
{
|
|
|
#define IS_VIS_ANIMATED(node) \
|
|
|
- (dynamic_cast<const ColladaAppNode*>(node)->nodeExt->mVisibility.isAnimated(appSeq->getStart(), appSeq->getEnd()))
|
|
|
+ (dynamic_cast<const ColladaAppNode*>(node)->nodeExt->visibility.isAnimated(appSeq->getStart(), appSeq->getEnd()))
|
|
|
|
|
|
// Check if the node visibility is animated within the sequence interval
|
|
|
- return IS_VIS_ANIMATED(mAppNode) || (mAppNode->appParent ? IS_VIS_ANIMATED(mAppNode->appParent) : false);
|
|
|
+ return IS_VIS_ANIMATED(appNode) || (appNode->appParent ? IS_VIS_ANIMATED(appNode->appParent) : false);
|
|
|
}
|
|
|
|
|
|
bool ColladaAppMesh::animatesMatFrame(const AppSequence* appSeq)
|
|
@@ -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 < mAppMaterials.size(); iMat++) {
|
|
|
- ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[iMat]);
|
|
|
+ for (S32 iMat = 0; iMat < appMaterials.size(); iMat++) {
|
|
|
+ ColladaAppMaterial* appMat = static_cast<ColladaAppMaterial*>(appMaterials[iMat]);
|
|
|
if (appMat->effectExt &&
|
|
|
appMat->effectExt->animatesTextureTransform(appSeq->getStart(), appSeq->getEnd()))
|
|
|
return true;
|
|
@@ -418,10 +418,10 @@ bool ColladaAppMesh::animatesFrame(const AppSequence* appSeq)
|
|
|
F32 ColladaAppMesh::getVisValue(F32 t)
|
|
|
{
|
|
|
#define GET_VIS(node) \
|
|
|
- (dynamic_cast<const ColladaAppNode*>(node)->nodeExt->mVisibility.getValue(t))
|
|
|
+ (dynamic_cast<const ColladaAppNode*>(node)->nodeExt->visibility.getValue(t))
|
|
|
|
|
|
// Get the visibility of the mesh's node at time, 't'
|
|
|
- return GET_VIS(mAppNode) * (mAppNode->appParent ? GET_VIS(mAppNode->appParent) : 1.0f);
|
|
|
+ return GET_VIS(appNode) * (appNode->appParent ? GET_VIS(appNode->appParent) : 1.0f);
|
|
|
}
|
|
|
|
|
|
S32 ColladaAppMesh::addMaterial(const char* symbol)
|
|
@@ -431,14 +431,14 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
|
|
|
|
|
|
// Lookup the symbol in the materials already bound to this geometry/controller
|
|
|
// instance
|
|
|
- Map<StringTableEntry,U32>::Iterator itr = mBoundMaterials.find(symbol);
|
|
|
- if (itr != mBoundMaterials.end())
|
|
|
+ Map<StringTableEntry,U32>::Iterator itr = boundMaterials.find(symbol);
|
|
|
+ if (itr != boundMaterials.end())
|
|
|
return itr->value;
|
|
|
|
|
|
// Find the Collada material that this symbol maps to
|
|
|
U32 matIndex = TSDrawPrimitive::NoMaterial;
|
|
|
- const domBind_material* binds = mInstanceGeom ? mInstanceGeom->getBind_material() :
|
|
|
- mInstanceCtrl->getBind_material();
|
|
|
+ const domBind_material* binds = instanceGeom ? instanceGeom->getBind_material() :
|
|
|
+ instanceCtrl->getBind_material();
|
|
|
if (binds) {
|
|
|
const domInstance_material_Array& matArray = binds->getTechnique_common()->getInstance_material_array();
|
|
|
for (S32 iBind = 0; iBind < matArray.getCount(); iBind++) {
|
|
@@ -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 < mAppMaterials.size(); matIndex++) {
|
|
|
- if (static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex])->mat == mat)
|
|
|
+ for (matIndex = 0; matIndex < appMaterials.size(); matIndex++) {
|
|
|
+ if (static_cast<ColladaAppMaterial*>(appMaterials[matIndex])->mat == mat)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// Check if this material needs to be added to the shape global list
|
|
|
- if (matIndex == mAppMaterials.size()) {
|
|
|
+ if (matIndex == appMaterials.size()) {
|
|
|
if (mat)
|
|
|
- mAppMaterials.push_back(new ColladaAppMaterial(mat));
|
|
|
+ appMaterials.push_back(new ColladaAppMaterial(mat));
|
|
|
else
|
|
|
- mAppMaterials.push_back(new ColladaAppMaterial(symbol));
|
|
|
+ appMaterials.push_back(new ColladaAppMaterial(symbol));
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -466,23 +466,23 @@ S32 ColladaAppMesh::addMaterial(const char* symbol)
|
|
|
else
|
|
|
{
|
|
|
// No Collada material is present for this symbol, so just create an empty one
|
|
|
- mAppMaterials.push_back(new ColladaAppMaterial(symbol));
|
|
|
+ appMaterials.push_back(new ColladaAppMaterial(symbol));
|
|
|
}
|
|
|
|
|
|
// Add this symbol to the bound list for the mesh
|
|
|
- mBoundMaterials.insert(StringTable->insert(symbol), matIndex);
|
|
|
+ boundMaterials.insert(StringTable->insert(symbol), matIndex);
|
|
|
return matIndex;
|
|
|
}
|
|
|
|
|
|
void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
|
|
{
|
|
|
// Only do this once
|
|
|
- if (mPrimitives.size())
|
|
|
+ if (primitives.size())
|
|
|
return;
|
|
|
|
|
|
// Read the <geometry> extension
|
|
|
- if (!mGeomExt)
|
|
|
- mGeomExt = new ColladaExtension_geometry(geometry);
|
|
|
+ if (!geomExt)
|
|
|
+ geomExt = new ColladaExtension_geometry(geometry);
|
|
|
|
|
|
// Get the supported primitive elements for this geometry, and warn
|
|
|
// about unsupported elements
|
|
@@ -517,25 +517,25 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
|
|
continue;
|
|
|
|
|
|
// Create TSMesh primitive
|
|
|
- mPrimitives.increment();
|
|
|
- TSDrawPrimitive& primitive = mPrimitives.last();
|
|
|
- primitive.start = mIndices.size();
|
|
|
+ primitives.increment();
|
|
|
+ TSDrawPrimitive& primitive = primitives.last();
|
|
|
+ primitive.start = indices.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*>(mAppMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
|
|
|
+ appMat = static_cast<ColladaAppMaterial*>(appMaterials[primitive.matIndex & TSDrawPrimitive::MaterialMask]);
|
|
|
|
|
|
// Force the material to be double-sided if this geometry is double-sided.
|
|
|
- if (mGeomExt->mDoubleSided && appMat && appMat->effectExt)
|
|
|
- appMat->effectExt->mDoubleSided = true;
|
|
|
+ if (geomExt->double_sided && appMat && appMat->effectExt)
|
|
|
+ appMat->effectExt->double_sided = true;
|
|
|
|
|
|
// Pre-allocate triangle indices
|
|
|
primitive.numElements = numTriangles * 3;
|
|
|
- mIndices.setSize(mIndices.size() + primitive.numElements);
|
|
|
- U32* dstIndex = mIndices.end() - primitive.numElements;
|
|
|
+ indices.setSize(indices.size() + primitive.numElements);
|
|
|
+ U32* dstIndex = indices.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
|
|
@@ -555,12 +555,12 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
|
|
// If the next triangle could cause us to index across a 16-bit
|
|
|
// boundary, split this primitive and clear the tuple map to
|
|
|
// ensure primitives only index verts within a 16-bit range.
|
|
|
- if (mVertTuples.size() &&
|
|
|
- (((mVertTuples.size()-1) ^ (mVertTuples.size()+2)) & 0x10000))
|
|
|
+ if (vertTuples.size() &&
|
|
|
+ (((vertTuples.size()-1) ^ (vertTuples.size()+2)) & 0x10000))
|
|
|
{
|
|
|
// Pad vertTuples up to the next 16-bit boundary
|
|
|
- while (mVertTuples.size() & 0xFFFF)
|
|
|
- mVertTuples.push_back(VertTuple(mVertTuples.last()));
|
|
|
+ while (vertTuples.size() & 0xFFFF)
|
|
|
+ vertTuples.push_back(VertTuple(vertTuples.last()));
|
|
|
|
|
|
// Split the primitive at the current triangle
|
|
|
S32 indicesRemaining = (numTriangles - iTri) * 3;
|
|
@@ -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)));
|
|
|
|
|
|
- mPrimitives.last().numElements -= indicesRemaining;
|
|
|
- mPrimitives.push_back(TSDrawPrimitive(mPrimitives.last()));
|
|
|
+ primitives.last().numElements -= indicesRemaining;
|
|
|
+ primitives.push_back(TSDrawPrimitive(primitives.last()));
|
|
|
}
|
|
|
|
|
|
- mPrimitives.last().numElements = indicesRemaining;
|
|
|
- mPrimitives.last().start = mIndices.size() - indicesRemaining;
|
|
|
+ primitives.last().numElements = indicesRemaining;
|
|
|
+ primitives.last().start = indices.size() - indicesRemaining;
|
|
|
|
|
|
tupleMap.clear();
|
|
|
}
|
|
@@ -586,29 +586,29 @@ void ColladaAppMesh::getPrimitives(const domGeometry* geometry)
|
|
|
// Collect vert tuples into a single array so we can easily grab
|
|
|
// vertex data later.
|
|
|
VertTuple tuple;
|
|
|
- tuple.mPrim = iPrim;
|
|
|
- tuple.mVertex = offsets[MeshStreams::Points] >= 0 ? pSrcData[offsets[MeshStreams::Points]] : -1;
|
|
|
- tuple.mNormal = offsets[MeshStreams::Normals] >= 0 ? pSrcData[offsets[MeshStreams::Normals]] : -1;
|
|
|
- tuple.mColor = offsets[MeshStreams::Colors] >= 0 ? pSrcData[offsets[MeshStreams::Colors]] : -1;
|
|
|
- tuple.mUV = offsets[MeshStreams::UVs] >= 0 ? pSrcData[offsets[MeshStreams::UVs]] : -1;
|
|
|
- tuple.mUV2 = offsets[MeshStreams::UV2s] >= 0 ? pSrcData[offsets[MeshStreams::UV2s]] : -1;
|
|
|
-
|
|
|
- tuple.mDataVertex = tuple.mVertex > -1 ? streams.mPoints.getPoint3FValue(tuple.mVertex) : Point3F::Max;
|
|
|
- tuple.mDataNormal = tuple.mNormal > -1 ? streams.mNormals.getPoint3FValue(tuple.mNormal) : Point3F::Max;
|
|
|
- tuple.mDataColor = tuple.mColor > -1 ? streams.mColors.getColorIValue(tuple.mColor) : ColorI(0,0,0);
|
|
|
- tuple.mDataUV = tuple.mUV > -1 ? streams.mUVs.getPoint2FValue(tuple.mUV) : Point2F::Max;
|
|
|
- tuple.mDataUV2 = tuple.mUV2 > -1 ? streams.mUV2s.getPoint2FValue(tuple.mUV2) : Point2F::Max;
|
|
|
+ tuple.prim = iPrim;
|
|
|
+ tuple.vertex = offsets[MeshStreams::Points] >= 0 ? pSrcData[offsets[MeshStreams::Points]] : -1;
|
|
|
+ tuple.normal = offsets[MeshStreams::Normals] >= 0 ? pSrcData[offsets[MeshStreams::Normals]] : -1;
|
|
|
+ tuple.color = offsets[MeshStreams::Colors] >= 0 ? pSrcData[offsets[MeshStreams::Colors]] : -1;
|
|
|
+ tuple.uv = offsets[MeshStreams::UVs] >= 0 ? pSrcData[offsets[MeshStreams::UVs]] : -1;
|
|
|
+ tuple.uv2 = offsets[MeshStreams::UV2s] >= 0 ? pSrcData[offsets[MeshStreams::UV2s]] : -1;
|
|
|
+
|
|
|
+ tuple.dataVertex = tuple.vertex > -1 ? streams.points.getPoint3FValue(tuple.vertex) : Point3F::Max;
|
|
|
+ tuple.dataNormal = tuple.normal > -1 ? streams.normals.getPoint3FValue(tuple.normal) : Point3F::Max;
|
|
|
+ tuple.dataColor = tuple.color > -1 ? streams.colors.getColorIValue(tuple.color) : ColorI(0,0,0);
|
|
|
+ tuple.dataUV = tuple.uv > -1 ? streams.uvs.getPoint2FValue(tuple.uv) : Point2F::Max;
|
|
|
+ tuple.dataUV2 = tuple.uv2 > -1 ? streams.uv2s.getPoint2FValue(tuple.uv2) : Point2F::Max;
|
|
|
|
|
|
VertTupleMap::Iterator itr = tupleMap.find(tuple);
|
|
|
if (itr == tupleMap.end())
|
|
|
{
|
|
|
- itr = tupleMap.insert(tuple, mVertTuples.size());
|
|
|
- mVertTuples.push_back(tuple);
|
|
|
+ itr = tupleMap.insert(tuple, vertTuples.size());
|
|
|
+ vertTuples.push_back(tuple);
|
|
|
}
|
|
|
|
|
|
// Collada uses CCW for front face and Torque uses the opposite, so
|
|
|
// for normal (non-inverted) meshes, the indices are flipped.
|
|
|
- if (mAppNode->invertMeshes)
|
|
|
+ if (appNode->invertMeshes)
|
|
|
dstIndex[v] = itr->value;
|
|
|
else
|
|
|
dstIndex[2 - v] = itr->value;
|
|
@@ -631,7 +631,7 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
|
|
|
Vector<Point2F>& v_uv2s,
|
|
|
bool appendValues)
|
|
|
{
|
|
|
- if (!mPrimitives.size())
|
|
|
+ if (!primitives.size())
|
|
|
return;
|
|
|
|
|
|
MeshStreams streams;
|
|
@@ -648,24 +648,24 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
|
|
|
|
|
|
// If appending values, pre-allocate the arrays
|
|
|
if (appendValues) {
|
|
|
- v_points.setSize(v_points.size() + mVertTuples.size());
|
|
|
- v_uvs.setSize(v_uvs.size() + mVertTuples.size());
|
|
|
+ v_points.setSize(v_points.size() + vertTuples.size());
|
|
|
+ v_uvs.setSize(v_uvs.size() + vertTuples.size());
|
|
|
}
|
|
|
|
|
|
// Get pointers to arrays
|
|
|
- Point3F* points_array = &v_points[v_points.size() - mVertTuples.size()];
|
|
|
- Point2F* uvs_array = &v_uvs[v_uvs.size() - mVertTuples.size()];
|
|
|
+ Point3F* points_array = &v_points[v_points.size() - vertTuples.size()];
|
|
|
+ Point2F* uvs_array = &v_uvs[v_uvs.size() - vertTuples.size()];
|
|
|
Point3F* norms_array = NULL;
|
|
|
ColorI* colors_array = NULL;
|
|
|
Point2F* uv2s_array = NULL;
|
|
|
|
|
|
- for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
|
|
|
+ for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
|
|
|
|
|
|
- const VertTuple& tuple = mVertTuples[iVert];
|
|
|
+ const VertTuple& tuple = vertTuples[iVert];
|
|
|
|
|
|
// Change primitives?
|
|
|
- if (tuple.mPrim != lastPrimitive) {
|
|
|
- if (meshPrims.size() <= tuple.mPrim) {
|
|
|
+ if (tuple.prim != lastPrimitive) {
|
|
|
+ if (meshPrims.size() <= tuple.prim) {
|
|
|
daeErrorHandler::get()->handleError(avar("Failed to get vertex data "
|
|
|
"for %s. Primitives do not match base geometry.", geometry->getID()));
|
|
|
break;
|
|
@@ -673,31 +673,31 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
|
|
|
|
|
|
// Update vertex/normal/UV streams and get the new material index
|
|
|
streams.reset();
|
|
|
- streams.readInputs(meshPrims[tuple.mPrim]->getInputs());
|
|
|
- S32 matIndex = addMaterial(meshPrims[tuple.mPrim]->getMaterial());
|
|
|
+ streams.readInputs(meshPrims[tuple.prim]->getInputs());
|
|
|
+ S32 matIndex = addMaterial(meshPrims[tuple.prim]->getMaterial());
|
|
|
if (matIndex != TSDrawPrimitive::NoMaterial)
|
|
|
- appMat = static_cast<ColladaAppMaterial*>(mAppMaterials[matIndex]);
|
|
|
+ appMat = static_cast<ColladaAppMaterial*>(appMaterials[matIndex]);
|
|
|
else
|
|
|
appMat = 0;
|
|
|
|
|
|
- lastPrimitive = tuple.mPrim;
|
|
|
+ lastPrimitive = tuple.prim;
|
|
|
}
|
|
|
|
|
|
// If we are NOT appending values, only set the value if it actually exists
|
|
|
// in the mesh data stream.
|
|
|
|
|
|
- if (appendValues || ((tuple.mVertex >= 0) && (tuple.mVertex < streams.mPoints.size()))) {
|
|
|
- points_array[iVert] = streams.mPoints.getPoint3FValue(tuple.mVertex);
|
|
|
+ if (appendValues || ((tuple.vertex >= 0) && (tuple.vertex < streams.points.size()))) {
|
|
|
+ points_array[iVert] = streams.points.getPoint3FValue(tuple.vertex);
|
|
|
|
|
|
// Flip verts for inverted meshes
|
|
|
- if (mAppNode->invertMeshes)
|
|
|
+ if (appNode->invertMeshes)
|
|
|
points_array[iVert].z = -points_array[iVert].z;
|
|
|
|
|
|
objOffset.mulP(points_array[iVert]);
|
|
|
}
|
|
|
|
|
|
- if (appendValues || ((tuple.mUV >= 0) && (tuple.mUV < streams.mUVs.size()))) {
|
|
|
- uvs_array[iVert] = streams.mUVs.getPoint2FValue(tuple.mUV);
|
|
|
+ if (appendValues || ((tuple.uv >= 0) && (tuple.uv < streams.uvs.size()))) {
|
|
|
+ uvs_array[iVert] = streams.uvs.getPoint2FValue(tuple.uv);
|
|
|
if (appMat && appMat->effectExt)
|
|
|
appMat->effectExt->applyTextureTransform(uvs_array[iVert], time);
|
|
|
uvs_array[iVert].y = 1.0f - uvs_array[iVert].y; // Collada texcoords are upside down compared to TGE
|
|
@@ -705,45 +705,45 @@ void ColladaAppMesh::getVertexData(const domGeometry* geometry, F32 time, const
|
|
|
|
|
|
// The rest is non-required data... if it doesn't exist then don't append it.
|
|
|
|
|
|
- if ( (tuple.mNormal >= 0) && (tuple.mNormal < streams.mNormals.size()) ) {
|
|
|
+ if ( (tuple.normal >= 0) && (tuple.normal < streams.normals.size()) ) {
|
|
|
if ( !norms_array && iVert == 0 )
|
|
|
{
|
|
|
- v_norms.setSize(v_norms.size() + mVertTuples.size());
|
|
|
- norms_array = &v_norms[v_norms.size() - mVertTuples.size()];
|
|
|
+ v_norms.setSize(v_norms.size() + vertTuples.size());
|
|
|
+ norms_array = &v_norms[v_norms.size() - vertTuples.size()];
|
|
|
}
|
|
|
|
|
|
if ( norms_array ) {
|
|
|
- norms_array[iVert] = streams.mNormals.getPoint3FValue(tuple.mNormal);
|
|
|
+ norms_array[iVert] = streams.normals.getPoint3FValue(tuple.normal);
|
|
|
|
|
|
// Flip normals for inverted meshes
|
|
|
- if (mAppNode->invertMeshes)
|
|
|
+ if (appNode->invertMeshes)
|
|
|
norms_array[iVert].z = -norms_array[iVert].z;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ( (tuple.mColor >= 0) && (tuple.mColor < streams.mColors.size()))
|
|
|
+ if ( (tuple.color >= 0) && (tuple.color < streams.colors.size()))
|
|
|
{
|
|
|
if ( !colors_array && iVert == 0 )
|
|
|
{
|
|
|
- v_colors.setSize(v_colors.size() + mVertTuples.size());
|
|
|
- colors_array = &v_colors[v_colors.size() - mVertTuples.size()];
|
|
|
+ v_colors.setSize(v_colors.size() + vertTuples.size());
|
|
|
+ colors_array = &v_colors[v_colors.size() - vertTuples.size()];
|
|
|
}
|
|
|
|
|
|
if ( colors_array )
|
|
|
- colors_array[iVert] = streams.mColors.getColorIValue(tuple.mColor);
|
|
|
+ colors_array[iVert] = streams.colors.getColorIValue(tuple.color);
|
|
|
}
|
|
|
|
|
|
- if ( (tuple.mUV2 >= 0) && (tuple.mUV2 < streams.mUV2s.size()) )
|
|
|
+ if ( (tuple.uv2 >= 0) && (tuple.uv2 < streams.uv2s.size()) )
|
|
|
{
|
|
|
if ( !uv2s_array && iVert == 0 )
|
|
|
{
|
|
|
- v_uv2s.setSize(v_uv2s.size() + mVertTuples.size());
|
|
|
- uv2s_array = &v_uv2s[v_uv2s.size() - mVertTuples.size()];
|
|
|
+ v_uv2s.setSize(v_uv2s.size() + vertTuples.size());
|
|
|
+ uv2s_array = &v_uv2s[v_uv2s.size() - vertTuples.size()];
|
|
|
}
|
|
|
|
|
|
if ( uv2s_array )
|
|
|
{
|
|
|
- uv2s_array[iVert] = streams.mUV2s.getPoint2FValue(tuple.mUV2);
|
|
|
+ uv2s_array[iVert] = streams.uv2s.getPoint2FValue(tuple.uv2);
|
|
|
if (appMat && appMat->effectExt)
|
|
|
appMat->effectExt->applyTextureTransform(uv2s_array[iVert], time);
|
|
|
uv2s_array[iVert].y = 1.0f - uv2s_array[iVert].y; // Collada texcoords are upside down compared to TGE
|
|
@@ -810,11 +810,11 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
|
|
|
getVertexData(baseGeometry, time, objOffset, v_points, v_norms, v_colors, v_uvs, v_uv2s, true);
|
|
|
|
|
|
// Get pointers to the arrays of base geometry data
|
|
|
- Point3F* points_array = &v_points[v_points.size() - mVertTuples.size()];
|
|
|
- Point3F* norms_array = &v_norms[v_norms.size() - mVertTuples.size()];
|
|
|
- Point2F* uvs_array = &v_uvs[v_uvs.size() - mVertTuples.size()];
|
|
|
- ColorI* colors_array = v_colors.size() ? &v_colors[v_colors.size() - mVertTuples.size()] : 0;
|
|
|
- Point2F* uv2s_array = v_uv2s.size() ? &v_uv2s[v_uv2s.size() - mVertTuples.size()] : 0;
|
|
|
+ Point3F* points_array = &v_points[v_points.size() - vertTuples.size()];
|
|
|
+ Point3F* norms_array = &v_norms[v_norms.size() - vertTuples.size()];
|
|
|
+ Point2F* uvs_array = &v_uvs[v_uvs.size() - vertTuples.size()];
|
|
|
+ ColorI* colors_array = v_colors.size() ? &v_colors[v_colors.size() - vertTuples.size()] : 0;
|
|
|
+ Point2F* uv2s_array = v_uv2s.size() ? &v_uv2s[v_uv2s.size() - vertTuples.size()] : 0;
|
|
|
|
|
|
// Normalize base vertex data?
|
|
|
if (morph->getMethod() == MORPHMETHODTYPE_NORMALIZED) {
|
|
@@ -827,14 +827,14 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
|
|
|
// Result = Base*(1.0-w1-w2 ... -wN) + w1*Target1 + w2*Target2 ... + wN*TargetN
|
|
|
weightSum = mClampF(1.0f - weightSum, 0.0f, 1.0f);
|
|
|
|
|
|
- for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
|
|
|
+ for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
|
|
|
points_array[iVert] *= weightSum;
|
|
|
norms_array[iVert] *= weightSum;
|
|
|
uvs_array[iVert] *= weightSum;
|
|
|
}
|
|
|
|
|
|
if (uv2s_array) {
|
|
|
- for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
|
|
|
+ for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
|
|
|
uv2s_array[iVert] *= weightSum;
|
|
|
}
|
|
|
}
|
|
@@ -855,29 +855,29 @@ void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const M
|
|
|
|
|
|
// Copy base geometry into target geometry (will be used if target does
|
|
|
// not define normals or uvs)
|
|
|
- targetPoints.set(points_array, mVertTuples.size());
|
|
|
- targetNorms.set(norms_array, mVertTuples.size());
|
|
|
- targetUvs.set(uvs_array, mVertTuples.size());
|
|
|
+ targetPoints.set(points_array, vertTuples.size());
|
|
|
+ targetNorms.set(norms_array, vertTuples.size());
|
|
|
+ targetUvs.set(uvs_array, vertTuples.size());
|
|
|
if (colors_array)
|
|
|
- targetColors.set(colors_array, mVertTuples.size());
|
|
|
+ targetColors.set(colors_array, vertTuples.size());
|
|
|
if (uv2s_array)
|
|
|
- targetUv2s.set(uv2s_array, mVertTuples.size());
|
|
|
+ targetUv2s.set(uv2s_array, vertTuples.size());
|
|
|
|
|
|
getVertexData(targetGeoms[iTarget], time, objOffset, targetPoints, targetNorms, targetColors, targetUvs, targetUv2s, false);
|
|
|
|
|
|
// Combine with base geometry
|
|
|
- for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++) {
|
|
|
+ for (S32 iVert = 0; iVert < vertTuples.size(); iVert++) {
|
|
|
points_array[iVert] += targetPoints[iVert] * targetWeights[iTarget];
|
|
|
norms_array[iVert] += targetNorms[iVert] * targetWeights[iTarget];
|
|
|
uvs_array[iVert] += targetUvs[iVert] * targetWeights[iTarget];
|
|
|
}
|
|
|
|
|
|
if (uv2s_array) {
|
|
|
- for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
|
|
|
+ for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
|
|
|
uv2s_array[iVert] += targetUv2s[iVert] * targetWeights[iTarget];
|
|
|
}
|
|
|
if (colors_array) {
|
|
|
- for (S32 iVert = 0; iVert < mVertTuples.size(); iVert++)
|
|
|
+ for (S32 iVert = 0; iVert < vertTuples.size(); iVert++)
|
|
|
colors_array[iVert] += targetColors[iVert] * (F32)targetWeights[iTarget];
|
|
|
}
|
|
|
}
|
|
@@ -891,12 +891,12 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
|
|
|
// 3) a skin (skin geometry could also be a morph!)
|
|
|
daeElement* geometry = 0;
|
|
|
|
|
|
- if (mInstanceGeom) {
|
|
|
+ if (instanceGeom) {
|
|
|
// Simple, static mesh
|
|
|
- geometry = mInstanceGeom->getUrl().getElement();
|
|
|
+ geometry = instanceGeom->getUrl().getElement();
|
|
|
}
|
|
|
- else if (mInstanceCtrl) {
|
|
|
- const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
|
|
|
+ else if (instanceCtrl) {
|
|
|
+ const domController* ctrl = daeSafeCast<domController>(instanceCtrl->getUrl().getElement());
|
|
|
if (!ctrl) {
|
|
|
daeErrorHandler::get()->handleWarning(avar("Failed to find <controller> "
|
|
|
"element for %s", getName()));
|
|
@@ -923,10 +923,10 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
|
|
|
// Now get the vertex data at the specified time
|
|
|
if (geometry->getElementType() == COLLADA_TYPE::GEOMETRY) {
|
|
|
getPrimitives(daeSafeCast<domGeometry>(geometry));
|
|
|
- getVertexData(daeSafeCast<domGeometry>(geometry), t, objOffset, mPoints, mNormals, mColors, mUVs, mUV2s, true);
|
|
|
+ getVertexData(daeSafeCast<domGeometry>(geometry), t, objOffset, points, normals, colors, uvs, uv2s, true);
|
|
|
}
|
|
|
else if (geometry->getElementType() == COLLADA_TYPE::MORPH) {
|
|
|
- getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objOffset, mPoints, mNormals, mColors, mUVs, mUV2s);
|
|
|
+ getMorphVertexData(daeSafeCast<domMorph>(geometry), t, objOffset, points, normals, colors, uvs, uv2s);
|
|
|
}
|
|
|
else {
|
|
|
daeErrorHandler::get()->handleWarning(avar("Unsupported geometry type "
|
|
@@ -937,11 +937,11 @@ void ColladaAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
|
|
|
void ColladaAppMesh::lookupSkinData()
|
|
|
{
|
|
|
// Only lookup skin data once
|
|
|
- if (!isSkin() || mWeight.size())
|
|
|
+ if (!isSkin() || weight.size())
|
|
|
return;
|
|
|
|
|
|
// Get the skin and vertex weight data
|
|
|
- const domSkin* skin = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement())->getSkin();
|
|
|
+ const domSkin* skin = daeSafeCast<domController>(instanceCtrl->getUrl().getElement())->getSkin();
|
|
|
const domSkin::domVertex_weights& weightIndices = *(skin->getVertex_weights());
|
|
|
const domListOfInts& weights_v = weightIndices.getV()->getValue();
|
|
|
const domListOfUInts& weights_vcount = weightIndices.getVcount()->getValue();
|
|
@@ -950,7 +950,7 @@ void ColladaAppMesh::lookupSkinData()
|
|
|
streams.readInputs(skin->getJoints()->getInput_array());
|
|
|
streams.readInputs(weightIndices.getInput_array());
|
|
|
|
|
|
- MatrixF invObjOffset(mObjectOffset);
|
|
|
+ MatrixF invObjOffset(objectOffset);
|
|
|
invObjOffset.inverse();
|
|
|
|
|
|
// Get the bind shape matrix
|
|
@@ -971,17 +971,17 @@ void ColladaAppMesh::lookupSkinData()
|
|
|
|
|
|
// Set vertex weights
|
|
|
bool tooManyWeightsWarning = false;
|
|
|
- for (S32 iVert = 0; iVert < mVertsPerFrame; iVert++) {
|
|
|
+ for (S32 iVert = 0; iVert < vertsPerFrame; iVert++) {
|
|
|
const domUint* vcount = (domUint*)weights_vcount.getRaw(0);
|
|
|
const domInt* vindices = (domInt*)weights_v.getRaw(0);
|
|
|
- vindices += vindicesOffset[mVertTuples[iVert].mVertex];
|
|
|
+ vindices += vindicesOffset[vertTuples[iVert].vertex];
|
|
|
|
|
|
S32 nonZeroWeightCount = 0;
|
|
|
|
|
|
- for (S32 iWeight = 0; iWeight < vcount[mVertTuples[iVert].mVertex]; iWeight++) {
|
|
|
+ for (S32 iWeight = 0; iWeight < vcount[vertTuples[iVert].vertex]; iWeight++) {
|
|
|
|
|
|
S32 bIndex = vindices[iWeight*2];
|
|
|
- F32 bWeight = streams.mWeights.getFloatValue( vindices[iWeight*2 + 1] );
|
|
|
+ F32 bWeight = streams.weights.getFloatValue( vindices[iWeight*2 + 1] );
|
|
|
|
|
|
// Ignore empty weights
|
|
|
if ( bIndex < 0 || bWeight == 0 )
|
|
@@ -990,7 +990,7 @@ void ColladaAppMesh::lookupSkinData()
|
|
|
// Limit the number of weights per bone (keep the N largest influences)
|
|
|
if ( nonZeroWeightCount >= TSSkinMesh::BatchData::maxBonePerVert )
|
|
|
{
|
|
|
- if (vcount[mVertTuples[iVert].mVertex] > TSSkinMesh::BatchData::maxBonePerVert)
|
|
|
+ if (vcount[vertTuples[iVert].vertex] > TSSkinMesh::BatchData::maxBonePerVert)
|
|
|
{
|
|
|
if (!tooManyWeightsWarning)
|
|
|
{
|
|
@@ -1002,25 +1002,25 @@ void ColladaAppMesh::lookupSkinData()
|
|
|
}
|
|
|
|
|
|
// Too many weights => find and replace the smallest one
|
|
|
- S32 minIndex = mWeight.size() - TSSkinMesh::BatchData::maxBonePerVert;
|
|
|
- F32 minWeight = mWeight[minIndex];
|
|
|
- for (S32 i = minIndex + 1; i < mWeight.size(); i++)
|
|
|
+ S32 minIndex = weight.size() - TSSkinMesh::BatchData::maxBonePerVert;
|
|
|
+ F32 minWeight = weight[minIndex];
|
|
|
+ for (S32 i = minIndex + 1; i < weight.size(); i++)
|
|
|
{
|
|
|
- if (mWeight[i] < minWeight)
|
|
|
+ if (weight[i] < minWeight)
|
|
|
{
|
|
|
- minWeight = mWeight[i];
|
|
|
+ minWeight = weight[i];
|
|
|
minIndex = i;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- mBoneIndex[minIndex] = bIndex;
|
|
|
- mWeight[minIndex] = bWeight;
|
|
|
+ boneIndex[minIndex] = bIndex;
|
|
|
+ weight[minIndex] = bWeight;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- mVertexIndex.push_back( iVert );
|
|
|
- mBoneIndex.push_back( bIndex );
|
|
|
- mWeight.push_back( bWeight );
|
|
|
+ vertexIndex.push_back( iVert );
|
|
|
+ boneIndex.push_back( bIndex );
|
|
|
+ weight.push_back( bWeight );
|
|
|
nonZeroWeightCount++;
|
|
|
}
|
|
|
}
|
|
@@ -1028,36 +1028,36 @@ void ColladaAppMesh::lookupSkinData()
|
|
|
|
|
|
// Normalize vertex weights (force weights for each vert to sum to 1)
|
|
|
S32 iWeight = 0;
|
|
|
- while (iWeight < mWeight.size()) {
|
|
|
+ while (iWeight < weight.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 < mWeight.size(); iLast++) {
|
|
|
- if (mVertexIndex[iLast] != mVertexIndex[iWeight])
|
|
|
+ for (iLast = iWeight; iLast < weight.size(); iLast++) {
|
|
|
+ if (vertexIndex[iLast] != vertexIndex[iWeight])
|
|
|
break;
|
|
|
- invTotalWeight += mWeight[iLast];
|
|
|
+ invTotalWeight += weight[iLast];
|
|
|
}
|
|
|
|
|
|
// Then normalize the vertex weights
|
|
|
invTotalWeight = 1.0f / invTotalWeight;
|
|
|
for (; iWeight < iLast; iWeight++)
|
|
|
- mWeight[iWeight] *= invTotalWeight;
|
|
|
+ weight[iWeight] *= invTotalWeight;
|
|
|
}
|
|
|
|
|
|
// Add dummy AppNodes to allow Collada joints to be mapped to 3space nodes
|
|
|
- mBones.setSize(streams.mJoints.size());
|
|
|
- mInitialTransforms.setSize(streams.mJoints.size());
|
|
|
- for (S32 iJoint = 0; iJoint < streams.mJoints.size(); iJoint++)
|
|
|
+ bones.setSize(streams.joints.size());
|
|
|
+ initialTransforms.setSize(streams.joints.size());
|
|
|
+ for (S32 iJoint = 0; iJoint < streams.joints.size(); iJoint++)
|
|
|
{
|
|
|
- const char* jointName = streams.mJoints.getStringValue(iJoint);
|
|
|
+ const char* jointName = streams.joints.getStringValue(iJoint);
|
|
|
|
|
|
// Lookup the joint element
|
|
|
const domNode* joint = 0;
|
|
|
- if (mInstanceCtrl->getSkeleton_array().getCount()) {
|
|
|
+ if (instanceCtrl->getSkeleton_array().getCount()) {
|
|
|
// Search for the node using the <skeleton> as the base element
|
|
|
- for (S32 iSkel = 0; iSkel < mInstanceCtrl->getSkeleton_array().getCount(); iSkel++) {
|
|
|
- xsAnyURI skeleton = mInstanceCtrl->getSkeleton_array()[iSkel]->getValue();
|
|
|
+ for (S32 iSkel = 0; iSkel < instanceCtrl->getSkeleton_array().getCount(); iSkel++) {
|
|
|
+ xsAnyURI skeleton = instanceCtrl->getSkeleton_array()[iSkel]->getValue();
|
|
|
daeSIDResolver resolver(skeleton.getElement(), jointName);
|
|
|
joint = daeSafeCast<domNode>(resolver.getElement());
|
|
|
if (joint)
|
|
@@ -1072,33 +1072,33 @@ void ColladaAppMesh::lookupSkinData()
|
|
|
|
|
|
if (!joint) {
|
|
|
daeErrorHandler::get()->handleWarning(avar("Failed to find bone '%s', "
|
|
|
- "defaulting to instance_controller parent node '%s'", jointName, mAppNode->getName()));
|
|
|
- joint = mAppNode->getDomNode();
|
|
|
+ "defaulting to instance_controller parent node '%s'", jointName, appNode->getName()));
|
|
|
+ joint = appNode->getDomNode();
|
|
|
}
|
|
|
- mBones[iJoint] = new ColladaAppNode(joint);
|
|
|
+ bones[iJoint] = new ColladaAppNode(joint);
|
|
|
|
|
|
- mInitialTransforms[iJoint] = mObjectOffset;
|
|
|
+ initialTransforms[iJoint] = objectOffset;
|
|
|
|
|
|
// Bone scaling is generally ignored during import, since 3space only
|
|
|
// stores default node transform and rotation. Compensate for this by
|
|
|
// removing the scaling from the inverse bind transform as well
|
|
|
- MatrixF invBind = streams.mInvBindMatrices.getMatrixFValue(iJoint);
|
|
|
- if (!ColladaUtils::getOptions().mIgnoreNodeScale)
|
|
|
+ MatrixF invBind = streams.invBindMatrices.getMatrixFValue(iJoint);
|
|
|
+ if (!ColladaUtils::getOptions().ignoreNodeScale)
|
|
|
{
|
|
|
Point3F invScale = invBind.getScale();
|
|
|
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;
|
|
|
- mInitialTransforms[iJoint].scale(invScale);
|
|
|
+ initialTransforms[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)
|
|
|
- mInitialTransforms[iJoint].scale(Point3F(1, 1, -1));
|
|
|
+ initialTransforms[iJoint].scale(Point3F(1, 1, -1));
|
|
|
|
|
|
- mInitialTransforms[iJoint].mul(invBind);
|
|
|
- mInitialTransforms[iJoint].mul(bindShapeMatrix);
|
|
|
+ initialTransforms[iJoint].mul(invBind);
|
|
|
+ initialTransforms[iJoint].mul(bindShapeMatrix);
|
|
|
}
|
|
|
}
|