Engine directory for ticket #1

This commit is contained in:
DavidWyand-GG 2012-09-19 11:15:01 -04:00
parent 352279af7a
commit 7dbfe6994d
3795 changed files with 1363358 additions and 0 deletions

View file

@ -0,0 +1,40 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _APPMATERIAL_H_
#define _APPMATERIAL_H_
struct AppMaterial
{
U32 flags;
F32 reflectance;
AppMaterial() : flags(0), reflectance(1.0f) { }
virtual ~AppMaterial() {}
virtual String getName() const { return "unnamed"; }
virtual U32 getFlags() { return flags; }
virtual F32 getReflectance() { return reflectance; }
};
#endif // _APPMATERIAL_H_

View file

@ -0,0 +1,178 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "ts/loader/appMesh.h"
#include "ts/loader/tsShapeLoader.h"
Vector<AppMaterial*> AppMesh::appMaterials;
AppMesh::AppMesh()
: flags(0), numFrames(0), numMatFrames(0), vertsPerFrame(0)
{
}
AppMesh::~AppMesh()
{
}
void AppMesh::computeBounds(Box3F& bounds)
{
bounds = Box3F::Invalid;
if ( isSkin() )
{
// Need to skin the mesh before we can compute the bounds
// Setup bone transforms
Vector<MatrixF> boneTransforms;
boneTransforms.setSize( nodeIndex.size() );
for (S32 iBone = 0; iBone < boneTransforms.size(); iBone++)
{
MatrixF nodeMat = bones[iBone]->getNodeTransform( TSShapeLoader::DefaultTime );
TSShapeLoader::zapScale(nodeMat);
boneTransforms[iBone].mul( nodeMat, initialTransforms[iBone] );
}
// Multiply verts by weighted bone transforms
for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
points[iVert].set( Point3F::Zero );
for (S32 iWeight = 0; iWeight < vertexIndex.size(); iWeight++)
{
const S32& vertIndex = vertexIndex[iWeight];
const MatrixF& deltaTransform = boneTransforms[ boneIndex[iWeight] ];
Point3F v;
deltaTransform.mulP( initialVerts[vertIndex], &v );
v *= weight[iWeight];
points[vertIndex] += v;
}
// compute bounds for the skinned mesh
for (S32 iVert = 0; iVert < initialVerts.size(); iVert++)
bounds.extend( points[iVert] );
}
else
{
MatrixF transform = getMeshTransform(TSShapeLoader::DefaultTime);
TSShapeLoader::zapScale(transform);
for (S32 iVert = 0; iVert < points.size(); iVert++)
{
Point3F p;
transform.mulP(points[iVert], &p);
bounds.extend(p);
}
}
}
void AppMesh::computeNormals()
{
// Clear normals
normals.setSize( points.size() );
for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
normals[iNorm] = Point3F::Zero;
// Sum triangle normals for each vertex
for (S32 iPrim = 0; iPrim < primitives.size(); iPrim++)
{
const TSDrawPrimitive& prim = primitives[iPrim];
for (S32 iInd = 0; iInd < prim.numElements; iInd += 3)
{
// Compute the normal for this triangle
S32 idx0 = indices[prim.start + iInd + 0];
S32 idx1 = indices[prim.start + iInd + 1];
S32 idx2 = indices[prim.start + iInd + 2];
const Point3F& v0 = points[idx0];
const Point3F& v1 = points[idx1];
const Point3F& v2 = points[idx2];
Point3F n;
mCross(v2 - v0, v1 - v0, &n);
n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect)
normals[idx0] += n;
normals[idx1] += n;
normals[idx2] += n;
}
}
// Normalize the vertex normals (this takes care of averaging the triangle normals)
for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
normals[iNorm].normalize();
}
TSMesh* AppMesh::constructTSMesh()
{
TSMesh* tsmesh;
if (isSkin())
{
TSSkinMesh* tsskin = new TSSkinMesh();
tsmesh = tsskin;
// Copy skin elements
tsskin->weight = weight;
tsskin->boneIndex = boneIndex;
tsskin->vertexIndex = vertexIndex;
tsskin->batchData.nodeIndex = nodeIndex;
tsskin->batchData.initialTransforms = initialTransforms;
tsskin->batchData.initialVerts = initialVerts;
tsskin->batchData.initialNorms = initialNorms;
}
else
{
tsmesh = new TSMesh();
}
// Copy mesh elements
tsmesh->verts = points;
tsmesh->norms = normals;
tsmesh->tverts = uvs;
tsmesh->primitives = primitives;
tsmesh->indices = indices;
tsmesh->colors = colors;
tsmesh->tverts2 = uv2s;
// Finish initializing the shape
tsmesh->setFlags(flags);
tsmesh->computeBounds();
tsmesh->numFrames = numFrames;
tsmesh->numMatFrames = numMatFrames;
tsmesh->vertsPerFrame = vertsPerFrame;
tsmesh->createTangents(tsmesh->verts, tsmesh->norms);
tsmesh->encodedNorms.set(NULL,0);
return tsmesh;
}
bool AppMesh::isBillboard()
{
return !dStrnicmp(getName(),"BB::",4) || !dStrnicmp(getName(),"BB_",3) || isBillboardZAxis();
}
bool AppMesh::isBillboardZAxis()
{
return !dStrnicmp(getName(),"BBZ::",5) || !dStrnicmp(getName(),"BBZ_",4);
}

