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