Revert recent style cleanup changes.

This commit is contained in:
Daniel Buckmaster 2015-03-04 11:55:30 +11:00
parent a73850a4bb
commit 84e8cbb4ee
62 changed files with 3380 additions and 3380 deletions

View file

@ -82,9 +82,9 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
const domCommon_color_or_texture_type_complexType* domSpecular = findEffectSpecular(effect);
// Wrap flags
if (effectExt->mWrapU)
if (effectExt->wrapU)
flags |= TSMaterialList::S_Wrap;
if (effectExt->mWrapV)
if (effectExt->wrapV)
flags |= TSMaterialList::T_Wrap;
// Set material attributes
@ -146,17 +146,17 @@ ColladaAppMaterial::ColladaAppMaterial(const domMaterial *pMat)
}
// Double-sided flag
doubleSided = effectExt->mDoubleSided;
doubleSided = effectExt->double_sided;
// Get the paths for the various textures => Collada indirection at its finest!
// <texture>.<newparam>.<sampler2D>.<source>.<newparam>.<surface>.<init_from>.<image>.<init_from>
diffuseMap = getSamplerImagePath(effect, getTextureSampler(effect, domDiffuse));
specularMap = getSamplerImagePath(effect, getTextureSampler(effect, domSpecular));
normalMap = getSamplerImagePath(effect, effectExt->mBumpSampler);
normalMap = getSamplerImagePath(effect, effectExt->bumpSampler);
// Set the material name
name = ColladaUtils::getOptions().mMatNamePrefix;
if ( ColladaUtils::getOptions().mUseDiffuseNames )
name = ColladaUtils::getOptions().matNamePrefix;
if ( ColladaUtils::getOptions().useDiffuseNames )
{
Torque::Path diffusePath( diffuseMap );
name += diffusePath.getFileName();

View file

@ -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.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.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.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);
}
}

View file