View file

@ -0,0 +1,105 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _APPMESH_H_
#define _APPMESH_H_
#ifndef _MMATH_H_
#include "math/mMath.h"
#endif
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
#ifndef _APPMATERIAL_H_
#include "ts/loader/appMaterial.h"
#endif
#ifndef _APPSEQUENCE_H_
#include "ts/loader/appSequence.h"
#endif
class AppNode;
class AppMesh
{
public:
// Mesh and skin elements
Vector<Point3F> points;
Vector<Point3F> normals;
Vector<Point2F> uvs;
Vector<Point2F> uv2s;
Vector<ColorI> colors;
Vector<TSDrawPrimitive> primitives;
Vector<U32> indices;
// Skin elements
Vector<F32> weight;
Vector<S32> boneIndex;
Vector<S32> vertexIndex;
Vector<S32> nodeIndex;
Vector<MatrixF> initialTransforms;
Vector<Point3F> initialVerts;
Vector<Point3F> initialNorms;
U32 flags;
U32 vertsPerFrame;
S32 numFrames;
S32 numMatFrames;
// Loader elements (can be discarded after loading)
S32 detailSize;
MatrixF objectOffset;
Vector<AppNode*> bones;
static Vector<AppMaterial*> appMaterials;
public:
AppMesh();
virtual ~AppMesh();
void computeBounds(Box3F& bounds);
void computeNormals();
// Create a TSMesh object
TSMesh* constructTSMesh();
virtual const char * getName(bool allowFixed=true) = 0;
virtual MatrixF getMeshTransform(F32 time) = 0;
virtual F32 getVisValue(F32 time) = 0;
virtual bool getFloat(const char* propName, F32& defaultVal) = 0;
virtual bool getInt(const char* propName, S32& defaultVal) = 0;
virtual bool getBool(const char* propName, bool& defaultVal) = 0;
virtual bool animatesVis(const AppSequence* appSeq) { return false; }
virtual bool animatesMatFrame(const AppSequence* appSeq) { return false; }
virtual bool animatesFrame(const AppSequence* appSeq) { return false; }
virtual bool isBillboard();
virtual bool isBillboardZAxis();
virtual bool isSkin() { return false; }
virtual void lookupSkinData() = 0;
virtual void lockMesh(F32 t, const MatrixF& objectOffset) { }
};
#endif // _APPMESH_H_

View file

@ -0,0 +1,104 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "ts/loader/appNode.h"
AppNode::AppNode()
{
mName = NULL;
mParentName = NULL;
}
AppNode::~AppNode()
{
dFree( mName );
dFree( mParentName );
// delete children and meshes
for (S32 i = 0; i < mChildNodes.size(); i++)
delete mChildNodes[i];
for (S32 i = 0; i < mMeshes.size(); i++)
delete mMeshes[i];
}
S32 AppNode::getNumMesh()
{
if (mMeshes.size() == 0)
buildMeshList();
return mMeshes.size();
}
AppMesh* AppNode::getMesh(S32 idx)
{
return (idx < getNumMesh() && idx >= 0) ? mMeshes[idx] : NULL;
}
S32 AppNode::getNumChildNodes()
{
if (mChildNodes.size() == 0)
buildChildList();
return mChildNodes.size();
}
AppNode * AppNode::getChildNode(S32 idx)
{
return (idx < getNumChildNodes() && idx >= 0) ? mChildNodes[idx] : NULL;
}
bool AppNode::isBillboard()
{
return !dStrnicmp(getName(),"BB::",4) || !dStrnicmp(getName(),"BB_",3) || isBillboardZAxis();
}
bool AppNode::isBillboardZAxis()
{
return !dStrnicmp(getName(),"BBZ::",5) || !dStrnicmp(getName(),"BBZ_",4);
}
bool AppNode::isDummy()
{
// naming convention should work well enough...
// ...but can override this method if one wants more
return !dStrnicmp(getName(), "dummy", 5);
}
bool AppNode::isBounds()
{
// naming convention should work well enough...
// ...but can override this method if one wants more
return !dStricmp(getName(), "bounds");
}
bool AppNode::isSequence()
{
// naming convention should work well enough...
// ...but can override this method if one wants more
return !dStrnicmp(getName(), "Sequence", 8);
}
bool AppNode::isRoot()
{
// we assume root node isn't added, so this is never true
// but allow for possibility (by overriding this method)
// so that isParentRoot still works.
return false;
}

