Torque3D Documentation / _generateds / assimpAppNode.h

assimpAppNode.h

Engine/source/ts/assimp/assimpAppNode.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _ASSIMP_APPNODE_H_
 25#define _ASSIMP_APPNODE_H_
 26
 27#ifndef _TDICTIONARY_H_
 28#include "core/tDictionary.h"
 29#endif
 30#ifndef _APPNODE_H_
 31#include "ts/loader/appNode.h"
 32#endif
 33#ifndef _COLLADA_EXTENSIONS_H_
 34#include "ts/collada/colladaExtensions.h"
 35#endif
 36
 37#ifndef AI_TYPES_H_INC
 38#include <assimp/types.h>
 39#endif
 40#include <assimp/scene.h>
 41
 42class AssimpAppNode : public AppNode
 43{
 44   typedef AppNode Parent;
 45   friend class AssimpAppMesh;
 46
 47   MatrixF getTransform(F32 time);
 48   void getAnimatedTransform(MatrixF& mat, F32 t, aiAnimation* animSeq);
 49   void buildMeshList();
 50   void buildChildList();
 51
 52protected:
 53
 54   const struct aiScene*   mScene;
 55   const struct aiNode*    mNode;                  ///< Pointer to the assimp scene node
 56   AssimpAppNode*          appParent;              ///< Parent node
 57   MatrixF                 mNodeTransform;         ///< Scene node transform converted to TorqueSpace (filled for ALL nodes)
 58
 59   bool                    mInvertMeshes;          ///< True if this node's coordinate space is inverted (left handed)
 60   F32                     mLastTransformTime;     ///< Time of the last transform lookup (getTransform)
 61   MatrixF                 mLastTransform;         ///< Last transform lookup (getTransform) (Only Non-Dummy Nodes)
 62   bool                    mDefaultTransformValid; ///< Flag indicating whether the defaultNodeTransform is valid
 63   MatrixF                 mDefaultNodeTransform;  ///< Transform at DefaultTime (Only Non-Dummy Nodes)
 64
 65public:
 66
 67   AssimpAppNode(const struct aiScene* scene, const struct aiNode* node, AssimpAppNode* parent = 0);
 68   virtual ~AssimpAppNode()
 69   {
 70      //
 71   }
 72
 73   static aiAnimation* sActiveSequence;
 74   static F32 sTimeMultiplier;
 75
 76   //-----------------------------------------------------------------------
 77   const char *getName() { return mName; }
 78   const char *getParentName() { return mParentName; }
 79
 80   bool isEqual(AppNode* node)
 81   {
 82      const AssimpAppNode* appNode = dynamic_cast<const AssimpAppNode*>(node);
 83      return (appNode && (appNode->mNode == mNode));
 84   }
 85
 86   // Property look-ups: only float properties are stored, the rest are
 87   // converted from floats as needed
 88   bool getFloat(const char* propName, F32& defaultVal)
 89   {
 90      //Map<StringTableEntry,F32>::Iterator itr = mProps.find(propName);
 91      //if (itr != mProps.end())
 92       //  defaultVal = itr->value;
 93      return false;
 94   }
 95   bool getInt(const char* propName, S32& defaultVal)
 96   {
 97      F32 value = defaultVal;
 98      bool ret = getFloat(propName, value);
 99      defaultVal = (S32)value;
100      return ret;
101   }
102   bool getBool(const char* propName, bool& defaultVal)
103   {
104      F32 value = defaultVal;
105      bool ret = getFloat(propName, value);
106      defaultVal = (value != 0);
107      return ret;
108   }
109
110   MatrixF getNodeTransform(F32 time);
111   bool animatesTransform(const AppSequence* appSeq);
112   bool isParentRoot() { return (appParent == NULL); }
113
114   static void assimpToTorqueMat(const aiMatrix4x4& inAssimpMat, MatrixF& outMat);
115   static void convertMat(MatrixF& outMat);
116   static aiNode* findChildNodeByName(const char* nodeName, aiNode* rootNode);
117};
118
119#endif // _ASSIMP_APPNODE_H_
120