@ -57,20 +57,20 @@
// AND all of the target geometries because they MUST have the same topology.
struct VertTuple
{
S32 mPrim, mVertex, mNormal, mColor, mUV, mUV2;
S32 prim, vertex, normal, color, uv, uv2;
Point3F mDataVertex, mDataNormal;
ColorI mDataColor;
Point2F mDataUV, mDataUV2;
Point3F dataVertex, dataNormal;
ColorI dataColor;
Point2F dataUV, dataUV2;
VertTuple(): mPrim(-1), mVertex(-1), mNormal(-1), mColor(-1), mUV(-1), mUV2(-1) {}
VertTuple(): prim(-1), vertex(-1), normal(-1), color(-1), uv(-1), uv2(-1) {}
bool operator==(const VertTuple& p) const
{
return mDataVertex == p.mDataVertex &&
mDataColor == p.mDataColor &&
mDataNormal == p.mDataNormal &&
mDataUV == p.mDataUV &&
mDataUV2 == p.mDataUV2;
return dataVertex == p.dataVertex &&
dataColor == p.dataColor &&
dataNormal == p.dataNormal &&
dataUV == p.dataUV &&
dataUV2 == p.dataUV2;
}
};
@ -79,24 +79,24 @@ class ColladaAppMesh : public AppMesh
typedef AppMesh Parent;
protected:
class ColladaAppNode* mAppNode; ///< Pointer to the node that owns this mesh
const domInstance_geometry* mInstanceGeom;
const domInstance_controller* mInstanceCtrl;
ColladaExtension_geometry* mGeomExt; ///< geometry extension
class ColladaAppNode* appNode; ///< Pointer to the node that owns this mesh
const domInstance_geometry* instanceGeom;
const domInstance_controller* instanceCtrl;
ColladaExtension_geometry* geomExt; ///< geometry extension
Vector<VertTuple> mVertTuples; ///<
Map<StringTableEntry,U32> mBoundMaterials; ///< Local map of symbols to materials
Vector<VertTuple> vertTuples; ///<
Map<StringTableEntry,U32> boundMaterials; ///< Local map of symbols to materials
static bool mFixedSizeEnabled; ///< Set to true to fix the detail size to a particular value for all geometry
static S32 mFixedSize; ///< The fixed detail size value for all geometry
static bool fixedSizeEnabled; ///< Set to true to fix the detail size to a particular value for all geometry
static S32 fixedSize; ///< The fixed detail size value for all geometry
//-----------------------------------------------------------------------
/// Get the morph controller for this mesh (if any)
const domMorph* getMorph()
{
if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->getUrl().getElement());
if (ctrl && ctrl->getSkin())
ctrl = daeSafeCast<domController>(ctrl->getSkin()->getSource().getElement());
return ctrl ? ctrl->getMorph() : NULL;
@ -123,13 +123,13 @@ public:
ColladaAppMesh(const domInstance_controller* instance, ColladaAppNode* node);
~ColladaAppMesh()
{
delete mGeomExt;
delete geomExt;
}
static void fixDetailSize(bool fixed, S32 size=2)
{
mFixedSizeEnabled = fixed;
mFixedSize = size;
fixedSizeEnabled = fixed;
fixedSize = size;
}
/// Get the name of this mesh
@ -147,7 +147,7 @@ public:
/// @return True if a value was set, false if not
bool getFloat(const char *propName, F32 &defaultVal)
{
return mAppNode->getFloat(propName,defaultVal);
return appNode->getFloat(propName,defaultVal);
}
/// Get an integer property value
@ -158,7 +158,7 @@ public:
/// @return True if a value was set, false if not
bool getInt(const char *propName, S32 &defaultVal)
{
return mAppNode->getInt(propName,defaultVal);
return appNode->getInt(propName,defaultVal);
}
/// Get a boolean property value
@ -169,14 +169,14 @@ public:
/// @return True if a value was set, false if not
bool getBool(const char *propName, bool &defaultVal)
{
return mAppNode->getBool(propName,defaultVal);
return appNode->getBool(propName,defaultVal);
}
/// Return true if this mesh is a skin
bool isSkin()
{
if (mInstanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(mInstanceCtrl->getUrl().getElement());
if (instanceCtrl) {
const domController* ctrl = daeSafeCast<domController>(instanceCtrl->getUrl().getElement());
if (ctrl && ctrl->getSkin() &&
(ctrl->getSkin()->getVertex_weights()->getV()->getValue().getCount() > 0))
return true;

View file

@ -58,7 +58,7 @@ static char* TrimFirstWord(char* str)
ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
: p_domNode(node), appParent(parent), nodeExt(new ColladaExtension_node(node)),
lastTransformTime(TSShapeLoader::smDefaultTime-1), defaultTransformValid(false),
lastTransformTime(TSShapeLoader::DefaultTime-1), defaultTransformValid(false),
invertMeshes(false)
{
mName = dStrdup(_GetNameOrId(node));
@ -66,7 +66,7 @@ ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
// Extract user properties from the <node> extension as whitespace separated
// "name=value" pairs
char* properties = dStrdup(nodeExt->mUserProperties);
char* properties = dStrdup(nodeExt->user_properties);
char* pos = properties;
char* end = properties + dStrlen( properties );
while ( pos < end )
@ -99,7 +99,7 @@ ColladaAppNode::ColladaAppNode(const domNode* node, ColladaAppNode* parent)
case COLLADA_TYPE::MATRIX:
case COLLADA_TYPE::LOOKAT:
nodeTransforms.increment();
nodeTransforms.last().mElement = node->getContents()[iChild];
nodeTransforms.last().element = node->getContents()[iChild];
break;
}
}
@ -178,7 +178,7 @@ bool ColladaAppNode::animatesTransform(const AppSequence* appSeq)
MatrixF ColladaAppNode::getNodeTransform(F32 time)
{
// Avoid re-computing the default transform if possible
if (defaultTransformValid && time == TSShapeLoader::smDefaultTime)
if (defaultTransformValid && time == TSShapeLoader::DefaultTime)
{
return defaultNodeTransform;
}
@ -198,7 +198,7 @@ MatrixF ColladaAppNode::getNodeTransform(F32 time)
}
// Cache the default transform
if (time == TSShapeLoader::smDefaultTime)
if (time == TSShapeLoader::DefaultTime)
{
defaultTransformValid = true;
defaultNodeTransform = nodeTransform;
@ -221,7 +221,7 @@ MatrixF ColladaAppNode::getTransform(F32 time)
else {
// no parent (ie. root level) => scale by global shape <unit>
lastTransform.identity();
lastTransform.scale(ColladaUtils::getOptions().mUnit);
lastTransform.scale(ColladaUtils::getOptions().unit);
if (!isBounds())
ColladaUtils::convertTransform(lastTransform); // don't convert bounds node transform (or upAxis won't work!)
}
@ -232,7 +232,7 @@ MatrixF ColladaAppNode::getTransform(F32 time)
MatrixF mat(true);
// Convert the transform element to a MatrixF
switch (nodeTransforms[iTxfm].mElement->getElementType()) {
switch (nodeTransforms[iTxfm].element->getElementType()) {
case COLLADA_TYPE::TRANSLATE: mat = vecToMatrixF<domTranslate>(nodeTransforms[iTxfm].getValue(time)); break;
case COLLADA_TYPE::SCALE: mat = vecToMatrixF<domScale>(nodeTransforms[iTxfm].getValue(time)); break;
case COLLADA_TYPE::ROTATE: mat = vecToMatrixF<domRotate>(nodeTransforms[iTxfm].getValue(time)); break;
@ -242,7 +242,7 @@ MatrixF ColladaAppNode::getTransform(F32 time)
}
// Remove node scaling (but keep reflections) if desired
if (ColladaUtils::getOptions().mIgnoreNodeScale)
if (ColladaUtils::getOptions().ignoreNodeScale)
{
Point3F invScale = mat.getScale();
invScale.x = invScale.x ? (1.0f / invScale.x) : 0;

View file

@ -45,31 +45,31 @@ const char* ColladaAppSequence::getName() const
S32 ColladaAppSequence::getNumTriggers()
{
return clipExt->mTriggers.size();
return clipExt->triggers.size();
}
void ColladaAppSequence::getTrigger(S32 index, TSShape::Trigger& trigger)
{
trigger.pos = clipExt->mTriggers[index].time;
trigger.state = clipExt->mTriggers[index].state;
trigger.pos = clipExt->triggers[index].time;
trigger.state = clipExt->triggers[index].state;
}
U32 ColladaAppSequence::getFlags() const
{
U32 flags = 0;
if (clipExt->mCyclic) flags |= TSShape::Cyclic;
if (clipExt->mBlend) flags |= TSShape::Blend;
if (clipExt->cyclic) flags |= TSShape::Cyclic;
if (clipExt->blend) flags |= TSShape::Blend;
return flags;
}
F32 ColladaAppSequence::getPriority()
{
return clipExt->mPriority;
return clipExt->priority;
}
F32 ColladaAppSequence::getBlendRefTime()
{
return clipExt->mBlendReferenceTime;
return clipExt->blendReferenceTime;
}
void ColladaAppSequence::setActive(bool active)
@ -88,7 +88,7 @@ void ColladaAppSequence::setAnimationActive(const domAnimation* anim, bool activ
domChannel* channel = anim->getChannel_array()[iChannel];
AnimData* animData = reinterpret_cast<AnimData*>(channel->getUserData());
if (animData)
animData->mEnabled = active;
animData->enabled = active;
}
// Recurse into child animations

View file

@ -29,10 +29,10 @@
/// the interval
bool ColladaExtension_effect::animatesTextureTransform(F32 start, F32 end)
{
return mRepeatU.isAnimated(start, end) || mRepeatV.isAnimated(start, end) ||
mOffsetU.isAnimated(start, end) || mOffsetV.isAnimated(start, end) ||
mRotateUV.isAnimated(start, end) || mNoiseU.isAnimated(start, end) ||
mNoiseV.isAnimated(start, end);
return repeatU.isAnimated(start, end) || repeatV.isAnimated(start, end) ||
offsetU.isAnimated(start, end) || offsetV.isAnimated(start, end) ||
rotateUV.isAnimated(start, end) || noiseU.isAnimated(start, end) ||
noiseV.isAnimated(start, end);
}
/// Apply the MAYA texture transform to the given UV coordinates
@ -41,21 +41,21 @@ void ColladaExtension_effect::applyTextureTransform(Point2F& uv, F32 time)
// This function will be called for every tvert, every frame. So cache the
// texture transform parameters to avoid interpolating them every call (since
// they are constant for all tverts for a given 't')
if (time != mLastAnimTime) {
if (time != lastAnimTime) {
// Update texture transform
mTextureTransform.set(EulerF(0, 0, mRotateUV.getValue(time)));
mTextureTransform.setPosition(Point3F(
mOffsetU.getValue(time) + mNoiseU.getValue(time)*gRandGen.randF(),
mOffsetV.getValue(time) + mNoiseV.getValue(time)*gRandGen.randF(),
textureTransform.set(EulerF(0, 0, rotateUV.getValue(time)));
textureTransform.setPosition(Point3F(
offsetU.getValue(time) + noiseU.getValue(time)*gRandGen.randF(),
offsetV.getValue(time) + noiseV.getValue(time)*gRandGen.randF(),
0));
mTextureTransform.scale(Point3F(mRepeatU.getValue(time), mRepeatV.getValue(time), 1.0f));
textureTransform.scale(Point3F(repeatU.getValue(time), repeatV.getValue(time), 1.0f));
mLastAnimTime = time;
lastAnimTime = time;
}
// Apply texture transform
Point3F result;
mTextureTransform.mulP(Point3F(uv.x, uv.y, 0), &result);
textureTransform.mulP(Point3F(uv.x, uv.y, 0), &result);
uv.x = result.x;
uv.y = result.y;

View file

@ -53,7 +53,7 @@ class ColladaExtension
get(#param, param, defaultVal)
protected:
const domTechnique* mTechnique;
const domTechnique* pTechnique;
/// Find the technique with the named profile
template<class T> const domTechnique* findExtraTechnique(const T* element, const char* name) const
@ -86,10 +86,10 @@ protected:
/// Find the parameter with the given name
const domAny* findParam(const char* name)
{
if (mTechnique) {
if (pTechnique) {
// search the technique contents for the desired parameter
for (S32 iParam = 0; iParam < mTechnique->getContents().getCount(); iParam++) {
const domAny* param = daeSafeCast<domAny>(mTechnique->getContents()[iParam]);
for (S32 iParam = 0; iParam < pTechnique->getContents().getCount(); iParam++) {
const domAny* param = daeSafeCast<domAny>(pTechnique->getContents()[iParam]);
if (param && !dStrcmp(param->getElementName(), name))
return param;
}
@ -108,13 +108,13 @@ protected:
/// Get the value of the named animated parameter (use defaultVal if parameter not found)
template<typename T> void get(const char* name, AnimatedElement<T>& value, T defaultVal)
{
value.mDefaultVal = defaultVal;
value.defaultVal = defaultVal;
if (const domAny* param = findParam(name))
value.mElement = param;
value.element = param;
}
public:
ColladaExtension() : mTechnique(0) { }
ColladaExtension() : pTechnique(0) { }
virtual ~ColladaExtension() { }
};
@ -122,14 +122,14 @@ public:
class ColladaExtension_effect : public ColladaExtension
{
// Cached texture transform
F32 mLastAnimTime;
MatrixF mTextureTransform;
F32 lastAnimTime;
MatrixF textureTransform;
public:
//----------------------------------
// <effect>
// MAX3D profile elements
bool mDoubleSided;
bool double_sided;
//----------------------------------
// <effect>.<profile_COMMON>
@ -139,39 +139,39 @@ public:
//----------------------------------
// <effect>.<profile_COMMON>.<technique>.<blinn/phong/lambert>.<diffuse>.<texture>
// MAYA profile elements
bool mWrapU, mWrapV;
bool mMirrorU, mMirrorV;
AnimatedFloat mCoverageU, mCoverageV;
AnimatedFloat mTranslateFrameU, mTranslateFrameV;
AnimatedFloat mRotateFrame;
AnimatedBool mStagger; // @todo: not supported yet
AnimatedFloat mRepeatU, mRepeatV;
AnimatedFloat mOffsetU, mOffsetV;
AnimatedFloat mRotateUV;
AnimatedFloat mNoiseU, mNoiseV;
bool wrapU, wrapV;
bool mirrorU, mirrorV;
AnimatedFloat coverageU, coverageV;
AnimatedFloat translateFrameU, translateFrameV;
AnimatedFloat rotateFrame;
AnimatedBool stagger; // @todo: not supported yet
AnimatedFloat repeatU, repeatV;
AnimatedFloat offsetU, offsetV;
AnimatedFloat rotateUV;
AnimatedFloat noiseU, noiseV;
//----------------------------------
// <effect>.<profile_COMMON>.<technique>
// FCOLLADA profile elements
domFx_sampler2D_common_complexType* mBumpSampler;
domFx_sampler2D_common_complexType* bumpSampler;
public:
ColladaExtension_effect(const domEffect* effect)
: mLastAnimTime(TSShapeLoader::smDefaultTime-1), mTextureTransform(true), mBumpSampler(0)
: lastAnimTime(TSShapeLoader::DefaultTime-1), textureTransform(true), bumpSampler(0)
{
//----------------------------------
// <effect>
// MAX3D profile
mTechnique = findExtraTechnique(effect, "MAX3D");
GET_EXTRA_PARAM(mDoubleSided, false);
pTechnique = findExtraTechnique(effect, "MAX3D");
GET_EXTRA_PARAM(double_sided, false);
//----------------------------------
// <effect>.<profile_COMMON>
const domProfile_COMMON* profileCommon = ColladaUtils::findEffectCommonProfile(effect);
// GOOGLEEARTH profile (same double_sided element)
mTechnique = findExtraTechnique(profileCommon, "GOOGLEEARTH");
GET_EXTRA_PARAM(mDoubleSided, mDoubleSided);
pTechnique = findExtraTechnique(profileCommon, "GOOGLEEARTH");
GET_EXTRA_PARAM(double_sided, double_sided);
//----------------------------------
// <effect>.<profile_COMMON>.<technique>.<blinn/phong/lambert>.<diffuse>.<texture>
@ -179,43 +179,43 @@ public:
const domFx_sampler2D_common_complexType* sampler2D = ColladaUtils::getTextureSampler(effect, domDiffuse);
// Use the sampler2D to set default values for wrap/mirror flags
mWrapU = mWrapV = true;
mMirrorU = mMirrorV = false;
wrapU = wrapV = true;
mirrorU = mirrorV = false;
if (sampler2D) {
domFx_sampler2D_common_complexType::domWrap_s* wrap_s = sampler2D->getWrap_s();
domFx_sampler2D_common_complexType::domWrap_t* wrap_t = sampler2D->getWrap_t();
mMirrorU = (wrap_s && wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
mWrapU = (mMirrorU || !wrap_s || (wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
mMirrorV = (wrap_t && wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
mWrapV = (mMirrorV || !wrap_t || (wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
mirrorU = (wrap_s && wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
wrapU = (mirrorU || !wrap_s || (wrap_s->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
mirrorV = (wrap_t && wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_MIRROR);
wrapV = (mirrorV || !wrap_t || (wrap_t->getValue() == FX_SAMPLER_WRAP_COMMON_WRAP));
}
// MAYA profile
mTechnique = findExtraTechnique(domDiffuse ? domDiffuse->getTexture() : 0, "MAYA");
GET_EXTRA_PARAM(mWrapU, mWrapU); GET_EXTRA_PARAM(mWrapV, mWrapV);
GET_EXTRA_PARAM(mMirrorU, mMirrorU); GET_EXTRA_PARAM(mMirrorV, mMirrorV);
GET_EXTRA_PARAM(mCoverageU, 1.0); GET_EXTRA_PARAM(mCoverageV, 1.0);
GET_EXTRA_PARAM(mTranslateFrameU, 0.0); GET_EXTRA_PARAM(mTranslateFrameV, 0.0);
GET_EXTRA_PARAM(mRotateFrame, 0.0);
GET_EXTRA_PARAM(mStagger, false);
GET_EXTRA_PARAM(mRepeatU, 1.0); GET_EXTRA_PARAM(mRepeatV, 1.0);
GET_EXTRA_PARAM(mOffsetU, 0.0); GET_EXTRA_PARAM(mOffsetV, 0.0);
GET_EXTRA_PARAM(mRotateUV, 0.0);
GET_EXTRA_PARAM(mNoiseU, 0.0); GET_EXTRA_PARAM(mNoiseV, 0.0);
pTechnique = findExtraTechnique(domDiffuse ? domDiffuse->getTexture() : 0, "MAYA");
GET_EXTRA_PARAM(wrapU, wrapU); GET_EXTRA_PARAM(wrapV, wrapV);
GET_EXTRA_PARAM(mirrorU, mirrorU); GET_EXTRA_PARAM(mirrorV, mirrorV);
GET_EXTRA_PARAM(coverageU, 1.0); GET_EXTRA_PARAM(coverageV, 1.0);
GET_EXTRA_PARAM(translateFrameU, 0.0); GET_EXTRA_PARAM(translateFrameV, 0.0);
GET_EXTRA_PARAM(rotateFrame, 0.0);
GET_EXTRA_PARAM(stagger, false);
GET_EXTRA_PARAM(repeatU, 1.0); GET_EXTRA_PARAM(repeatV, 1.0);
GET_EXTRA_PARAM(offsetU, 0.0); GET_EXTRA_PARAM(offsetV, 0.0);
GET_EXTRA_PARAM(rotateUV, 0.0);
GET_EXTRA_PARAM(noiseU, 0.0); GET_EXTRA_PARAM(noiseV, 0.0);
// FCOLLADA profile
if (profileCommon) {
mTechnique = findExtraTechnique((const domProfile_COMMON::domTechnique*)profileCommon->getTechnique(), "FCOLLADA");
if (mTechnique) {
domAny* bump = daeSafeCast<domAny>(const_cast<domTechnique*>(mTechnique)->getChild("bump"));
pTechnique = findExtraTechnique((const domProfile_COMMON::domTechnique*)profileCommon->getTechnique(), "FCOLLADA");
if (pTechnique) {
domAny* bump = daeSafeCast<domAny>(const_cast<domTechnique*>(pTechnique)->getChild("bump"));
if (bump) {
domAny* bumpTexture = daeSafeCast<domAny>(bump->getChild("texture"));
if (bumpTexture) {
daeSIDResolver resolver(const_cast<domEffect*>(effect), bumpTexture->getAttribute("texture").c_str());
domCommon_newparam_type* param = daeSafeCast<domCommon_newparam_type>(resolver.getElement());
if (param)
mBumpSampler = param->getSampler2D();
bumpSampler = param->getSampler2D();
}
}
}
@ -235,21 +235,21 @@ class ColladaExtension_node : public ColladaExtension
{
public:
// FCOLLADA or OpenCOLLADA profile elements
AnimatedFloat mVisibility;
const char* mUserProperties;
AnimatedFloat visibility;
const char* user_properties;
ColladaExtension_node(const domNode* node)
{
// FCOLLADA profile
mTechnique = findExtraTechnique(node, "FCOLLADA");
GET_EXTRA_PARAM(mVisibility, 1.0);
GET_EXTRA_PARAM(mUserProperties, "");
pTechnique = findExtraTechnique(node, "FCOLLADA");
GET_EXTRA_PARAM(visibility, 1.0);
GET_EXTRA_PARAM(user_properties, "");
// OpenCOLLADA profile
mTechnique = findExtraTechnique(node, "OpenCOLLADA");
if (!mVisibility.mElement)
GET_EXTRA_PARAM(mVisibility, 1.0);
GET_EXTRA_PARAM(mUserProperties, mUserProperties);
pTechnique = findExtraTechnique(node, "OpenCOLLADA");
if (!visibility.element)
GET_EXTRA_PARAM(visibility, 1.0);
GET_EXTRA_PARAM(user_properties, user_properties);
}
};
@ -258,13 +258,13 @@ class ColladaExtension_geometry : public ColladaExtension
{
public:
// MAYA profile elements
bool mDoubleSided;
bool double_sided;
ColladaExtension_geometry(const domGeometry* geometry)
{
// MAYA profile
mTechnique = findExtraTechnique(geometry, "MAYA");
GET_EXTRA_PARAM(mDoubleSided, false);
pTechnique = findExtraTechnique(geometry, "MAYA");
GET_EXTRA_PARAM(double_sided, false);
}
};
@ -278,27 +278,27 @@ public:
};
// Torque profile elements (none of these are animatable)
S32 mNumTriggers;
Vector<Trigger> mTriggers;
bool mCyclic;
bool mBlend;
F32 mBlendReferenceTime;
F32 mPriority;
S32 num_triggers;
Vector<Trigger> triggers;
bool cyclic;
bool blend;
F32 blendReferenceTime;
F32 priority;
ColladaExtension_animation_clip(const domAnimation_clip* clip)
{
// Torque profile
mTechnique = findExtraTechnique(clip, "Torque");
GET_EXTRA_PARAM(mNumTriggers, 0);
for (S32 iTrigger = 0; iTrigger < mNumTriggers; iTrigger++) {
mTriggers.increment();
get(avar("trigger_time%d", iTrigger), mTriggers.last().time, 0.0f);
get(avar("trigger_state%d", iTrigger), mTriggers.last().state, 0);
pTechnique = findExtraTechnique(clip, "Torque");
GET_EXTRA_PARAM(num_triggers, 0);
for (S32 iTrigger = 0; iTrigger < num_triggers; iTrigger++) {
triggers.increment();
get(avar("trigger_time%d", iTrigger), triggers.last().time, 0.0f);
get(avar("trigger_state%d", iTrigger), triggers.last().state, 0);
}
GET_EXTRA_PARAM(mCyclic, false);
GET_EXTRA_PARAM(mBlend, false);
GET_EXTRA_PARAM(mBlendReferenceTime, 0.0f);
GET_EXTRA_PARAM(mPriority, 5.0f);
GET_EXTRA_PARAM(cyclic, false);
GET_EXTRA_PARAM(blend, false);
GET_EXTRA_PARAM(blendReferenceTime, 0.0f);
GET_EXTRA_PARAM(priority, 5.0f);
}
};

View file

@ -117,7 +117,7 @@ static void processNodeLights(AppNode* appNode, const MatrixF& offset, SimGroup*
Con::printf("Adding <%s> light \"%s\" as a %s", lightType, lightName.c_str(), pLight->getClassName());
MatrixF mat(offset);
mat.mul(appNode->getNodeTransform(TSShapeLoader::smDefaultTime));
mat.mul(appNode->getNodeTransform(TSShapeLoader::DefaultTime));
pLight->setDataField(StringTable->insert("color"), 0,
avar("%f %f %f %f", color.red, color.green, color.blue, color.alpha));
@ -210,8 +210,8 @@ DefineConsoleFunction( loadColladaLights, bool, (const char * filename, const ch
upAxis = root->getAsset()->getUp_axis()->getValue();
}
ColladaUtils::getOptions().mUnit = unit;
ColladaUtils::getOptions().mUpAxis = upAxis;
ColladaUtils::getOptions().unit = unit;
ColladaUtils::getOptions().upAxis = upAxis;
// First grab all of the top-level nodes
Vector<ColladaAppNode*> sceneNodes;

View file

@ -95,11 +95,11 @@ ColladaShapeLoader::ColladaShapeLoader(domCOLLADA* _root)
}
// Set import options (if they are not set to override)
if (ColladaUtils::getOptions().mUnit <= 0.0f)
ColladaUtils::getOptions().mUnit = unit;
if (ColladaUtils::getOptions().unit <= 0.0f)
ColladaUtils::getOptions().unit = unit;
if (ColladaUtils::getOptions().mUpAxis == UPAXISTYPE_COUNT)
ColladaUtils::getOptions().mUpAxis = upAxis;
if (ColladaUtils::getOptions().upAxis == UPAXISTYPE_COUNT)
ColladaUtils::getOptions().upAxis = upAxis;
}
ColladaShapeLoader::~ColladaShapeLoader()
@ -169,14 +169,14 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
// @todo:don't care about the input param names for now. Could
// validate against the target type....
if (dStrEqual(input->getSemantic(), "INPUT")) {
data.mInput.initFromSource(source);
data.input.initFromSource(source);
// Adjust the maximum sequence end time
maxEndTime = getMax(maxEndTime, data.mInput.getFloatValue((S32)data.mInput.size()-1));
maxEndTime = getMax(maxEndTime, data.input.getFloatValue((S32)data.input.size()-1));
// Detect the frame rate (minimum time between keyframes)
for (S32 iFrame = 1; iFrame < data.mInput.size(); iFrame++)
for (S32 iFrame = 1; iFrame < data.input.size(); iFrame++)
{
F32 delta = data.mInput.getFloatValue( iFrame ) - data.mInput.getFloatValue( iFrame-1 );
F32 delta = data.input.getFloatValue( iFrame ) - data.input.getFloatValue( iFrame-1 );
if ( delta < 0 )
{
daeErrorHandler::get()->handleError(avar("<animation> INPUT '%s' "
@ -187,13 +187,13 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
}
}
else if (dStrEqual(input->getSemantic(), "OUTPUT"))
data.mOutput.initFromSource(source);
data.output.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "IN_TANGENT"))
data.mInTangent.initFromSource(source);
data.inTangent.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "OUT_TANGENT"))
data.mOutTangent.initFromSource(source);
data.outTangent.initFromSource(source);
else if (dStrEqual(input->getSemantic(), "INTERPOLATION"))
data.mInterpolation.initFromSource(source);
data.interpolation.initFromSource(source);
}
// Set initial value for visibility targets that were added automatically (in colladaUtils.cpp
@ -201,11 +201,11 @@ void ColladaShapeLoader::processAnimation(const domAnimation* anim, F32& maxEndT
{
domAny* visTarget = daeSafeCast<domAny>(target);
if (visTarget && dStrEqual(visTarget->getValue(), ""))
visTarget->setValue(avar("%g", data.mOutput.getFloatValue(0)));
visTarget->setValue(avar("%g", data.output.getFloatValue(0)));
}
// Ignore empty animations
if (data.mInput.size() == 0) {
if (data.input.size() == 0) {
channel->setUserData(0);
delete targetChannels->last();
targetChannels->pop_back();
@ -239,14 +239,14 @@ void ColladaShapeLoader::enumerateScene()
for (S32 iClipLib = 0; iClipLib < root->getLibrary_animation_clips_array().getCount(); iClipLib++) {
const domLibrary_animation_clips* libraryClips = root->getLibrary_animation_clips_array()[iClipLib];
for (S32 iClip = 0; iClip < libraryClips->getAnimation_clip_array().getCount(); iClip++)
mAppSequences.push_back(new ColladaAppSequence(libraryClips->getAnimation_clip_array()[iClip]));
appSequences.push_back(new ColladaAppSequence(libraryClips->getAnimation_clip_array()[iClip]));
}
// Process all animations => this attaches animation channels to the targeted
// Collada elements, and determines the length of the sequence if it is not
// already specified in the Collada <animation_clip> element
for (S32 iSeq = 0; iSeq < mAppSequences.size(); iSeq++) {
ColladaAppSequence* appSeq = dynamic_cast<ColladaAppSequence*>(mAppSequences[iSeq]);
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++) {
ColladaAppSequence* appSeq = dynamic_cast<ColladaAppSequence*>(appSequences[iSeq]);
F32 maxEndTime = 0;
F32 minFrameTime = 1000.0f;
for (S32 iAnim = 0; iAnim < appSeq->getClip()->getInstance_animation_array().getCount(); iAnim++) {
@ -260,7 +260,7 @@ void ColladaShapeLoader::enumerateScene()
// Collada animations can be stored as sampled frames or true keyframes. For
// sampled frames, use the same frame rate as the DAE file. For true keyframes,
// resample at a fixed frame rate.
appSeq->fps = mClamp(1.0f / minFrameTime + 0.5f, TSShapeLoader::smMinFrameRate, TSShapeLoader::smMaxFrameRate);
appSeq->fps = mClamp(1.0f / minFrameTime + 0.5f, TSShapeLoader::MinFrameRate, TSShapeLoader::MaxFrameRate);
}
// First grab all of the top-level nodes
@ -276,7 +276,7 @@ void ColladaShapeLoader::enumerateScene()
// Set LOD option
bool singleDetail = true;
switch (ColladaUtils::getOptions().mLodType)
switch (ColladaUtils::getOptions().lodType)
{
case ColladaUtils::ImportOptions::DetectDTS:
// Check for a baseXX->startXX hierarchy at the top-level, if we find
@ -307,7 +307,7 @@ void ColladaShapeLoader::enumerateScene()
break;
}
ColladaAppMesh::fixDetailSize( singleDetail, ColladaUtils::getOptions().mSingleDetailSize );
ColladaAppMesh::fixDetailSize( singleDetail, ColladaUtils::getOptions().singleDetailSize );
// Process the top level nodes
for (S32 iNode = 0; iNode < sceneNodes.size(); iNode++) {
@ -317,7 +317,7 @@ void ColladaShapeLoader::enumerateScene()
}
// Make sure that the scene has a bounds node (for getting the root scene transform)
if (!mBoundsNode)
if (!boundsNode)
{
domVisual_scene* visualScene = root->getLibrary_visual_scenes_array()[0]->getVisual_scene_array()[0];
domNode* dombounds = daeSafeCast<domNode>( visualScene->createAndPlace( "node" ) );
@ -330,18 +330,18 @@ void ColladaShapeLoader::enumerateScene()
bool ColladaShapeLoader::ignoreNode(const String& name)
{
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mAlwaysImport, name, false))
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().alwaysImport, name, false))
return false;
else
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mNeverImport, name, false);
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().neverImport, name, false);
}
bool ColladaShapeLoader::ignoreMesh(const String& name)
{
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mAlwaysImportMesh, name, false))
if (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().alwaysImportMesh, name, false))
return false;
else
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().mNeverImportMesh, name, false);
return FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().neverImportMesh, name, false);
}
void ColladaShapeLoader::computeBounds(Box3F& bounds)
@ -350,17 +350,17 @@ void ColladaShapeLoader::computeBounds(Box3F& bounds)
// Check if the model origin needs adjusting
if ( bounds.isValidBox() &&
(ColladaUtils::getOptions().mAdjustCenter ||
ColladaUtils::getOptions().mAdjustFloor) )
(ColladaUtils::getOptions().adjustCenter ||
ColladaUtils::getOptions().adjustFloor) )
{
// Compute shape offset
Point3F shapeOffset = Point3F::Zero;
if ( ColladaUtils::getOptions().mAdjustCenter )
if ( ColladaUtils::getOptions().adjustCenter )
{
bounds.getCenter( &shapeOffset );
shapeOffset = -shapeOffset;
}
if ( ColladaUtils::getOptions().mAdjustFloor )
if ( ColladaUtils::getOptions().adjustFloor )
shapeOffset.z = -bounds.minExtents.z;
// Adjust bounds
@ -368,24 +368,24 @@ void ColladaShapeLoader::computeBounds(Box3F& bounds)
bounds.maxExtents += shapeOffset;
// Now adjust all positions for root level nodes (nodes with no parent)
for (S32 iNode = 0; iNode < mShape->mNodes.size(); iNode++)
for (S32 iNode = 0; iNode < shape->nodes.size(); iNode++)
{
if ( !mAppNodes[iNode]->isParentRoot() )
if ( !appNodes[iNode]->isParentRoot() )
continue;
// Adjust default translation
mShape->mDefaultTranslations[iNode] += shapeOffset;
shape->defaultTranslations[iNode] += shapeOffset;
// Adjust animated translations
for (S32 iSeq = 0; iSeq < mShape->mSequences.size(); iSeq++)
for (S32 iSeq = 0; iSeq < shape->sequences.size(); iSeq++)
{
const TSShape::Sequence& seq = mShape->mSequences[iSeq];
const TSShape::Sequence& seq = shape->sequences[iSeq];
if ( seq.translationMatters.test(iNode) )
{
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
{
S32 index = seq.baseTranslation + seq.translationMatters.count(iNode)*seq.numKeyframes + iFrame;
mShape->mNodeTranslations[index] += shapeOffset;
shape->nodeTranslations[index] += shapeOffset;
}
}
}
@ -457,7 +457,7 @@ void copySketchupTexture(const Torque::Path &path, String &textureFilename)
void updateMaterialsScript(const Torque::Path &path, bool copyTextures = false)
{
#ifdef DAE2DTS_TOOL
if (!ColladaUtils::getOptions().mForceUpdateMaterials)
if (!ColladaUtils::getOptions().forceUpdateMaterials)
return;
#endif
@ -467,16 +467,16 @@ 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::mAppMaterials.size(); iMat++ )
for ( U32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++ )
{
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::mAppMaterials[iMat] );
ColladaAppMaterial *mat = dynamic_cast<ColladaAppMaterial*>( AppMesh::appMaterials[iMat] );
if ( mat )
{
Material *mappedMat;
if ( Sim::findObject( MATMGR->getMapEntry( mat->getName() ), mappedMat ) )
{
// Only update existing materials if forced to
if ( ColladaUtils::getOptions().mForceUpdateMaterials )
if ( ColladaUtils::getOptions().forceUpdateMaterials )
persistMgr.setDirty( mappedMat );
}
else
@ -686,8 +686,8 @@ TSShape* loadColladaShape(const Torque::Path &path)
#ifdef DAE2DTS_TOOL
// Command line overrides certain options
ColladaUtils::getOptions().mForceUpdateMaterials = cmdLineOptions.mForceUpdateMaterials;
ColladaUtils::getOptions().mUseDiffuseNames = cmdLineOptions.mUseDiffuseNames;
ColladaUtils::getOptions().forceUpdateMaterials = cmdLineOptions.forceUpdateMaterials;
ColladaUtils::getOptions().useDiffuseNames = cmdLineOptions.useDiffuseNames;
#endif
}

View file

@ -49,7 +49,7 @@ void ColladaUtils::convertTransform(MatrixF& mat)
{
MatrixF rot(true);
switch (ColladaUtils::getOptions().mUpAxis)
switch (ColladaUtils::getOptions().upAxis)
{
case UPAXISTYPE_X_UP:
// rotate 90 around Y-axis, then 90 around Z-axis
@ -248,27 +248,27 @@ BasePrimitive* BasePrimitive::get(const daeElement* element)
void AnimData::parseTargetString(const char* target, S32 fullCount, const char* elements[])
{
// Assume targeting all elements at offset 0
mTargetValueCount = fullCount;
mTargetValueOffset = 0;
targetValueCount = fullCount;
targetValueOffset = 0;
// Check for array syntax: (n) or (n)(m)
if (const char* p = dStrchr(target, '(')) {
S32 indN, indM;
if (dSscanf(p, "(%d)(%d)", &indN, &indM) == 2) {
mTargetValueOffset = (indN * 4) + indM; // @todo: 4x4 matrix only
mTargetValueCount = 1;
targetValueOffset = (indN * 4) + indM; // @todo: 4x4 matrix only
targetValueCount = 1;
}
else if (dSscanf(p, "(%d)", &indN) == 1) {
mTargetValueOffset = indN;
mTargetValueCount = 1;
targetValueOffset = indN;
targetValueCount = 1;
}
}
else if (const char* p = dStrrchr(target, '.')) {
// Check for named elements
for (S32 iElem = 0; elements[iElem][0] != 0; iElem++) {
if (!dStrcmp(p, elements[iElem])) {
mTargetValueOffset = iElem;
mTargetValueCount = 1;
targetValueOffset = iElem;
targetValueCount = 1;
break;
}
}
@ -327,47 +327,47 @@ F32 AnimData::invertParamCubic(F32 param, F32 x0, F32 x1, F32 x2, F32 x3) const
void AnimData::interpValue(F32 t, U32 offset, double* value) const
{
// handle degenerate animation data
if (mInput.size() == 0)
if (input.size() == 0)
{
*value = 0.0f;
return;
}
else if (mInput.size() == 1)
else if (input.size() == 1)
{
*value = mOutput.getStringArrayData(0)[offset];
*value = output.getStringArrayData(0)[offset];
return;
}
// clamp time to valid range
F32 curveStart = mInput.getFloatValue(0);
F32 curveEnd = mInput.getFloatValue(mInput.size()-1);
F32 curveStart = input.getFloatValue(0);
F32 curveEnd = input.getFloatValue(input.size()-1);
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
S32 index;
for (index = 0; index < mInput.size()-2; index++) {
if (mInput.getFloatValue(index + 1) > t)
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
break;
}
// get the data for the two control points either side of 't'
Point2F v0;
v0.x = mInput.getFloatValue(index);
v0.y = mOutput.getStringArrayData(index)[offset];
v0.x = input.getFloatValue(index);
v0.y = output.getStringArrayData(index)[offset];
Point2F v3;
v3.x = mInput.getFloatValue(index + 1);
v3.y = mOutput.getStringArrayData(index + 1)[offset];
v3.x = input.getFloatValue(index + 1);
v3.y = output.getStringArrayData(index + 1)[offset];
// If spline interpolation is specified but the tangents are not available,
// default to LINEAR.
const char* interp_method = mInterpolation.getStringValue(index);
const char* interp_method = interpolation.getStringValue(index);
if (dStrEqual(interp_method, "BEZIER") ||
dStrEqual(interp_method, "HERMITE") ||
dStrEqual(interp_method, "CARDINAL")) {
const double* inArray = mInTangent.getStringArrayData(index + 1);
const double* outArray = mOutTangent.getStringArrayData(index);
const double* inArray = inTangent.getStringArrayData(index + 1);
const double* outArray = outTangent.getStringArrayData(index);
if (!inArray || !outArray)
interp_method = "LINEAR";
}
@ -398,17 +398,17 @@ void AnimData::interpValue(F32 t, U32 offset, double* value) const
v2 = v3;
if (index > 0) {
v0.x = mInput.getFloatValue(index-1);
v0.y = mOutput.getStringArrayData(index-1)[offset];
v0.x = input.getFloatValue(index-1);
v0.y = output.getStringArrayData(index-1)[offset];
}
else {
// mirror P1 through P0
v0 = v1 + (v1 - v2);
}
if (index < (mInput.size()-2)) {
v3.x = mInput.getFloatValue(index+2);
v3.y = mOutput.getStringArrayData(index+2)[offset];
if (index < (input.size()-2)) {
v3.x = input.getFloatValue(index+2);
v3.y = output.getStringArrayData(index+2)[offset];
}
else {
// mirror P0 through P1
@ -416,10 +416,10 @@ void AnimData::interpValue(F32 t, U32 offset, double* value) const
}
}
else {
const double* inArray = mInTangent.getStringArrayData(index + 1);
const double* outArray = mOutTangent.getStringArrayData(index);
const double* inArray = inTangent.getStringArrayData(index + 1);
const double* outArray = outTangent.getStringArrayData(index);
if (mOutput.stride() == mInTangent.stride()) {
if (output.stride() == inTangent.stride()) {
// This degenerate form (1D control points) does 2 things wrong:
// 1) it does not specify the key (time) value
// 2) the control point is specified as a tangent for both bezier and hermite
@ -458,27 +458,27 @@ void AnimData::interpValue(F32 t, U32 offset, double* value) const
void AnimData::interpValue(F32 t, U32 offset, const char** value) const
{
if (mInput.size() == 0)
if (input.size() == 0)
*value = "";
else if (mInput.size() == 1)
*value = mOutput.getStringValue(0);
else if (input.size() == 1)
*value = output.getStringValue(0);
else
{
// clamp time to valid range
F32 curveStart = mInput.getFloatValue(0);
F32 curveEnd = mInput.getFloatValue(mInput.size()-1);
F32 curveStart = input.getFloatValue(0);
F32 curveEnd = input.getFloatValue(input.size()-1);
t = mClampF(t, curveStart, curveEnd);
// find the index of the input keyframe BEFORE 't'
S32 index;
for (index = 0; index < mInput.size()-2; index++) {
if (mInput.getFloatValue(index + 1) > t)
for (index = 0; index < input.size()-2; index++) {
if (input.getFloatValue(index + 1) > t)
break;
}
// String values only support STEP interpolation, so just get the
// value at the input keyframe
*value = mOutput.getStringValue(index);
*value = output.getStringValue(index);
}
}

View file

@ -76,20 +76,20 @@ namespace ColladaUtils
NumLodTypes
};
domUpAxisType mUpAxis; // Override for the collada <up_axis> element
F32 mUnit; // Override for the collada <unit> element
eLodType mLodType; // LOD type option
S32 mSingleDetailSize; // Detail size for all meshes in the model
String mMatNamePrefix; // Prefix to apply to collada material names
String mAlwaysImport; // List of node names (with wildcards) to import, even if in the neverImport list
String mNeverImport; // List of node names (with wildcards) to ignore on loading
String mAlwaysImportMesh; // List of mesh names (with wildcards) to import, even if in the neverImportMesh list
String mNeverImportMesh; // List of mesh names (with wildcards) to ignore on loading
bool mIgnoreNodeScale; // Ignore <scale> elements in <node>s
bool mAdjustCenter; // Translate model so origin is at the center
bool mAdjustFloor; // Translate model so origin is at the bottom
bool mForceUpdateMaterials; // Force update of materials.cs
bool mUseDiffuseNames; // Use diffuse texture as the material name
domUpAxisType upAxis; // Override for the collada <up_axis> element
F32 unit; // Override for the collada <unit> element
eLodType lodType; // LOD type option
S32 singleDetailSize; // Detail size for all meshes in the model
String matNamePrefix; // Prefix to apply to collada material names
String alwaysImport; // List of node names (with wildcards) to import, even if in the neverImport list
String neverImport; // List of node names (with wildcards) to ignore on loading
String alwaysImportMesh; // List of mesh names (with wildcards) to import, even if in the neverImportMesh list
String neverImportMesh; // List of mesh names (with wildcards) to ignore on loading
bool ignoreNodeScale; // Ignore <scale> elements in <node>s
bool adjustCenter; // Translate model so origin is at the center
bool adjustFloor; // Translate model so origin is at the bottom
bool forceUpdateMaterials; // Force update of materials.cs
bool useDiffuseNames; // Use diffuse texture as the material name
ImportOptions()
{
@ -98,20 +98,20 @@ namespace ColladaUtils
void reset()
{
mUpAxis = UPAXISTYPE_COUNT;
mUnit = -1.0f;
mLodType = DetectDTS;
mSingleDetailSize = 2;
mMatNamePrefix = "";
mAlwaysImport = "";
mNeverImport = "";
mAlwaysImportMesh = "";
mNeverImportMesh = "";
mIgnoreNodeScale = false;
mAdjustCenter = false;
mAdjustFloor = false;
mForceUpdateMaterials = false;
mUseDiffuseNames = false;
upAxis = UPAXISTYPE_COUNT;
unit = -1.0f;
lodType = DetectDTS;
singleDetailSize = 2;
matNamePrefix = "";
alwaysImport = "";
neverImport = "";
alwaysImportMesh = "";
neverImportMesh = "";
ignoreNodeScale = false;
adjustCenter = false;
adjustFloor = false;
forceUpdateMaterials = false;
useDiffuseNames = false;
}
};
@ -291,27 +291,27 @@ template<> inline const char* _GetNameOrId(const domInstance_controller* element
// is done until we actually try to extract values from the source.
class _SourceReader
{
const domSource* mSource; // the wrapped Collada source
const domAccessor* mAccessor; // shortcut to the source accessor
Vector<U32> mOffsets; // offset of each of the desired values to pull from the source array
const domSource* source; // the wrapped Collada source
const domAccessor* accessor; // shortcut to the source accessor
Vector<U32> offsets; // offset of each of the desired values to pull from the source array
public:
_SourceReader() : mSource(0), mAccessor(0) {}
_SourceReader() : source(0), accessor(0) {}
void reset()
{
mSource = 0;
mAccessor = 0;
mOffsets.clear();
source = 0;
accessor = 0;
offsets.clear();
}
//------------------------------------------------------
// Initialize the _SourceReader object
bool initFromSource(const domSource* src, const char* paramNames[] = 0)
{
mSource = src;
mAccessor = mSource->getTechnique_common()->getAccessor();
mOffsets.clear();
source = src;
accessor = source->getTechnique_common()->getAccessor();
offsets.clear();
// The source array has groups of values in a 1D stream => need to map the
// input param names to source params to determine the offset within the
@ -319,11 +319,11 @@ public:
U32 paramCount = 0;
while (paramNames && paramNames[paramCount][0]) {
// lookup the index of the source param that matches the input param
mOffsets.push_back(paramCount);
for (U32 iParam = 0; iParam < mAccessor->getParam_array().getCount(); iParam++) {
if (mAccessor->getParam_array()[iParam]->getName() &&
dStrEqual(mAccessor->getParam_array()[iParam]->getName(), paramNames[paramCount])) {
mOffsets.last() = iParam;
offsets.push_back(paramCount);
for (U32 iParam = 0; iParam < accessor->getParam_array().getCount(); iParam++) {
if (accessor->getParam_array()[iParam]->getName() &&
dStrEqual(accessor->getParam_array()[iParam]->getName(), paramNames[paramCount])) {
offsets.last() = iParam;
break;
}
}
@ -331,9 +331,9 @@ public:
}
// If no input params were specified, just map the source params directly
if (!mOffsets.size()) {
for (S32 iParam = 0; iParam < mAccessor->getParam_array().getCount(); iParam++)
mOffsets.push_back(iParam);
if (!offsets.size()) {
for (S32 iParam = 0; iParam < accessor->getParam_array().getCount(); iParam++)
offsets.push_back(iParam);
}
return true;
@ -341,10 +341,10 @@ public:
//------------------------------------------------------
// Shortcut to the size of the array (should be the number of destination objects)
S32 size() const { return mAccessor ? mAccessor->getCount() : 0; }
S32 size() const { return accessor ? accessor->getCount() : 0; }
// Get the number of elements per group in the source
S32 stride() const { return mAccessor ? mAccessor->getStride() : 0; }
S32 stride() const { return accessor ? accessor->getStride() : 0; }
//------------------------------------------------------
// Get a pointer to the start of a group of values (index advances by stride)
@ -353,8 +353,8 @@ public:
const double* getStringArrayData(S32 index) const
{
if ((index >= 0) && (index < size())) {
if (mSource->getFloat_array())
return &mSource->getFloat_array()->getValue()[index*stride()];
if (source->getFloat_array())
return &source->getFloat_array()->getValue()[index*stride()];
}
return 0;
}
@ -367,10 +367,10 @@ public:
{
if ((index >= 0) && (index < size())) {
// could be plain strings or IDREFs
if (mSource->getName_array())
return mSource->getName_array()->getValue()[index*stride()];
else if (mSource->getIDREF_array())
return mSource->getIDREF_array()->getValue()[index*stride()].getID();
if (source->getName_array())
return source->getName_array()->getValue()[index*stride()];
else if (source->getIDREF_array())
return source->getIDREF_array()->getValue()[index*stride()].getID();
}
return "";
}
@ -379,7 +379,7 @@ public:
{
F32 value(0);
if (const double* data = getStringArrayData(index))
return data[mOffsets[0]];
return data[offsets[0]];
return value;
}
@ -387,7 +387,7 @@ public:
{
Point2F value(0, 0);
if (const double* data = getStringArrayData(index))
value.set(data[mOffsets[0]], data[mOffsets[1]]);
value.set(data[offsets[0]], data[offsets[1]]);
return value;
}
@ -395,7 +395,7 @@ public:
{
Point3F value(1, 0, 0);
if (const double* data = getStringArrayData(index))
value.set(data[mOffsets[0]], data[mOffsets[1]], data[mOffsets[2]]);
value.set(data[offsets[0]], data[offsets[1]], data[offsets[2]]);
return value;
}
@ -404,11 +404,11 @@ public:
ColorI value(255, 255, 255, 255);
if (const double* data = getStringArrayData(index))
{
value.red = data[mOffsets[0]] * 255.0;
value.green = data[mOffsets[1]] * 255.0;
value.blue = data[mOffsets[2]] * 255.0;
value.red = data[offsets[0]] * 255.0;
value.green = data[offsets[1]] * 255.0;
value.blue = data[offsets[2]] * 255.0;
if ( stride() == 4 )
value.alpha = data[mOffsets[3]] * 255.0;
value.alpha = data[offsets[3]] * 255.0;
}
return value;
}
@ -477,14 +477,14 @@ public:
/// Template child class for supported Collada primitive elements
template<class T> class ColladaPrimitive : public BasePrimitive
{
T* mPrimitive;
domListOfUInts *mTriangleData;
T* primitive;
domListOfUInts *pTriangleData;
S32 stride;
public:
ColladaPrimitive(const daeElement* e) : mTriangleData(0)
ColladaPrimitive(const daeElement* e) : pTriangleData(0)
{
// Cast to geometric primitive element
mPrimitive = daeSafeCast<T>(const_cast<daeElement*>(e));
primitive = daeSafeCast<T>(const_cast<daeElement*>(e));
// Determine stride
stride = 0;
@ -495,13 +495,13 @@ public:
}
~ColladaPrimitive()
{
delete mTriangleData;
delete pTriangleData;
}
/// Most primitives can use these common implementations
const char* getElementName() { return mPrimitive->getElementName(); }
const char* getMaterial() { return mPrimitive->getMaterial(); }
const domInputLocalOffset_Array& getInputs() { return mPrimitive->getInput_array(); }
const char* getElementName() { return primitive->getElementName(); }
const char* getMaterial() { return primitive->getMaterial(); }
const domInputLocalOffset_Array& getInputs() { return primitive->getInput_array(); }
S32 getStride() const { return stride; }
/// Each supported primitive needs to implement this method (and convert
@ -514,21 +514,21 @@ public:
template<> inline const domListOfUInts *ColladaPrimitive<domTriangles>::getTriangleData()
{
// Return the <p> integer list directly
return (mPrimitive->getP() ? &(mPrimitive->getP()->getValue()) : NULL);
return (primitive->getP() ? &(primitive->getP()->getValue()) : NULL);
}
//-----------------------------------------------------------------------------
// <tristrips>
template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert strips to triangles
mTriangleData = new domListOfUInts();
pTriangleData = new domListOfUInts();
for (S32 iStrip = 0; iStrip < mPrimitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
domP* P = mPrimitive->getP_array()[iStrip];
domP* P = primitive->getP_array()[iStrip];
// Ignore invalid P arrays
if (!P || !P->getValue().getCount())
@ -543,33 +543,33 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTristrips>::getTrian
if (iTri & 0x1)
{
// CW triangle
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride, v0 + 2*stride);
mTriangleData->appendArray(stride, v0 + stride);
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride, v0 + 2*stride);
pTriangleData->appendArray(stride, v0 + stride);
}
else
{
// CCW triangle
mTriangleData->appendArray(stride*3, v0);
pTriangleData->appendArray(stride*3, v0);
}
}
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
// <trifans>
template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert strips to triangles
mTriangleData = new domListOfUInts();
pTriangleData = new domListOfUInts();
for (S32 iStrip = 0; iStrip < mPrimitive->getCount(); iStrip++) {
for (S32 iStrip = 0; iStrip < primitive->getCount(); iStrip++) {
domP* P = mPrimitive->getP_array()[iStrip];
domP* P = primitive->getP_array()[iStrip];
// Ignore invalid P arrays
if (!P || !P->getValue().getCount())
@ -581,27 +581,27 @@ template<> inline const domListOfUInts *ColladaPrimitive<domTrifans>::getTriangl
// Convert the fan back to a triangle list
domUint* v0 = pSrcData + stride;
for (S32 iTri = 0; iTri < numTriangles; iTri++, v0 += stride) {
mTriangleData->appendArray(stride, pSrcData); // shared vertex
mTriangleData->appendArray(stride, v0); // previous vertex
mTriangleData->appendArray(stride, v0+stride); // current vertex
pTriangleData->appendArray(stride, pSrcData); // shared vertex
pTriangleData->appendArray(stride, v0); // previous vertex
pTriangleData->appendArray(stride, v0+stride); // current vertex
}
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
// <polygons>
template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert polygons to triangles
mTriangleData = new domListOfUInts();
pTriangleData = new domListOfUInts();
for (S32 iPoly = 0; iPoly < mPrimitive->getCount(); iPoly++) {
for (S32 iPoly = 0; iPoly < primitive->getCount(); iPoly++) {
domP* P = mPrimitive->getP_array()[iPoly];
domP* P = primitive->getP_array()[iPoly];
// Ignore invalid P arrays
if (!P || !P->getValue().getCount())
@ -615,41 +615,41 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolygons>::getTriang
domUint* v0 = pSrcData;
pSrcData += stride;
for (S32 iTri = 0; iTri < numPoints-2; iTri++) {
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride*2, pSrcData);
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
}
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
// <polylist>
template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriangleData()
{
if (!mTriangleData)
if (!pTriangleData)
{
// Convert polygons to triangles
mTriangleData = new domListOfUInts();
pTriangleData = new domListOfUInts();
// Check that the P element has the right number of values (this
// has been seen with certain models exported using COLLADAMax)
const domListOfUInts& vcount = mPrimitive->getVcount()->getValue();
const domListOfUInts& vcount = primitive->getVcount()->getValue();
U32 expectedCount = 0;
for (S32 iPoly = 0; iPoly < vcount.getCount(); iPoly++)
expectedCount += vcount[iPoly];
expectedCount *= stride;
if (!mPrimitive->getP() || !mPrimitive->getP()->getValue().getCount() ||
(mPrimitive->getP()->getValue().getCount() != expectedCount) )
if (!primitive->getP() || !primitive->getP()->getValue().getCount() ||
(primitive->getP()->getValue().getCount() != expectedCount) )
{
Con::warnf("<polylist> element found with invalid <p> array. This primitive will be ignored.");
return mTriangleData;
return pTriangleData;
}
domUint* pSrcData = &(mPrimitive->getP()->getValue()[0]);
domUint* pSrcData = &(primitive->getP()->getValue()[0]);
for (S32 iPoly = 0; iPoly < vcount.getCount(); iPoly++) {
// Use a simple tri-fan (centered at the first point) method of
@ -657,14 +657,14 @@ template<> inline const domListOfUInts *ColladaPrimitive<domPolylist>::getTriang
domUint* v0 = pSrcData;
pSrcData += stride;
for (S32 iTri = 0; iTri < vcount[iPoly]-2; iTri++) {
mTriangleData->appendArray(stride, v0);
mTriangleData->appendArray(stride*2, pSrcData);
pTriangleData->appendArray(stride, v0);
pTriangleData->appendArray(stride*2, pSrcData);
pSrcData += stride;
}
pSrcData += stride;
}
}
return mTriangleData;
return pTriangleData;
}
//-----------------------------------------------------------------------------
@ -680,32 +680,32 @@ template<> inline F32 convert(const char* value) { return convert<double>(value)
/// Collada animation data
struct AnimChannels : public Vector<struct AnimData*>
{
daeElement *mElement;
AnimChannels(daeElement* el) : mElement(el)
daeElement *element;
AnimChannels(daeElement* el) : element(el)
{
mElement->setUserData(this);
element->setUserData(this);
}
~AnimChannels()
{
if (mElement)
mElement->setUserData(0);
if (element)
element->setUserData(0);
}
};
struct AnimData
{
bool mEnabled; ///!< Used to select animation channels for the current clip
bool enabled; ///!< Used to select animation channels for the current clip
_SourceReader mInput;
_SourceReader mOutput;
_SourceReader input;
_SourceReader output;
_SourceReader mInTangent;
_SourceReader mOutTangent;
_SourceReader inTangent;
_SourceReader outTangent;
_SourceReader mInterpolation;
_SourceReader interpolation;
U32 mTargetValueOffset; ///< Offset into the target element (for arrays of values)
U32 mTargetValueCount; ///< Number of values animated (from OUTPUT source array)
U32 targetValueOffset; ///< Offset into the target element (for arrays of values)
U32 targetValueCount; ///< Number of values animated (from OUTPUT source array)
/// Get the animation channels for the Collada element (if any)
static AnimChannels* getAnimChannels(const daeElement* element)
@ -713,7 +713,7 @@ struct AnimData
return element ? (AnimChannels*)const_cast<daeElement*>(element)->getUserData() : 0;
}
AnimData() : mEnabled(false) { }
AnimData() : enabled(false) { }
void parseTargetString(const char* target, S32 fullCount, const char* elements[]);
@ -737,13 +737,13 @@ struct AnimData
template<class T>
struct AnimatedElement
{
const daeElement* mElement; ///< The Collada element (can be NULL)
T mDefaultVal; ///< Default value (used when element is NULL)
const daeElement* element; ///< The Collada element (can be NULL)
T defaultVal; ///< Default value (used when element is NULL)
AnimatedElement(const daeElement* e=0) : mElement(e) { }
AnimatedElement(const daeElement* e=0) : element(e) { }
/// Check if the element has any animations channels
bool isAnimated() { return (AnimData::getAnimChannels(mElement) != 0); }
bool isAnimated() { return (AnimData::getAnimChannels(element) != 0); }
bool isAnimated(F32 start, F32 end) { return isAnimated(); }
/// Get the value of the element at the specified time
@ -751,17 +751,17 @@ struct AnimatedElement
{
// If the element is NULL, just use the default (handy for <extra> profiles which
// may or may not be present in the document)
T value(mDefaultVal);
if (const domAny* param = daeSafeCast<domAny>(const_cast<daeElement*>(mElement))) {
T value(defaultVal);
if (const domAny* param = daeSafeCast<domAny>(const_cast<daeElement*>(element))) {
// If the element is not animated, just use its current value
value = convert<T>(param->getValue());
// Animate the value
const AnimChannels* channels = AnimData::getAnimChannels(mElement);
const AnimChannels* channels = AnimData::getAnimChannels(element);
if (channels && (time >= 0)) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->mEnabled)
if (animData->enabled)
animData->interpValue(time, 0, &value);
}
}
@ -781,19 +781,19 @@ template<class T> struct AnimatedElementList : public AnimatedElement<T>
// Get the value of the element list at the specified time
T getValue(F32 time)
{
T vec(this->mDefaultVal);
if (this->mElement) {
T vec(this->defaultVal);
if (this->element) {
// Get a copy of the vector
vec = *(T*)const_cast<daeElement*>(this->mElement)->getValuePointer();
vec = *(T*)const_cast<daeElement*>(this->element)->getValuePointer();
// Animate the vector
const AnimChannels* channels = AnimData::getAnimChannels(this->mElement);
const AnimChannels* channels = AnimData::getAnimChannels(this->element);
if (channels && (time >= 0)) {
for (S32 iChannel = 0; iChannel < channels->size(); iChannel++) {
const AnimData* animData = (*channels)[iChannel];
if (animData->mEnabled) {
for (S32 iValue = 0; iValue < animData->mTargetValueCount; iValue++)
animData->interpValue(time, iValue, &vec[animData->mTargetValueOffset + iValue]);
if (animData->enabled) {
for (S32 iValue = 0; iValue < animData->targetValueCount; iValue++)
animData->interpValue(time, iValue, &vec[animData->targetValueOffset + iValue]);
}
}
}