View file

@ -0,0 +1,88 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _APPNODE_H_
#define _APPNODE_H_
#ifndef _MMATH_H_
#include "math/mMath.h"
#endif
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
#ifndef _APPMESH_H_
#include "ts/loader/appMesh.h"
#endif
class AppNode
{
friend class TSShapeLoader;
// add attached meshes and child nodes to app node
// the reason these are tracked by AppNode is that
// AppNode is responsible for deleting all it's children
// and attached meshes.
virtual void buildMeshList() = 0;
virtual void buildChildList() = 0;
protected:
S32 mParentIndex;
Vector<AppMesh*> mMeshes;
Vector<AppNode*> mChildNodes;
char* mName;
char* mParentName;
public:
AppNode();
virtual ~AppNode();
S32 getNumMesh();
AppMesh* getMesh(S32 idx);
S32 getNumChildNodes();
AppNode* getChildNode(S32 idx);
virtual MatrixF getNodeTransform(F32 time) = 0;
virtual bool isEqual(AppNode* node) = 0;
virtual bool animatesTransform(const AppSequence* appSeq) = 0;
virtual const char* getName() = 0;
virtual const char* getParentName() = 0;
virtual bool getFloat(const char* propName, F32& defaultVal) = 0;
virtual bool getInt(const char* propName, S32& defaultVal) = 0;
virtual bool getBool(const char* propName, bool& defaultVal) = 0;
virtual bool isBillboard();
virtual bool isBillboardZAxis();
virtual bool isParentRoot() = 0;
virtual bool isDummy();
virtual bool isBounds();
virtual bool isSequence();
virtual bool isRoot();
};
#endif // _APPNODE_H_

View file

