mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Revert "collada/ts chain shadowvar and member var clenaups"
This reverts commit 3ce15b33eb.
This commit is contained in:
parent
43c3f75b14
commit
c84bd23e17
|
|
@ -147,12 +147,12 @@ private:
|
|||
end = start;
|
||||
|
||||
// Get the set for this input
|
||||
domInputLocalOffset* localOffset = daeSafeCast<domInputLocalOffset>(input);
|
||||
const domInputLocalOffset* localOffset = daeSafeCast<domInputLocalOffset>(input);
|
||||
domUint newSet = localOffset ? localOffset->getSet() : 0;
|
||||
|
||||
// Add the input to the right place in the list (somewhere between start and end)
|
||||
for (S32 i = start; i <= end; i++) {
|
||||
localOffset = daeSafeCast<domInputLocalOffset>(sortedInputs[i]);
|
||||
const domInputLocalOffset* localOffset = daeSafeCast<domInputLocalOffset>(sortedInputs[i]);
|
||||
domUint set = localOffset ? localOffset->getSet() : 0xFFFFFFFF;
|
||||
if (newSet < set) {
|
||||
for (S32 j = i + 1; j <= end; j++)
|
||||
|
|
@ -181,10 +181,10 @@ private:
|
|||
const char* semantic = SourceTypeToSemantic( type );
|
||||
for (S32 iInput = 0; iInput < vertices->getInput_array().getCount(); iInput++)
|
||||
{
|
||||
domInputLocal* vInput = vertices->getInput_array().get(iInput);
|
||||
if (dStrEqual(vInput->getSemantic(), semantic))
|
||||
domInputLocal* input = vertices->getInput_array().get(iInput);
|
||||
if (dStrEqual(input->getSemantic(), semantic))
|
||||
{
|
||||
source = daeSafeCast<domSource>(findInputSource(vInput));
|
||||
source = daeSafeCast<domSource>(findInputSource(input));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -966,7 +966,7 @@ void ColladaAppMesh::lookupSkinData()
|
|||
// Determine the offset into the vindices array for each vertex (since each
|
||||
// vertex may have multiple [bone, weight] pairs in the array)
|
||||
Vector<U32> vindicesOffset;
|
||||
domInt* vindices = (domInt*)weights_v.getRaw(0);
|
||||
const domInt* vindices = (domInt*)weights_v.getRaw(0);
|
||||
for (S32 iWeight = 0; iWeight < weights_vcount.getCount(); iWeight++) {
|
||||
// Store the offset into the vindices array for this vertex
|
||||
vindicesOffset.push_back(vindices - (domInt*)weights_v.getRaw(0));
|
||||
|
|
@ -977,7 +977,7 @@ void ColladaAppMesh::lookupSkinData()
|
|||
bool tooManyWeightsWarning = false;
|
||||
for (S32 iVert = 0; iVert < vertsPerFrame; iVert++) {
|
||||
const domUint* vcount = (domUint*)weights_vcount.getRaw(0);
|
||||
vindices = (domInt*)weights_v.getRaw(0);
|
||||
const domInt* vindices = (domInt*)weights_v.getRaw(0);
|
||||
vindices += vindicesOffset[vertTuples[iVert].vertex];
|
||||
|
||||
S32 nonZeroWeightCount = 0;
|
||||
|
|
|
|||
|
|
@ -120,9 +120,9 @@ static void processNode(GuiTreeViewCtrl* tree, domNode* node, S32 parentID, Scen
|
|||
for (S32 i = 0; i < node->getInstance_node_array().getCount(); i++)
|
||||
{
|
||||
domInstance_node* instnode = node->getInstance_node_array()[i];
|
||||
domNode* dNode = daeSafeCast<domNode>(instnode->getUrl().getElement());
|
||||
if (dNode)
|
||||
processNode(tree, dNode, nodeID, stats);
|
||||
domNode* node = daeSafeCast<domNode>(instnode->getUrl().getElement());
|
||||
if (node)
|
||||
processNode(tree, node, nodeID, stats);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
|
|
@ -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" ) );
|
||||
|
|
@ -354,7 +354,7 @@ void ColladaShapeLoader::computeBounds(Box3F& bounds)
|
|||
ColladaUtils::getOptions().adjustFloor) )
|
||||
{
|
||||
// Compute shape offset
|
||||
Point3F shapeOffset = Point3F::Zero;
|
||||
Point3F shapeOffset = Point3F::Zero;
|
||||
if ( ColladaUtils::getOptions().adjustCenter )
|
||||
{
|
||||
bounds.getCenter( &shapeOffset );
|
||||
|
|
@ -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->nodes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < shape->nodes.size(); iNode++)
|
||||
{
|
||||
if ( !mAppNodes[iNode]->isParentRoot() )
|
||||
if ( !appNodes[iNode]->isParentRoot() )
|
||||
continue;
|
||||
|
||||
// Adjust default translation
|
||||
mShape->defaultTranslations[iNode] += shapeOffset;
|
||||
shape->defaultTranslations[iNode] += shapeOffset;
|
||||
|
||||
// Adjust animated translations
|
||||
for (S32 iSeq = 0; iSeq < mShape->sequences.size(); iSeq++)
|
||||
for (S32 iSeq = 0; iSeq < shape->sequences.size(); iSeq++)
|
||||
{
|
||||
const TSShape::Sequence& seq = mShape->sequences[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->nodeTranslations[index] += shapeOffset;
|
||||
shape->nodeTranslations[index] += shapeOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,10 +266,10 @@ void AnimData::parseTargetString(const char* target, S32 fullCount, const char*
|
|||
targetValueCount = 1;
|
||||
}
|
||||
}
|
||||
else if (const char* p2 = dStrrchr(target, '.')) {
|
||||
else if (const char* p = dStrrchr(target, '.')) {
|
||||
// Check for named elements
|
||||
for (S32 iElem = 0; elements[iElem][0] != 0; iElem++) {
|
||||
if (!dStrcmp(p2, elements[iElem])) {
|
||||
if (!dStrcmp(p, elements[iElem])) {
|
||||
targetValueOffset = iElem;
|
||||
targetValueCount = 1;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const F32 TSShapeLoader::DefaultTime = -1.0f;
|
|||
const F64 TSShapeLoader::MinFrameRate = 15.0f;
|
||||
const F64 TSShapeLoader::MaxFrameRate = 60.0f;
|
||||
const F64 TSShapeLoader::AppGroundFrameRate = 10.0f;
|
||||
Torque::Path TSShapeLoader::mShapePath;
|
||||
Torque::Path TSShapeLoader::shapePath;
|
||||
|
||||
Vector<TSShapeLoader::ShapeFormat> TSShapeLoader::smFormats;
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ MatrixF TSShapeLoader::getLocalNodeMatrix(AppNode* node, F32 t)
|
|||
|
||||
if (node->mParentIndex >= 0)
|
||||
{
|
||||
AppNode *parent = mAppNodes[node->mParentIndex];
|
||||
AppNode *parent = appNodes[node->mParentIndex];
|
||||
|
||||
MatrixF m2 = parent->getNodeTransform(t);
|
||||
|
||||
|
|
@ -84,10 +84,10 @@ MatrixF TSShapeLoader::getLocalNodeMatrix(AppNode* node, F32 t)
|
|||
// get local transform by pre-multiplying by inverted parent transform
|
||||
m1 = m2.inverse() * m1;
|
||||
}
|
||||
else if (mBoundsNode && node != mBoundsNode)
|
||||
else if (boundsNode && node != boundsNode)
|
||||
{
|
||||
// make transform relative to bounds node transform at time=t
|
||||
MatrixF mb = mBoundsNode->getNodeTransform(t);
|
||||
MatrixF mb = boundsNode->getNodeTransform(t);
|
||||
zapScale(mb);
|
||||
m1 = mb.inverse() * m1;
|
||||
}
|
||||
|
|
@ -133,22 +133,22 @@ void TSShapeLoader::updateProgress(S32 major, const char* msg, S32 numMinor, S32
|
|||
|
||||
TSShape* TSShapeLoader::generateShape(const Torque::Path& path)
|
||||
{
|
||||
mShapePath = path;
|
||||
mShape = new TSShape();
|
||||
shapePath = path;
|
||||
shape = new TSShape();
|
||||
|
||||
mShape->mExporterVersion = 124;
|
||||
mShape->mSmallestVisibleSize = 999999;
|
||||
mShape->mSmallestVisibleDL = 0;
|
||||
mShape->mReadVersion = 24;
|
||||
mShape->mFlags = 0;
|
||||
mShape->mSequencesConstructed = 0;
|
||||
shape->mExporterVersion = 124;
|
||||
shape->mSmallestVisibleSize = 999999;
|
||||
shape->mSmallestVisibleDL = 0;
|
||||
shape->mReadVersion = 24;
|
||||
shape->mFlags = 0;
|
||||
shape->mSequencesConstructed = 0;
|
||||
|
||||
// Get all nodes, objects and sequences in the shape
|
||||
updateProgress(Load_EnumerateScene, "Enumerating scene...");
|
||||
enumerateScene();
|
||||
if (!mSubshapes.size())
|
||||
if (!subshapes.size())
|
||||
{
|
||||
delete mShape;
|
||||
delete shape;
|
||||
Con::errorf("Failed to load shape \"%s\", no subshapes found", path.getFullPath().c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ TSShape* TSShapeLoader::generateShape(const Torque::Path& path)
|
|||
// Install the TS memory helper into a TSShape object.
|
||||
install();
|
||||
|
||||
return mShape;
|
||||
return shape;
|
||||
}
|
||||
|
||||
bool TSShapeLoader::processNode(AppNode* node)
|
||||
|
|
@ -186,20 +186,20 @@ bool TSShapeLoader::processNode(AppNode* node)
|
|||
// Detect bounds node
|
||||
if ( node->isBounds() )
|
||||
{
|
||||
if ( mBoundsNode )
|
||||
if ( boundsNode )
|
||||
{
|
||||
Con::warnf( "More than one bounds node found" );
|
||||
return false;
|
||||
}
|
||||
mBoundsNode = node;
|
||||
boundsNode = node;
|
||||
|
||||
// Process bounds geometry
|
||||
MatrixF boundsMat(mBoundsNode->getNodeTransform(DefaultTime));
|
||||
MatrixF boundsMat(boundsNode->getNodeTransform(DefaultTime));
|
||||
boundsMat.inverse();
|
||||
zapScale(boundsMat);
|
||||
for (S32 iMesh = 0; iMesh < mBoundsNode->getNumMesh(); iMesh++)
|
||||
for (S32 iMesh = 0; iMesh < boundsNode->getNumMesh(); iMesh++)
|
||||
{
|
||||
AppMesh* mesh = mBoundsNode->getMesh(iMesh);
|
||||
AppMesh* mesh = boundsNode->getMesh(iMesh);
|
||||
MatrixF transform = mesh->getMeshTransform(DefaultTime);
|
||||
transform.mulL(boundsMat);
|
||||
mesh->lockMesh(DefaultTime, transform);
|
||||
|
|
@ -215,10 +215,10 @@ bool TSShapeLoader::processNode(AppNode* node)
|
|||
}
|
||||
|
||||
// Add this node to the subshape (create one if needed)
|
||||
if (mSubshapes.size() == 0 )
|
||||
mSubshapes.push_back( new TSShapeLoader::Subshape );
|
||||
if ( subshapes.size() == 0 )
|
||||
subshapes.push_back( new TSShapeLoader::Subshape );
|
||||
|
||||
mSubshapes.last()->branches.push_back( node );
|
||||
subshapes.last()->branches.push_back( node );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -263,8 +263,8 @@ void TSShapeLoader::recurseSubshape(AppNode* appNode, S32 parentIndex, bool recu
|
|||
if (appNode->isBounds())
|
||||
return;
|
||||
|
||||
S32 subShapeNum = mShape->subShapeFirstNode.size()-1;
|
||||
Subshape* subshape = mSubshapes[subShapeNum];
|
||||
S32 subShapeNum = shape->subShapeFirstNode.size()-1;
|
||||
Subshape* subshape = subshapes[subShapeNum];
|
||||
|
||||
// Check if we should collapse this node
|
||||
S32 myIndex;
|
||||
|
|
@ -275,16 +275,16 @@ void TSShapeLoader::recurseSubshape(AppNode* appNode, S32 parentIndex, bool recu
|
|||
else
|
||||
{
|
||||
// Check that adding this node will not exceed the maximum node count
|
||||
if (mShape->nodes.size() >= MAX_TS_SET_SIZE)
|
||||
if (shape->nodes.size() >= MAX_TS_SET_SIZE)
|
||||
return;
|
||||
|
||||
myIndex = mShape->nodes.size();
|
||||
String nodeName = getUniqueName(appNode->getName(), cmpShapeName, mShape->names);
|
||||
myIndex = shape->nodes.size();
|
||||
String nodeName = getUniqueName(appNode->getName(), cmpShapeName, shape->names);
|
||||
|
||||
// Create the 3space node
|
||||
mShape->nodes.increment();
|
||||
TSShape::Node& lastNode = mShape->nodes.last();
|
||||
lastNode.nameIndex = mShape->addName(nodeName);
|
||||
shape->nodes.increment();
|
||||
TSShape::Node& lastNode = shape->nodes.last();
|
||||
lastNode.nameIndex = shape->addName(nodeName);
|
||||
lastNode.parentIndex = parentIndex;
|
||||
lastNode.firstObject = -1;
|
||||
lastNode.firstChild = -1;
|
||||
|
|
@ -292,8 +292,8 @@ void TSShapeLoader::recurseSubshape(AppNode* appNode, S32 parentIndex, bool recu
|
|||
|
||||
// Add the AppNode to a matching list (so AppNodes can be accessed using 3space
|
||||
// node indices)
|
||||
mAppNodes.push_back(appNode);
|
||||
mAppNodes.last()->mParentIndex = parentIndex;
|
||||
appNodes.push_back(appNode);
|
||||
appNodes.last()->mParentIndex = parentIndex;
|
||||
|
||||
// Check for NULL detail or AutoBillboard nodes (no children or geometry)
|
||||
if ((appNode->getNumChildNodes() == 0) &&
|
||||
|
|
@ -304,7 +304,7 @@ void TSShapeLoader::recurseSubshape(AppNode* appNode, S32 parentIndex, bool recu
|
|||
|
||||
if (dStrEqual(dname, "nulldetail") && (size != 0x7FFFFFFF))
|
||||
{
|
||||
mShape->addDetail("detail", size, subShapeNum);
|
||||
shape->addDetail("detail", size, subShapeNum);
|
||||
}
|
||||
else if (appNode->isBillboard() && (size != 0x7FFFFFFF))
|
||||
{
|
||||
|
|
@ -323,9 +323,9 @@ void TSShapeLoader::recurseSubshape(AppNode* appNode, S32 parentIndex, bool recu
|
|||
appNode->getInt("BB::DIM", dim);
|
||||
appNode->getBool("BB::INCLUDE_POLES", includePoles);
|
||||
|
||||
S32 detIndex = mShape->addDetail( "bbDetail", size, -1 );
|
||||
S32 detIndex = shape->addDetail( "bbDetail", size, -1 );
|
||||
|
||||
TSShape::Detail& detIndexDetail = mShape->details[detIndex];
|
||||
TSShape::Detail& detIndexDetail = shape->details[detIndex];
|
||||
detIndexDetail.bbEquatorSteps = numEquatorSteps;
|
||||
detIndexDetail.bbPolarSteps = numPolarSteps;
|
||||
detIndexDetail.bbDetailLevel = dl;
|
||||
|
|
@ -357,23 +357,23 @@ void TSShapeLoader::recurseSubshape(AppNode* appNode, S32 parentIndex, bool recu
|
|||
|
||||
void TSShapeLoader::generateSubshapes()
|
||||
{
|
||||
for (U32 iSub = 0; iSub < mSubshapes.size(); iSub++)
|
||||
for (U32 iSub = 0; iSub < subshapes.size(); iSub++)
|
||||
{
|
||||
updateProgress(Load_GenerateSubshapes, "Generating subshapes...", mSubshapes.size(), iSub);
|
||||
updateProgress(Load_GenerateSubshapes, "Generating subshapes...", subshapes.size(), iSub);
|
||||
|
||||
Subshape* subshape = mSubshapes[iSub];
|
||||
Subshape* subshape = subshapes[iSub];
|
||||
|
||||
// Recurse through the node hierarchy, adding 3space nodes and
|
||||
// collecting geometry
|
||||
S32 firstNode = mShape->nodes.size();
|
||||
mShape->subShapeFirstNode.push_back(firstNode);
|
||||
S32 firstNode = shape->nodes.size();
|
||||
shape->subShapeFirstNode.push_back(firstNode);
|
||||
|
||||
for (U32 iBranch = 0; iBranch < subshape->branches.size(); iBranch++)
|
||||
recurseSubshape(subshape->branches[iBranch], -1, true);
|
||||
|
||||
mShape->subShapeNumNodes.push_back(mShape->nodes.size() - firstNode);
|
||||
shape->subShapeNumNodes.push_back(shape->nodes.size() - firstNode);
|
||||
|
||||
if (mShape->nodes.size() >= MAX_TS_SET_SIZE)
|
||||
if (shape->nodes.size() >= MAX_TS_SET_SIZE)
|
||||
{
|
||||
Con::warnf("Shape exceeds the maximum node count (%d). Ignoring additional nodes.",
|
||||
MAX_TS_SET_SIZE);
|
||||
|
|
@ -400,10 +400,10 @@ bool cmpMeshNameAndSize(const String& key, const Vector<String>& names, void* ar
|
|||
|
||||
void TSShapeLoader::generateObjects()
|
||||
{
|
||||
for (S32 iSub = 0; iSub < mSubshapes.size(); iSub++)
|
||||
for (S32 iSub = 0; iSub < subshapes.size(); iSub++)
|
||||
{
|
||||
Subshape* subshape = mSubshapes[iSub];
|
||||
mShape->subShapeFirstObject.push_back(mShape->objects.size());
|
||||
Subshape* subshape = subshapes[iSub];
|
||||
shape->subShapeFirstObject.push_back(shape->objects.size());
|
||||
|
||||
// Get the names and sizes of the meshes for this subshape
|
||||
Vector<String> meshNames;
|
||||
|
|
@ -464,18 +464,18 @@ void TSShapeLoader::generateObjects()
|
|||
|
||||
if (!lastName || (meshNames[iMesh] != *lastName))
|
||||
{
|
||||
mShape->objects.increment();
|
||||
TSShape::Object& lastObject = mShape->objects.last();
|
||||
lastObject.nameIndex = mShape->addName(meshNames[iMesh]);
|
||||
shape->objects.increment();
|
||||
TSShape::Object& lastObject = shape->objects.last();
|
||||
lastObject.nameIndex = shape->addName(meshNames[iMesh]);
|
||||
lastObject.nodeIndex = subshape->objNodes[iMesh];
|
||||
lastObject.startMeshIndex = mAppMeshes.size();
|
||||
lastObject.startMeshIndex = appMeshes.size();
|
||||
lastObject.numMeshes = 0;
|
||||
lastName = &meshNames[iMesh];
|
||||
}
|
||||
|
||||
// Add this mesh to the object
|
||||
mAppMeshes.push_back(mesh);
|
||||
mShape->objects.last().numMeshes++;
|
||||
appMeshes.push_back(mesh);
|
||||
shape->objects.last().numMeshes++;
|
||||
|
||||
// Set mesh flags
|
||||
mesh->flags = 0;
|
||||
|
|
@ -498,9 +498,9 @@ void TSShapeLoader::generateObjects()
|
|||
}
|
||||
|
||||
// Attempt to add the detail (will fail if it already exists)
|
||||
S32 oldNumDetails = mShape->details.size();
|
||||
mShape->addDetail(detailName, mesh->detailSize, iSub);
|
||||
if (mShape->details.size() > oldNumDetails)
|
||||
S32 oldNumDetails = shape->details.size();
|
||||
shape->addDetail(detailName, mesh->detailSize, iSub);
|
||||
if (shape->details.size() > oldNumDetails)
|
||||
{
|
||||
Con::warnf("Object mesh \"%s\" has no matching detail (\"%s%d\" has"
|
||||
" been added automatically)", mesh->getName(false), detailName, mesh->detailSize);
|
||||
|
|
@ -508,18 +508,18 @@ void TSShapeLoader::generateObjects()
|
|||
}
|
||||
|
||||
// Get object count for this subshape
|
||||
mShape->subShapeNumObjects.push_back(mShape->objects.size() - mShape->subShapeFirstObject.last());
|
||||
shape->subShapeNumObjects.push_back(shape->objects.size() - shape->subShapeFirstObject.last());
|
||||
}
|
||||
}
|
||||
|
||||
void TSShapeLoader::generateSkins()
|
||||
{
|
||||
Vector<AppMesh*> skins;
|
||||
for (S32 iObject = 0; iObject < mShape->objects.size(); iObject++)
|
||||
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
|
||||
{
|
||||
for (S32 iMesh = 0; iMesh < mShape->objects[iObject].numMeshes; iMesh++)
|
||||
for (S32 iMesh = 0; iMesh < shape->objects[iObject].numMeshes; iMesh++)
|
||||
{
|
||||
AppMesh* mesh = mAppMeshes[mShape->objects[iObject].startMeshIndex + iMesh];
|
||||
AppMesh* mesh = appMeshes[shape->objects[iObject].startMeshIndex + iMesh];
|
||||
if (mesh->isSkin())
|
||||
skins.push_back(mesh);
|
||||
}
|
||||
|
|
@ -543,12 +543,12 @@ void TSShapeLoader::generateSkins()
|
|||
{
|
||||
// Find the node that matches this bone
|
||||
skin->nodeIndex[iBone] = -1;
|
||||
for (S32 iNode = 0; iNode < mAppMeshes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
if (mAppNodes[iNode]->isEqual(skin->bones[iBone]))
|
||||
if (appNodes[iNode]->isEqual(skin->bones[iBone]))
|
||||
{
|
||||
delete skin->bones[iBone];
|
||||
skin->bones[iBone] = mAppNodes[iNode];
|
||||
skin->bones[iBone] = appNodes[iNode];
|
||||
skin->nodeIndex[iBone] = iNode;
|
||||
break;
|
||||
}
|
||||
|
|
@ -566,18 +566,18 @@ void TSShapeLoader::generateSkins()
|
|||
void TSShapeLoader::generateDefaultStates()
|
||||
{
|
||||
// Generate default object states (includes initial geometry)
|
||||
for (S32 iObject = 0; iObject < mShape->objects.size(); iObject++)
|
||||
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
|
||||
{
|
||||
updateProgress(Load_GenerateDefaultStates, "Generating initial mesh and node states...",
|
||||
mShape->objects.size(), iObject);
|
||||
shape->objects.size(), iObject);
|
||||
|
||||
TSShape::Object& obj = mShape->objects[iObject];
|
||||
TSShape::Object& obj = shape->objects[iObject];
|
||||
|
||||
// Calculate the objectOffset for each mesh at T=0
|
||||
for (S32 iMesh = 0; iMesh < obj.numMeshes; iMesh++)
|
||||
{
|
||||
AppMesh* appMesh = mAppMeshes[obj.startMeshIndex + iMesh];
|
||||
AppNode* appNode = obj.nodeIndex >= 0 ? mAppNodes[obj.nodeIndex] : mBoundsNode;
|
||||
AppMesh* appMesh = appMeshes[obj.startMeshIndex + iMesh];
|
||||
AppNode* appNode = obj.nodeIndex >= 0 ? appNodes[obj.nodeIndex] : boundsNode;
|
||||
|
||||
MatrixF meshMat(appMesh->getMeshTransform(DefaultTime));
|
||||
MatrixF nodeMat(appMesh->isSkin() ? meshMat : appNode->getNodeTransform(DefaultTime));
|
||||
|
|
@ -587,16 +587,16 @@ void TSShapeLoader::generateDefaultStates()
|
|||
appMesh->objectOffset = nodeMat.inverse() * meshMat;
|
||||
}
|
||||
|
||||
generateObjectState(mShape->objects[iObject], DefaultTime, true, true);
|
||||
generateObjectState(shape->objects[iObject], DefaultTime, true, true);
|
||||
}
|
||||
|
||||
// Generate default node transforms
|
||||
for (S32 iNode = 0; iNode < mAppNodes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
// Determine the default translation and rotation for the node
|
||||
QuatF rot, srot;
|
||||
Point3F trans, scale;
|
||||
generateNodeTransform(mAppNodes[iNode], DefaultTime, false, 0, rot, trans, srot, scale);
|
||||
generateNodeTransform(appNodes[iNode], DefaultTime, false, 0, rot, trans, srot, scale);
|
||||
|
||||
// Add default node translation and rotation
|
||||
addNodeRotation(rot, true);
|
||||
|
|
@ -606,20 +606,20 @@ void TSShapeLoader::generateDefaultStates()
|
|||
|
||||
void TSShapeLoader::generateObjectState(TSShape::Object& obj, F32 t, bool addFrame, bool addMatFrame)
|
||||
{
|
||||
mShape->objectStates.increment();
|
||||
TSShape::ObjectState& state = mShape->objectStates.last();
|
||||
shape->objectStates.increment();
|
||||
TSShape::ObjectState& state = shape->objectStates.last();
|
||||
|
||||
state.frameIndex = 0;
|
||||
state.matFrameIndex = 0;
|
||||
state.vis = mClampF(mAppMeshes[obj.startMeshIndex]->getVisValue(t), 0.0f, 1.0f);
|
||||
state.vis = mClampF(appMeshes[obj.startMeshIndex]->getVisValue(t), 0.0f, 1.0f);
|
||||
|
||||
if (addFrame || addMatFrame)
|
||||
{
|
||||
generateFrame(obj, t, addFrame, addMatFrame);
|
||||
|
||||
// set the frame number for the object state
|
||||
state.frameIndex = mAppMeshes[obj.startMeshIndex]->numFrames - 1;
|
||||
state.matFrameIndex = mAppMeshes[obj.startMeshIndex]->numMatFrames - 1;
|
||||
state.frameIndex = appMeshes[obj.startMeshIndex]->numFrames - 1;
|
||||
state.matFrameIndex = appMeshes[obj.startMeshIndex]->numMatFrames - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -627,7 +627,7 @@ void TSShapeLoader::generateFrame(TSShape::Object& obj, F32 t, bool addFrame, bo
|
|||
{
|
||||
for (S32 iMesh = 0; iMesh < obj.numMeshes; iMesh++)
|
||||
{
|
||||
AppMesh* appMesh = mAppMeshes[obj.startMeshIndex + iMesh];
|
||||
AppMesh* appMesh = appMeshes[obj.startMeshIndex + iMesh];
|
||||
|
||||
U32 oldNumPoints = appMesh->points.size();
|
||||
U32 oldNumUvs = appMesh->uvs.size();
|
||||
|
|
@ -704,13 +704,13 @@ void TSShapeLoader::generateFrame(TSShape::Object& obj, F32 t, bool addFrame, bo
|
|||
void TSShapeLoader::generateMaterialList()
|
||||
{
|
||||
// Install the materials into the material list
|
||||
mShape->materialList = new TSMaterialList;
|
||||
shape->materialList = new TSMaterialList;
|
||||
for (S32 iMat = 0; iMat < AppMesh::appMaterials.size(); iMat++)
|
||||
{
|
||||
updateProgress(Load_GenerateMaterials, "Generating materials...", AppMesh::appMaterials.size(), iMat);
|
||||
|
||||
AppMaterial* appMat = AppMesh::appMaterials[iMat];
|
||||
mShape->materialList->push_back(appMat->getName(), appMat->getFlags(), U32(-1), U32(-1), U32(-1), 1.0f, appMat->getReflectance());
|
||||
shape->materialList->push_back(appMat->getName(), appMat->getFlags(), U32(-1), U32(-1), U32(-1), 1.0f, appMat->getReflectance());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -720,38 +720,38 @@ void TSShapeLoader::generateMaterialList()
|
|||
|
||||
void TSShapeLoader::generateSequences()
|
||||
{
|
||||
for (S32 iSeq = 0; iSeq < mAppSequences.size(); iSeq++)
|
||||
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++)
|
||||
{
|
||||
updateProgress(Load_GenerateSequences, "Generating sequences...", mAppSequences.size(), iSeq);
|
||||
updateProgress(Load_GenerateSequences, "Generating sequences...", appSequences.size(), iSeq);
|
||||
|
||||
// Initialize the sequence
|
||||
mAppSequences[iSeq]->setActive(true);
|
||||
appSequences[iSeq]->setActive(true);
|
||||
|
||||
mShape->sequences.increment();
|
||||
TSShape::Sequence& seq = mShape->sequences.last();
|
||||
shape->sequences.increment();
|
||||
TSShape::Sequence& seq = shape->sequences.last();
|
||||
|
||||
seq.nameIndex = mShape->addName(mAppSequences[iSeq]->getName());
|
||||
seq.toolBegin = mAppSequences[iSeq]->getStart();
|
||||
seq.priority = mAppSequences[iSeq]->getPriority();
|
||||
seq.flags = mAppSequences[iSeq]->getFlags();
|
||||
seq.nameIndex = shape->addName(appSequences[iSeq]->getName());
|
||||
seq.toolBegin = appSequences[iSeq]->getStart();
|
||||
seq.priority = appSequences[iSeq]->getPriority();
|
||||
seq.flags = appSequences[iSeq]->getFlags();
|
||||
|
||||
// Compute duration and number of keyframes (then adjust time between frames to match)
|
||||
seq.duration = mAppSequences[iSeq]->getEnd() - mAppSequences[iSeq]->getStart();
|
||||
seq.numKeyframes = (S32)(seq.duration * mAppSequences[iSeq]->fps + 0.5f) + 1;
|
||||
seq.duration = appSequences[iSeq]->getEnd() - appSequences[iSeq]->getStart();
|
||||
seq.numKeyframes = (S32)(seq.duration * appSequences[iSeq]->fps + 0.5f) + 1;
|
||||
|
||||
seq.sourceData.start = 0;
|
||||
seq.sourceData.end = seq.numKeyframes-1;
|
||||
seq.sourceData.total = seq.numKeyframes;
|
||||
|
||||
// Set membership arrays (ie. which nodes and objects are affected by this sequence)
|
||||
setNodeMembership(seq, mAppSequences[iSeq]);
|
||||
setObjectMembership(seq, mAppSequences[iSeq]);
|
||||
setNodeMembership(seq, appSequences[iSeq]);
|
||||
setObjectMembership(seq, appSequences[iSeq]);
|
||||
|
||||
// Generate keyframes
|
||||
generateNodeAnimation(seq);
|
||||
generateObjectAnimation(seq, mAppSequences[iSeq]);
|
||||
generateGroundAnimation(seq, mAppSequences[iSeq]);
|
||||
generateFrameTriggers(seq, mAppSequences[iSeq]);
|
||||
generateObjectAnimation(seq, appSequences[iSeq]);
|
||||
generateGroundAnimation(seq, appSequences[iSeq]);
|
||||
generateFrameTriggers(seq, appSequences[iSeq]);
|
||||
|
||||
// Set sequence flags
|
||||
seq.dirtyFlags = 0;
|
||||
|
|
@ -765,11 +765,11 @@ void TSShapeLoader::generateSequences()
|
|||
seq.dirtyFlags |= TSShapeInstance::MatFrameDirty;
|
||||
|
||||
// Set shape flags (only the most significant scale type)
|
||||
U32 curVal = mShape->mFlags & TSShape::AnyScale;
|
||||
mShape->mFlags &= ~(TSShape::AnyScale);
|
||||
mShape->mFlags |= getMax(curVal, seq.flags & TSShape::AnyScale); // take the larger value (can only convert upwards)
|
||||
U32 curVal = shape->mFlags & TSShape::AnyScale;
|
||||
shape->mFlags &= ~(TSShape::AnyScale);
|
||||
shape->mFlags |= getMax(curVal, seq.flags & TSShape::AnyScale); // take the larger value (can only convert upwards)
|
||||
|
||||
mAppSequences[iSeq]->setActive(false);
|
||||
appSequences[iSeq]->setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -798,16 +798,16 @@ void TSShapeLoader::setNodeMembership(TSShape::Sequence& seq, const AppSequence*
|
|||
|
||||
void TSShapeLoader::setRotationMembership(TSShape::Sequence& seq)
|
||||
{
|
||||
for (S32 iNode = 0; iNode < mAppNodes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
// Check if any of the node rotations are different to
|
||||
// the default rotation
|
||||
QuatF defaultRot;
|
||||
mShape->defaultRotations[iNode].getQuatF(&defaultRot);
|
||||
shape->defaultRotations[iNode].getQuatF(&defaultRot);
|
||||
|
||||
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
|
||||
{
|
||||
if (mNodeRotCache[iNode][iFrame] != defaultRot)
|
||||
if (nodeRotCache[iNode][iFrame] != defaultRot)
|
||||
{
|
||||
seq.rotationMatters.set(iNode);
|
||||
break;
|
||||
|
|
@ -818,15 +818,15 @@ void TSShapeLoader::setRotationMembership(TSShape::Sequence& seq)
|
|||
|
||||
void TSShapeLoader::setTranslationMembership(TSShape::Sequence& seq)
|
||||
{
|
||||
for (S32 iNode = 0; iNode < mAppNodes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
// Check if any of the node translations are different to
|
||||
// the default translation
|
||||
Point3F& defaultTrans = mShape->defaultTranslations[iNode];
|
||||
Point3F& defaultTrans = shape->defaultTranslations[iNode];
|
||||
|
||||
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
|
||||
{
|
||||
if (!mNodeTransCache[iNode][iFrame].equal(defaultTrans))
|
||||
if (!nodeTransCache[iNode][iFrame].equal(defaultTrans))
|
||||
{
|
||||
seq.translationMatters.set(iNode);
|
||||
break;
|
||||
|
|
@ -843,16 +843,16 @@ void TSShapeLoader::setScaleMembership(TSShape::Sequence& seq)
|
|||
U32 alignedScaleCount = 0;
|
||||
U32 uniformScaleCount = 0;
|
||||
|
||||
for (S32 iNode = 0; iNode < mAppNodes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
// Check if any of the node scales are not the unit scale
|
||||
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
|
||||
{
|
||||
Point3F& scale = mNodeScaleCache[iNode][iFrame];
|
||||
Point3F& scale = nodeScaleCache[iNode][iFrame];
|
||||
if (!unitScale.equal(scale))
|
||||
{
|
||||
// Determine what type of scale this is
|
||||
if (!mNodeScaleRotCache[iNode][iFrame].isIdentity())
|
||||
if (!nodeScaleRotCache[iNode][iFrame].isIdentity())
|
||||
arbitraryScaleCount++;
|
||||
else if (scale.x != scale.y || scale.y != scale.z)
|
||||
alignedScaleCount++;
|
||||
|
|
@ -880,12 +880,12 @@ void TSShapeLoader::setObjectMembership(TSShape::Sequence& seq, const AppSequenc
|
|||
seq.frameMatters.clearAll(); // vert animation (morph) (size = objects.size())
|
||||
seq.matFrameMatters.clearAll(); // UV animation (size = objects.size())
|
||||
|
||||
for (S32 iObject = 0; iObject < mShape->objects.size(); iObject++)
|
||||
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
|
||||
{
|
||||
if (!mAppMeshes[mShape->objects[iObject].startMeshIndex])
|
||||
if (!appMeshes[shape->objects[iObject].startMeshIndex])
|
||||
continue;
|
||||
|
||||
if (mAppMeshes[mShape->objects[iObject].startMeshIndex]->animatesVis(appSeq))
|
||||
if (appMeshes[shape->objects[iObject].startMeshIndex]->animatesVis(appSeq))
|
||||
seq.visMatters.set(iObject);
|
||||
// Morph and UV animation has been deprecated
|
||||
//if (appMeshes[shape->objects[iObject].startMeshIndex]->animatesFrame(appSeq))
|
||||
|
|
@ -898,18 +898,18 @@ void TSShapeLoader::setObjectMembership(TSShape::Sequence& seq, const AppSequenc
|
|||
void TSShapeLoader::clearNodeTransformCache()
|
||||
{
|
||||
// clear out the transform caches
|
||||
for (S32 i = 0; i < mNodeRotCache.size(); i++)
|
||||
delete [] mNodeRotCache[i];
|
||||
mNodeRotCache.clear();
|
||||
for (S32 i = 0; i < mNodeTransCache.size(); i++)
|
||||
delete [] mNodeTransCache[i];
|
||||
mNodeTransCache.clear();
|
||||
for (S32 i = 0; i < mNodeScaleRotCache.size(); i++)
|
||||
delete [] mNodeScaleRotCache[i];
|
||||
mNodeScaleRotCache.clear();
|
||||
for (S32 i = 0; i < mNodeScaleCache.size(); i++)
|
||||
delete [] mNodeScaleCache[i];
|
||||
mNodeScaleCache.clear();
|
||||
for (S32 i = 0; i < nodeRotCache.size(); i++)
|
||||
delete [] nodeRotCache[i];
|
||||
nodeRotCache.clear();
|
||||
for (S32 i = 0; i < nodeTransCache.size(); i++)
|
||||
delete [] nodeTransCache[i];
|
||||
nodeTransCache.clear();
|
||||
for (S32 i = 0; i < nodeScaleRotCache.size(); i++)
|
||||
delete [] nodeScaleRotCache[i];
|
||||
nodeScaleRotCache.clear();
|
||||
for (S32 i = 0; i < nodeScaleCache.size(); i++)
|
||||
delete [] nodeScaleCache[i];
|
||||
nodeScaleCache.clear();
|
||||
}
|
||||
|
||||
void TSShapeLoader::fillNodeTransformCache(TSShape::Sequence& seq, const AppSequence* appSeq)
|
||||
|
|
@ -917,28 +917,28 @@ void TSShapeLoader::fillNodeTransformCache(TSShape::Sequence& seq, const AppSequ
|
|||
// clear out the transform caches and set it up for this sequence
|
||||
clearNodeTransformCache();
|
||||
|
||||
mNodeRotCache.setSize(mAppNodes.size());
|
||||
for (S32 i = 0; i < mNodeRotCache.size(); i++)
|
||||
mNodeRotCache[i] = new QuatF[seq.numKeyframes];
|
||||
mNodeTransCache.setSize(mAppNodes.size());
|
||||
for (S32 i = 0; i < mNodeTransCache.size(); i++)
|
||||
mNodeTransCache[i] = new Point3F[seq.numKeyframes];
|
||||
mNodeScaleRotCache.setSize(mAppNodes.size());
|
||||
for (S32 i = 0; i < mNodeScaleRotCache.size(); i++)
|
||||
mNodeScaleRotCache[i] = new QuatF[seq.numKeyframes];
|
||||
mNodeScaleCache.setSize(mAppNodes.size());
|
||||
for (S32 i = 0; i < mNodeScaleCache.size(); i++)
|
||||
mNodeScaleCache[i] = new Point3F[seq.numKeyframes];
|
||||
nodeRotCache.setSize(appNodes.size());
|
||||
for (S32 i = 0; i < nodeRotCache.size(); i++)
|
||||
nodeRotCache[i] = new QuatF[seq.numKeyframes];
|
||||
nodeTransCache.setSize(appNodes.size());
|
||||
for (S32 i = 0; i < nodeTransCache.size(); i++)
|
||||
nodeTransCache[i] = new Point3F[seq.numKeyframes];
|
||||
nodeScaleRotCache.setSize(appNodes.size());
|
||||
for (S32 i = 0; i < nodeScaleRotCache.size(); i++)
|
||||
nodeScaleRotCache[i] = new QuatF[seq.numKeyframes];
|
||||
nodeScaleCache.setSize(appNodes.size());
|
||||
for (S32 i = 0; i < nodeScaleCache.size(); i++)
|
||||
nodeScaleCache[i] = new Point3F[seq.numKeyframes];
|
||||
|
||||
// get the node transforms for every frame
|
||||
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
|
||||
{
|
||||
F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numKeyframes - 1);
|
||||
for (S32 iNode = 0; iNode < mAppNodes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
generateNodeTransform(mAppNodes[iNode], time, seq.isBlend(), appSeq->getBlendRefTime(),
|
||||
mNodeRotCache[iNode][iFrame], mNodeTransCache[iNode][iFrame],
|
||||
mNodeScaleRotCache[iNode][iFrame], mNodeScaleCache[iNode][iFrame]);
|
||||
generateNodeTransform(appNodes[iNode], time, seq.isBlend(), appSeq->getBlendRefTime(),
|
||||
nodeRotCache[iNode][iFrame], nodeTransCache[iNode][iFrame],
|
||||
nodeScaleRotCache[iNode][iFrame], nodeScaleCache[iNode][iFrame]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -949,57 +949,57 @@ void TSShapeLoader::addNodeRotation(QuatF& rot, bool defaultVal)
|
|||
rot16.set(rot);
|
||||
|
||||
if (!defaultVal)
|
||||
mShape->nodeRotations.push_back(rot16);
|
||||
shape->nodeRotations.push_back(rot16);
|
||||
else
|
||||
mShape->defaultRotations.push_back(rot16);
|
||||
shape->defaultRotations.push_back(rot16);
|
||||
}
|
||||
|
||||
void TSShapeLoader::addNodeTranslation(Point3F& trans, bool defaultVal)
|
||||
{
|
||||
if (!defaultVal)
|
||||
mShape->nodeTranslations.push_back(trans);
|
||||
shape->nodeTranslations.push_back(trans);
|
||||
else
|
||||
mShape->defaultTranslations.push_back(trans);
|
||||
shape->defaultTranslations.push_back(trans);
|
||||
}
|
||||
|
||||
void TSShapeLoader::addNodeUniformScale(F32 scale)
|
||||
{
|
||||
mShape->nodeUniformScales.push_back(scale);
|
||||
shape->nodeUniformScales.push_back(scale);
|
||||
}
|
||||
|
||||
void TSShapeLoader::addNodeAlignedScale(Point3F& scale)
|
||||
{
|
||||
mShape->nodeAlignedScales.push_back(scale);
|
||||
shape->nodeAlignedScales.push_back(scale);
|
||||
}
|
||||
|
||||
void TSShapeLoader::addNodeArbitraryScale(QuatF& qrot, Point3F& scale)
|
||||
{
|
||||
Quat16 rot16;
|
||||
rot16.set(qrot);
|
||||
mShape->nodeArbitraryScaleRots.push_back(rot16);
|
||||
mShape->nodeArbitraryScaleFactors.push_back(scale);
|
||||
shape->nodeArbitraryScaleRots.push_back(rot16);
|
||||
shape->nodeArbitraryScaleFactors.push_back(scale);
|
||||
}
|
||||
|
||||
void TSShapeLoader::generateNodeAnimation(TSShape::Sequence& seq)
|
||||
{
|
||||
seq.baseRotation = mShape->nodeRotations.size();
|
||||
seq.baseTranslation = mShape->nodeTranslations.size();
|
||||
seq.baseScale = (seq.flags & TSShape::ArbitraryScale) ? mShape->nodeArbitraryScaleRots.size() :
|
||||
(seq.flags & TSShape::AlignedScale) ? mShape->nodeAlignedScales.size() :
|
||||
mShape->nodeUniformScales.size();
|
||||
seq.baseRotation = shape->nodeRotations.size();
|
||||
seq.baseTranslation = shape->nodeTranslations.size();
|
||||
seq.baseScale = (seq.flags & TSShape::ArbitraryScale) ? shape->nodeArbitraryScaleRots.size() :
|
||||
(seq.flags & TSShape::AlignedScale) ? shape->nodeAlignedScales.size() :
|
||||
shape->nodeUniformScales.size();
|
||||
|
||||
for (S32 iNode = 0; iNode < mAppNodes.size(); iNode++)
|
||||
for (S32 iNode = 0; iNode < appNodes.size(); iNode++)
|
||||
{
|
||||
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
|
||||
{
|
||||
if (seq.rotationMatters.test(iNode))
|
||||
addNodeRotation(mNodeRotCache[iNode][iFrame], false);
|
||||
addNodeRotation(nodeRotCache[iNode][iFrame], false);
|
||||
if (seq.translationMatters.test(iNode))
|
||||
addNodeTranslation(mNodeTransCache[iNode][iFrame], false);
|
||||
addNodeTranslation(nodeTransCache[iNode][iFrame], false);
|
||||
if (seq.scaleMatters.test(iNode))
|
||||
{
|
||||
QuatF& rot = mNodeScaleRotCache[iNode][iFrame];
|
||||
Point3F scale = mNodeScaleCache[iNode][iFrame];
|
||||
QuatF& rot = nodeScaleRotCache[iNode][iFrame];
|
||||
Point3F scale = nodeScaleCache[iNode][iFrame];
|
||||
|
||||
if (seq.flags & TSShape::ArbitraryScale)
|
||||
addNodeArbitraryScale(rot, scale);
|
||||
|
|
@ -1014,9 +1014,9 @@ void TSShapeLoader::generateNodeAnimation(TSShape::Sequence& seq)
|
|||
|
||||
void TSShapeLoader::generateObjectAnimation(TSShape::Sequence& seq, const AppSequence* appSeq)
|
||||
{
|
||||
seq.baseObjectState = mShape->objectStates.size();
|
||||
seq.baseObjectState = shape->objectStates.size();
|
||||
|
||||
for (S32 iObject = 0; iObject < mShape->objects.size(); iObject++)
|
||||
for (S32 iObject = 0; iObject < shape->objects.size(); iObject++)
|
||||
{
|
||||
bool visMatters = seq.visMatters.test(iObject);
|
||||
bool frameMatters = seq.frameMatters.test(iObject);
|
||||
|
|
@ -1027,7 +1027,7 @@ void TSShapeLoader::generateObjectAnimation(TSShape::Sequence& seq, const AppSeq
|
|||
for (S32 iFrame = 0; iFrame < seq.numKeyframes; iFrame++)
|
||||
{
|
||||
F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numKeyframes - 1);
|
||||
generateObjectState(mShape->objects[iObject], time, frameMatters, matFrameMatters);
|
||||
generateObjectState(shape->objects[iObject], time, frameMatters, matFrameMatters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1035,10 +1035,10 @@ void TSShapeLoader::generateObjectAnimation(TSShape::Sequence& seq, const AppSeq
|
|||
|
||||
void TSShapeLoader::generateGroundAnimation(TSShape::Sequence& seq, const AppSequence* appSeq)
|
||||
{
|
||||
seq.firstGroundFrame = mShape->groundTranslations.size();
|
||||
seq.firstGroundFrame = shape->groundTranslations.size();
|
||||
seq.numGroundFrames = 0;
|
||||
|
||||
if (!mBoundsNode)
|
||||
if (!boundsNode)
|
||||
return;
|
||||
|
||||
// Check if the bounds node is animated by this sequence
|
||||
|
|
@ -1047,7 +1047,7 @@ void TSShapeLoader::generateGroundAnimation(TSShape::Sequence& seq, const AppSeq
|
|||
seq.flags |= TSShape::MakePath;
|
||||
|
||||
// Get ground transform at the start of the sequence
|
||||
MatrixF invStartMat = mBoundsNode->getNodeTransform(appSeq->getStart());
|
||||
MatrixF invStartMat = boundsNode->getNodeTransform(appSeq->getStart());
|
||||
zapScale(invStartMat);
|
||||
invStartMat.inverse();
|
||||
|
||||
|
|
@ -1056,22 +1056,22 @@ void TSShapeLoader::generateGroundAnimation(TSShape::Sequence& seq, const AppSeq
|
|||
F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numGroundFrames - 1);
|
||||
|
||||
// Determine delta bounds node transform at 't'
|
||||
MatrixF mat = mBoundsNode->getNodeTransform(time);
|
||||
MatrixF mat = boundsNode->getNodeTransform(time);
|
||||
zapScale(mat);
|
||||
mat = invStartMat * mat;
|
||||
|
||||
// Add ground transform
|
||||
Quat16 rotation;
|
||||
rotation.set(QuatF(mat));
|
||||
mShape->groundTranslations.push_back(mat.getPosition());
|
||||
mShape->groundRotations.push_back(rotation);
|
||||
shape->groundTranslations.push_back(mat.getPosition());
|
||||
shape->groundRotations.push_back(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
void TSShapeLoader::generateFrameTriggers(TSShape::Sequence& seq, const AppSequence* appSeq)
|
||||
{
|
||||
// Initialize triggers
|
||||
seq.firstTrigger = mShape->triggers.size();
|
||||
seq.firstTrigger = shape->triggers.size();
|
||||
seq.numTriggers = appSeq->getNumTriggers();
|
||||
if (!seq.numTriggers)
|
||||
return;
|
||||
|
|
@ -1081,8 +1081,8 @@ void TSShapeLoader::generateFrameTriggers(TSShape::Sequence& seq, const AppSeque
|
|||
// Add triggers
|
||||
for (S32 iTrigger = 0; iTrigger < seq.numTriggers; iTrigger++)
|
||||
{
|
||||
mShape->triggers.increment();
|
||||
appSeq->getTrigger(iTrigger, mShape->triggers.last());
|
||||
shape->triggers.increment();
|
||||
appSeq->getTrigger(iTrigger, shape->triggers.last());
|
||||
}
|
||||
|
||||
// Track the triggers that get turned off by this shape...normally, triggers
|
||||
|
|
@ -1092,7 +1092,7 @@ void TSShapeLoader::generateFrameTriggers(TSShape::Sequence& seq, const AppSeque
|
|||
U32 offTriggers = 0;
|
||||
for (S32 iTrigger = 0; iTrigger < seq.numTriggers; iTrigger++)
|
||||
{
|
||||
U32 state = mShape->triggers[seq.firstTrigger+iTrigger].state;
|
||||
U32 state = shape->triggers[seq.firstTrigger+iTrigger].state;
|
||||
if ((state & TSShape::Trigger::StateOn) == 0)
|
||||
offTriggers |= (state & TSShape::Trigger::StateMask);
|
||||
}
|
||||
|
|
@ -1100,8 +1100,8 @@ void TSShapeLoader::generateFrameTriggers(TSShape::Sequence& seq, const AppSeque
|
|||
// We now know which states are turned off, set invert on all those (including when turned on)
|
||||
for (int iTrigger = 0; iTrigger < seq.numTriggers; iTrigger++)
|
||||
{
|
||||
if (mShape->triggers[seq.firstTrigger + iTrigger].state & offTriggers)
|
||||
mShape->triggers[seq.firstTrigger + iTrigger].state |= TSShape::Trigger::InvertOnReverse;
|
||||
if (shape->triggers[seq.firstTrigger + iTrigger].state & offTriggers)
|
||||
shape->triggers[seq.firstTrigger + iTrigger].state |= TSShape::Trigger::InvertOnReverse;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1113,36 +1113,36 @@ void TSShapeLoader::sortDetails()
|
|||
|
||||
|
||||
// Insert NULL meshes where required
|
||||
for (S32 iSub = 0; iSub < mSubshapes.size(); iSub++)
|
||||
for (S32 iSub = 0; iSub < subshapes.size(); iSub++)
|
||||
{
|
||||
Vector<S32> validDetails;
|
||||
mShape->getSubShapeDetails(iSub, validDetails);
|
||||
shape->getSubShapeDetails(iSub, validDetails);
|
||||
|
||||
for (S32 iDet = 0; iDet < validDetails.size(); iDet++)
|
||||
{
|
||||
TSShape::Detail &detail = mShape->details[validDetails[iDet]];
|
||||
TSShape::Detail &detail = shape->details[validDetails[iDet]];
|
||||
if (detail.subShapeNum >= 0)
|
||||
detail.objectDetailNum = iDet;
|
||||
|
||||
for (S32 iObj = mShape->subShapeFirstObject[iSub];
|
||||
iObj < (mShape->subShapeFirstObject[iSub] + mShape->subShapeNumObjects[iSub]);
|
||||
for (S32 iObj = shape->subShapeFirstObject[iSub];
|
||||
iObj < (shape->subShapeFirstObject[iSub] + shape->subShapeNumObjects[iSub]);
|
||||
iObj++)
|
||||
{
|
||||
TSShape::Object &object = mShape->objects[iObj];
|
||||
TSShape::Object &object = shape->objects[iObj];
|
||||
|
||||
// Insert a NULL mesh for this detail level if required (ie. if the
|
||||
// object does not already have a mesh with an equal or higher detail)
|
||||
S32 meshIndex = (iDet < object.numMeshes) ? iDet : object.numMeshes-1;
|
||||
|
||||
if (mAppMeshes[object.startMeshIndex + meshIndex]->detailSize < mShape->details[iDet].size)
|
||||
if (appMeshes[object.startMeshIndex + meshIndex]->detailSize < shape->details[iDet].size)
|
||||
{
|
||||
// Add a NULL mesh
|
||||
mAppMeshes.insert(object.startMeshIndex + iDet, NULL);
|
||||
appMeshes.insert(object.startMeshIndex + iDet, NULL);
|
||||
object.numMeshes++;
|
||||
|
||||
// Fixup the start index for the other objects
|
||||
for (S32 k = iObj+1; k < mShape->objects.size(); k++)
|
||||
mShape->objects[k].startMeshIndex++;
|
||||
for (S32 k = iObj+1; k < shape->objects.size(); k++)
|
||||
shape->objects[k].startMeshIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1157,79 +1157,79 @@ void TSShapeLoader::install()
|
|||
{
|
||||
// Arrays that are filled in by ts shape init, but need
|
||||
// to be allocated beforehand.
|
||||
mShape->subShapeFirstTranslucentObject.setSize(mShape->subShapeFirstObject.size());
|
||||
shape->subShapeFirstTranslucentObject.setSize(shape->subShapeFirstObject.size());
|
||||
|
||||
// Construct TS sub-meshes
|
||||
mShape->meshes.setSize(mAppMeshes.size());
|
||||
for (U32 m = 0; m < mAppMeshes.size(); m++)
|
||||
mShape->meshes[m] = mAppMeshes[m] ? mAppMeshes[m]->constructTSMesh() : NULL;
|
||||
shape->meshes.setSize(appMeshes.size());
|
||||
for (U32 m = 0; m < appMeshes.size(); m++)
|
||||
shape->meshes[m] = appMeshes[m] ? appMeshes[m]->constructTSMesh() : NULL;
|
||||
|
||||
// Remove empty meshes and objects
|
||||
for (S32 iObj = mShape->objects.size()-1; iObj >= 0; iObj--)
|
||||
for (S32 iObj = shape->objects.size()-1; iObj >= 0; iObj--)
|
||||
{
|
||||
TSShape::Object& obj = mShape->objects[iObj];
|
||||
TSShape::Object& obj = shape->objects[iObj];
|
||||
for (S32 iMesh = obj.numMeshes-1; iMesh >= 0; iMesh--)
|
||||
{
|
||||
TSMesh *mesh = mShape->meshes[obj.startMeshIndex + iMesh];
|
||||
TSMesh *mesh = shape->meshes[obj.startMeshIndex + iMesh];
|
||||
|
||||
if (mesh && !mesh->mPrimitives.size())
|
||||
{
|
||||
S32 oldMeshCount = obj.numMeshes;
|
||||
destructInPlace(mesh);
|
||||
mShape->removeMeshFromObject(iObj, iMesh);
|
||||
shape->removeMeshFromObject(iObj, iMesh);
|
||||
iMesh -= (oldMeshCount - obj.numMeshes - 1); // handle when more than one mesh is removed
|
||||
}
|
||||
}
|
||||
|
||||
if (!obj.numMeshes)
|
||||
mShape->removeObject(mShape->getName(obj.nameIndex));
|
||||
shape->removeObject(shape->getName(obj.nameIndex));
|
||||
}
|
||||
|
||||
// Add a dummy object if needed so the shape loads and renders ok
|
||||
if (!mShape->details.size())
|
||||
if (!shape->details.size())
|
||||
{
|
||||
mShape->addDetail("detail", 2, 0);
|
||||
mShape->subShapeNumObjects.last() = 1;
|
||||
shape->addDetail("detail", 2, 0);
|
||||
shape->subShapeNumObjects.last() = 1;
|
||||
|
||||
mShape->meshes.push_back(NULL);
|
||||
shape->meshes.push_back(NULL);
|
||||
|
||||
mShape->objects.increment();
|
||||
shape->objects.increment();
|
||||
|
||||
TSShape::Object& lastObject = mShape->objects.last();
|
||||
lastObject.nameIndex = mShape->addName("dummy");
|
||||
TSShape::Object& lastObject = shape->objects.last();
|
||||
lastObject.nameIndex = shape->addName("dummy");
|
||||
lastObject.nodeIndex = 0;
|
||||
lastObject.startMeshIndex = 0;
|
||||
lastObject.numMeshes = 1;
|
||||
|
||||
mShape->objectStates.increment();
|
||||
mShape->objectStates.last().frameIndex = 0;
|
||||
mShape->objectStates.last().matFrameIndex = 0;
|
||||
mShape->objectStates.last().vis = 1.0f;
|
||||
shape->objectStates.increment();
|
||||
shape->objectStates.last().frameIndex = 0;
|
||||
shape->objectStates.last().matFrameIndex = 0;
|
||||
shape->objectStates.last().vis = 1.0f;
|
||||
}
|
||||
|
||||
// Update smallest visible detail
|
||||
mShape->mSmallestVisibleDL = -1;
|
||||
mShape->mSmallestVisibleSize = 999999;
|
||||
for (S32 i = 0; i < mShape->details.size(); i++)
|
||||
shape->mSmallestVisibleDL = -1;
|
||||
shape->mSmallestVisibleSize = 999999;
|
||||
for (S32 i = 0; i < shape->details.size(); i++)
|
||||
{
|
||||
if ((mShape->details[i].size >= 0) &&
|
||||
(mShape->details[i].size < mShape->mSmallestVisibleSize))
|
||||
if ((shape->details[i].size >= 0) &&
|
||||
(shape->details[i].size < shape->mSmallestVisibleSize))
|
||||
{
|
||||
mShape->mSmallestVisibleDL = i;
|
||||
mShape->mSmallestVisibleSize = mShape->details[i].size;
|
||||
shape->mSmallestVisibleDL = i;
|
||||
shape->mSmallestVisibleSize = shape->details[i].size;
|
||||
}
|
||||
}
|
||||
|
||||
computeBounds(mShape->mBounds);
|
||||
if (!mShape->mBounds.isValidBox())
|
||||
mShape->mBounds = Box3F(1.0f);
|
||||
computeBounds(shape->mBounds);
|
||||
if (!shape->mBounds.isValidBox())
|
||||
shape->mBounds = Box3F(1.0f);
|
||||
|
||||
mShape->mBounds.getCenter(&mShape->center);
|
||||
mShape->mRadius = (mShape->mBounds.maxExtents - mShape->center).len();
|
||||
mShape->tubeRadius = mShape->mRadius;
|
||||
shape->mBounds.getCenter(&shape->center);
|
||||
shape->mRadius = (shape->mBounds.maxExtents - shape->center).len();
|
||||
shape->tubeRadius = shape->mRadius;
|
||||
|
||||
mShape->init();
|
||||
mShape->finalizeEditable();
|
||||
shape->init();
|
||||
shape->finalizeEditable();
|
||||
}
|
||||
|
||||
void TSShapeLoader::computeBounds(Box3F& bounds)
|
||||
|
|
@ -1238,11 +1238,11 @@ void TSShapeLoader::computeBounds(Box3F& bounds)
|
|||
bounds = Box3F::Invalid;
|
||||
|
||||
// Use bounds node geometry if present
|
||||
if (mBoundsNode && mBoundsNode->getNumMesh() )
|
||||
if ( boundsNode && boundsNode->getNumMesh() )
|
||||
{
|
||||
for (S32 iMesh = 0; iMesh < mBoundsNode->getNumMesh(); iMesh++)
|
||||
for (S32 iMesh = 0; iMesh < boundsNode->getNumMesh(); iMesh++)
|
||||
{
|
||||
AppMesh* mesh = mBoundsNode->getMesh( iMesh );
|
||||
AppMesh* mesh = boundsNode->getMesh( iMesh );
|
||||
if ( !mesh )
|
||||
continue;
|
||||
|
||||
|
|
@ -1255,9 +1255,9 @@ void TSShapeLoader::computeBounds(Box3F& bounds)
|
|||
else
|
||||
{
|
||||
// Compute bounds based on all geometry in the model
|
||||
for (S32 iMesh = 0; iMesh < mAppMeshes.size(); iMesh++)
|
||||
for (S32 iMesh = 0; iMesh < appMeshes.size(); iMesh++)
|
||||
{
|
||||
AppMesh* mesh = mAppMeshes[iMesh];
|
||||
AppMesh* mesh = appMeshes[iMesh];
|
||||
if ( !mesh )
|
||||
continue;
|
||||
|
||||
|
|
@ -1279,14 +1279,14 @@ TSShapeLoader::~TSShapeLoader()
|
|||
AppMesh::appMaterials.clear();
|
||||
|
||||
// Delete Subshapes
|
||||
delete mBoundsNode;
|
||||
for (S32 iSub = 0; iSub < mSubshapes.size(); iSub++)
|
||||
delete mSubshapes[iSub];
|
||||
delete boundsNode;
|
||||
for (S32 iSub = 0; iSub < subshapes.size(); iSub++)
|
||||
delete subshapes[iSub];
|
||||
|
||||
// Delete AppSequences
|
||||
for (S32 iSeq = 0; iSeq < mAppSequences.size(); iSeq++)
|
||||
delete mAppSequences[iSeq];
|
||||
mAppSequences.clear();
|
||||
for (S32 iSeq = 0; iSeq < appSequences.size(); iSeq++)
|
||||
delete appSequences[iSeq];
|
||||
appSequences.clear();
|
||||
}
|
||||
|
||||
// Static functions to handle supported formats for shape loader.
|
||||
|
|
|
|||
|
|
@ -101,24 +101,24 @@ public:
|
|||
|
||||
protected:
|
||||
// Variables used during loading that must be held until the shape is deleted
|
||||
TSShape* mShape;
|
||||
Vector<AppMesh*> mAppMeshes;
|
||||
TSShape* shape;
|
||||
Vector<AppMesh*> appMeshes;
|
||||
|
||||
// Variables used during loading, but that can be discarded afterwards
|
||||
static Torque::Path mShapePath;
|
||||
static Torque::Path shapePath;
|
||||
|
||||
AppNode* mBoundsNode;
|
||||
Vector<AppNode*> mAppNodes; ///< Nodes in the loaded shape
|
||||
Vector<AppSequence*> mAppSequences;
|
||||
AppNode* boundsNode;
|
||||
Vector<AppNode*> appNodes; ///< Nodes in the loaded shape
|
||||
Vector<AppSequence*> appSequences;
|
||||
|
||||
Vector<Subshape*> mSubshapes;
|
||||
Vector<Subshape*> subshapes;
|
||||
|
||||
Vector<QuatF*> mNodeRotCache;
|
||||
Vector<Point3F*> mNodeTransCache;
|
||||
Vector<QuatF*> mNodeScaleRotCache;
|
||||
Vector<Point3F*> mNodeScaleCache;
|
||||
Vector<QuatF*> nodeRotCache;
|
||||
Vector<Point3F*> nodeTransCache;
|
||||
Vector<QuatF*> nodeScaleRotCache;
|
||||
Vector<Point3F*> nodeScaleCache;
|
||||
|
||||
Point3F mShapeOffset; ///< Offset used to translate the shape origin
|
||||
Point3F shapeOffset; ///< Offset used to translate the shape origin
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -183,10 +183,10 @@ protected:
|
|||
void install();
|
||||
|
||||
public:
|
||||
TSShapeLoader() : mBoundsNode(0) { }
|
||||
TSShapeLoader() : boundsNode(0) { }
|
||||
virtual ~TSShapeLoader();
|
||||
|
||||
static const Torque::Path& getShapePath() { return mShapePath; }
|
||||
static const Torque::Path& getShapePath() { return shapePath; }
|
||||
|
||||
static void zapScale(MatrixF& mat);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue