Torque3D Documentation / _generateds / colladaAppNode.h

colladaAppNode.h

Engine/source/ts/collada/colladaAppNode.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 _COLLADA_APPNODE_H_
 25#define _COLLADA_APPNODE_H_
 26
 27#ifndef _TDICTIONARY_H_
 28#include "core/util/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
 37class ColladaAppNode : public AppNode
 38{
 39   typedef AppNode Parent;
 40   friend class ColladaAppMesh;
 41
 42   MatrixF getTransform(F32 time);
 43   void buildMeshList();
 44   void buildChildList();
 45
 46protected:
 47
 48   const domNode*             p_domNode;        ///< Pointer to the node in the Collada DOM
 49   ColladaAppNode*            appParent;        ///< Parent node in Collada-space
 50   ColladaExtension_node*     nodeExt;          ///< node extension
 51   Vector<AnimatedFloatList>  nodeTransforms;   ///< Ordered vector of node transform elements (scale, translate etc)
 52   bool                       invertMeshes;     ///< True if this node's coordinate space is inverted (left handed)
 53
 54   Map<StringTableEntry, F32> mProps;           ///< Hash of float properties (converted to int or bool as needed)
 55
 56   F32                        lastTransformTime;      ///< Time of the last transform lookup (getTransform)
 57   MatrixF                    lastTransform;          ///< Last transform lookup (getTransform)
 58   bool                       defaultTransformValid;  ///< Flag indicating whether the defaultNodeTransform is valid
 59   MatrixF                    defaultNodeTransform;   ///< Transform at DefaultTime
 60
 61public:
 62
 63   ColladaAppNode(const domNode* node, ColladaAppNode* parent = 0);
 64   virtual ~ColladaAppNode()
 65   {
 66      delete nodeExt;
 67      mProps.clear();
 68   }
 69
 70   const domNode* getDomNode() const { return p_domNode; }
 71
 72   //-----------------------------------------------------------------------
 73   const char *getName() { return mName; }
 74   const char *getParentName() { return mParentName; }
 75
 76   bool isEqual(AppNode* node)
 77   {
 78      const ColladaAppNode* appNode = dynamic_cast<const ColladaAppNode*>(node);
 79      return (appNode && (appNode->p_domNode == p_domNode));
 80   }
 81
 82   // Property look-ups: only float properties are stored, the rest are
 83   // converted from floats as needed
 84   bool getFloat(const char* propName, F32& defaultVal)
 85   {
 86      Map<StringTableEntry,F32>::Iterator itr = mProps.find(propName);
 87      if (itr != mProps.end())
 88         defaultVal = itr->value;
 89      return false;
 90   }
 91   bool getInt(const char* propName, S32& defaultVal)
 92   {
 93      F32 value = defaultVal;
 94      bool ret = getFloat(propName, value);
 95      defaultVal = (S32)value;
 96      return ret;
 97   }
 98   bool getBool(const char* propName, bool& defaultVal)
 99   {
100      F32 value = defaultVal;
101      bool ret = getFloat(propName, value);
102      defaultVal = (value != 0);
103      return ret;
104   }
105
106   MatrixF getNodeTransform(F32 time);
107   bool animatesTransform(const AppSequence* appSeq);
108   bool isParentRoot() { return (appParent == NULL); }
109};
110
111#endif // _COLLADA_APPNODE_H_
112