@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _APPSEQUENCE_H_
#define _APPSEQUENCE_H_
#ifndef _MMATH_H_
#include "math/mMath.h"
#endif
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
#ifndef _TSSHAPE_H_
#include "ts/tsShape.h"
#endif
class AppSequence
{
public:
S32 fps;
public:
AppSequence() { }
virtual ~AppSequence() { }
virtual void setActive(bool active) { }
virtual S32 getNumTriggers() const { return 0; }
virtual void getTrigger(S32 index, TSShape::Trigger& trigger) const { trigger.state = 0;}
virtual const char* getName() const { return "ambient"; }
virtual F32 getStart() const { return 0.0f; }
virtual F32 getEnd() const { return 0.0f; }
virtual U32 getFlags() const { return 0; }
virtual F32 getPriority() const { return 5; }
virtual F32 getBlendRefTime() const { return 0.0f; }
};
#endif // _APPSEQUENCE_H_

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,183 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _TSSHAPE_LOADER_H_
#define _TSSHAPE_LOADER_H_
#ifndef _MMATH_H_
#include "math/mMath.h"
#endif
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
#ifndef _TSSHAPE_H_
#include "ts/tsShape.h"
#endif
#ifndef _APPNODE_H_
#include "ts/loader/appNode.h"
#endif
#ifndef _APPMESH_H_
#include "ts/loader/appMesh.h"
#endif
#ifndef _APPSEQUENCE_H_
#include "ts/loader/appSequence.h"
#endif
class TSShapeLoader
{
public:
enum eLoadPhases
{
Load_ReadFile = 0,
Load_ParseFile,
Load_ExternalRefs,
Load_EnumerateScene,
Load_GenerateSubshapes,
Load_GenerateObjects,
Load_GenerateDefaultStates,
Load_GenerateSkins,
Load_GenerateMaterials,
Load_GenerateSequences,
Load_InitShape,
NumLoadPhases,
Load_Complete = NumLoadPhases
};
static void updateProgress(int major, const char* msg, int numMinor=0, int minor=0);
protected:
struct Subshape
{
Vector<AppNode*> branches; ///< Shape branches
Vector<AppMesh*> objMeshes; ///< Object meshes for this subshape
Vector<S32> objNodes; ///< AppNode indices with objects attached
~Subshape()
{
// Delete children
for (S32 i = 0; i < branches.size(); i++)
delete branches[i];
}
};
public:
static const F32 DefaultTime;
static const double MinFrameRate;
static const double MaxFrameRate;
static const double AppGroundFrameRate;
protected:
// Variables used during loading that must be held until the shape is deleted
TSShape* shape;
Vector<AppMesh*> appMeshes;
// Variables used during loading, but that can be discarded afterwards
static Torque::Path shapePath;
AppNode* boundsNode;
Vector<AppNode*> appNodes; ///< Nodes in the loaded shape
Vector<AppSequence*> appSequences;
Vector<Subshape*> subshapes;
Vector<QuatF*> nodeRotCache;
Vector<Point3F*> nodeTransCache;
Vector<QuatF*> nodeScaleRotCache;
Vector<Point3F*> nodeScaleCache;
Point3F shapeOffset; ///< Offset used to translate the shape origin
//--------------------------------------------------------------------------
// Collect the nodes, objects and sequences for the scene
virtual void enumerateScene() = 0;
bool processNode(AppNode* node);
virtual bool ignoreNode(const String& name) { return false; }
virtual bool ignoreMesh(const String& name) { return false; }
void addSkin(AppMesh* mesh);
void addDetailMesh(AppMesh* mesh);
void addSubshape(AppNode* node);
void addObject(AppMesh* mesh, S32 nodeIndex, S32 subShapeNum);
// Node transform methods
MatrixF getLocalNodeMatrix(AppNode* node, F32 t);
void generateNodeTransform(AppNode* node, F32 t, bool blend, F32 referenceTime,
QuatF& rot, Point3F& trans, QuatF& srot, Point3F& scale);
virtual void computeBounds(Box3F& bounds);
// Create objects, materials and sequences
void recurseSubshape(AppNode* appNode, S32 parentIndex, bool recurseChildren);
void generateSubshapes();
void generateObjects();
void generateSkins();
void generateDefaultStates();
void generateObjectState(TSShape::Object& obj, F32 t, bool addFrame, bool addMatFrame);
void generateFrame(TSShape::Object& obj, F32 t, bool addFrame, bool addMatFrame);
void generateMaterialList();
void generateSequences();
// Determine what is actually animated in the sequence
void setNodeMembership(TSShape::Sequence& seq, const AppSequence* appSeq);
void setRotationMembership(TSShape::Sequence& seq);
void setTranslationMembership(TSShape::Sequence& seq);
void setScaleMembership(TSShape::Sequence& seq);
void setObjectMembership(TSShape::Sequence& seq, const AppSequence* appSeq);
// Manage a cache of all node transform elements for the sequence
void clearNodeTransformCache();
void fillNodeTransformCache(TSShape::Sequence& seq, const AppSequence* appSeq);
// Add node transform elements
void addNodeRotation(QuatF& rot, bool defaultVal);
void addNodeTranslation(Point3F& trans, bool defaultVal);
void addNodeUniformScale(F32 scale);
void addNodeAlignedScale(Point3F& scale);
void addNodeArbitraryScale(QuatF& qrot, Point3F& scale);
// Generate animation data
void generateNodeAnimation(TSShape::Sequence& seq);
void generateObjectAnimation(TSShape::Sequence& seq, const AppSequence* appSeq);
void generateGroundAnimation(TSShape::Sequence& seq, const AppSequence* appSeq);
void generateFrameTriggers(TSShape::Sequence& seq, const AppSequence* appSeq);
// Shape construction
void sortDetails();
void install();
public:
TSShapeLoader() : boundsNode(0) { }
virtual ~TSShapeLoader();
static const Torque::Path& getShapePath() { return shapePath; }
static void zapScale(MatrixF& mat);
TSShape* generateShape(const Torque::Path& path);
};
#endif // _TSSHAPE_LOADER_H_