2019-02-08 22:25:43 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// 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 _ASSIMP_APPNODE_H_
|
|
|
|
|
#define _ASSIMP_APPNODE_H_
|
|
|
|
|
|
|
|
|
|
#ifndef _TDICTIONARY_H_
|
|
|
|
|
#include "core/tDictionary.h"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _APPNODE_H_
|
|
|
|
|
#include "ts/loader/appNode.h"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _COLLADA_EXTENSIONS_H_
|
|
|
|
|
#include "ts/collada/colladaExtensions.h"
|
|
|
|
|
#endif
|
2024-12-12 14:32:20 +00:00
|
|
|
|
2025-05-04 09:16:49 +00:00
|
|
|
|
|
|
|
|
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
|
|
|
|
#ifdef new
|
|
|
|
|
#undef new
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-03-24 10:18:20 +00:00
|
|
|
#ifndef AI_TYPES_H_INC
|
|
|
|
|
#include <assimp/types.h>
|
|
|
|
|
#endif
|
2019-04-18 20:45:52 +00:00
|
|
|
#include <assimp/scene.h>
|
2019-03-24 10:18:20 +00:00
|
|
|
|
2025-05-04 09:16:49 +00:00
|
|
|
#if !defined(TORQUE_DISABLE_MEMORY_MANAGER)
|
|
|
|
|
# define _new new(__FILE__, __LINE__)
|
|
|
|
|
# define new _new
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-12-12 14:32:20 +00:00
|
|
|
class AssimpAppMesh;
|
|
|
|
|
|
2019-02-08 22:25:43 +00:00
|
|
|
class AssimpAppNode : public AppNode
|
|
|
|
|
{
|
|
|
|
|
typedef AppNode Parent;
|
|
|
|
|
friend class AssimpAppMesh;
|
|
|
|
|
|
|
|
|
|
MatrixF getTransform(F32 time);
|
2019-04-18 20:45:52 +00:00
|
|
|
void getAnimatedTransform(MatrixF& mat, F32 t, aiAnimation* animSeq);
|
2024-12-10 11:54:13 +00:00
|
|
|
Point3F interpolateVectorKey(const aiVectorKey* keys, U32 numKeys, F32 frameTime);
|
|
|
|
|
QuatF interpolateQuaternionKey(const aiQuatKey* keys, U32 numKeys, F32 frameTime);
|
2025-09-23 14:59:24 +00:00
|
|
|
void buildMeshList() override;
|
|
|
|
|
void buildChildList() override;
|
2019-02-08 22:25:43 +00:00
|
|
|
protected:
|
|
|
|
|
|
2024-12-09 23:24:09 +00:00
|
|
|
const aiScene* mScene;
|
|
|
|
|
const aiNode* mNode; ///< Pointer to the assimp scene node
|
2024-12-11 15:38:17 +00:00
|
|
|
AssimpAppNode* appParent; ///< Parent node
|
|
|
|
|
MatrixF mNodeTransform; ///< Scene node transform converted to TorqueSpace (filled for ALL nodes)
|
2019-03-24 10:18:20 +00:00
|
|
|
|
2024-12-11 15:38:17 +00:00
|
|
|
bool mInvertMeshes; ///< True if this node's coordinate space is inverted (left handed)
|
|
|
|
|
F32 mLastTransformTime; ///< Time of the last transform lookup (getTransform)
|
|
|
|
|
MatrixF mLastTransform; ///< Last transform lookup (getTransform) (Only Non-Dummy Nodes)
|
|
|
|
|
bool mDefaultTransformValid; ///< Flag indicating whether the defaultNodeTransform is valid
|
|
|
|
|
MatrixF mDefaultNodeTransform; ///< Transform at DefaultTime (Only Non-Dummy Nodes)
|
2019-02-08 22:25:43 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2024-12-11 15:38:17 +00:00
|
|
|
AssimpAppNode(const aiScene* scene, const aiNode* node, AssimpAppNode* parentNode = nullptr);
|
2019-02-08 22:25:43 +00:00
|
|
|
virtual ~AssimpAppNode()
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-18 20:45:52 +00:00
|
|
|
static aiAnimation* sActiveSequence;
|
2019-04-22 10:52:59 +00:00
|
|
|
static F32 sTimeMultiplier;
|
2019-04-18 20:45:52 +00:00
|
|
|
|
2019-02-08 22:25:43 +00:00
|
|
|
//-----------------------------------------------------------------------
|
2024-03-18 18:40:22 +00:00
|
|
|
const char *getName() override { return mName; }
|
|
|
|
|
const char *getParentName() override { return mParentName; }
|
2019-02-08 22:25:43 +00:00
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
bool isEqual(AppNode* node) override
|
2019-02-08 22:25:43 +00:00
|
|
|
{
|
|
|
|
|
const AssimpAppNode* appNode = dynamic_cast<const AssimpAppNode*>(node);
|
|
|
|
|
return (appNode && (appNode->mNode == mNode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Property look-ups: only float properties are stored, the rest are
|
|
|
|
|
// converted from floats as needed
|
2024-03-18 18:40:22 +00:00
|
|
|
bool getFloat(const char* propName, F32& defaultVal) override
|
2019-02-08 22:25:43 +00:00
|
|
|
{
|
|
|
|
|
//Map<StringTableEntry,F32>::Iterator itr = mProps.find(propName);
|
|
|
|
|
//if (itr != mProps.end())
|
|
|
|
|
// defaultVal = itr->value;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-03-18 18:40:22 +00:00
|
|
|
bool getInt(const char* propName, S32& defaultVal) override
|
2019-02-08 22:25:43 +00:00
|
|
|
{
|
|
|
|
|
F32 value = defaultVal;
|
|
|
|
|
bool ret = getFloat(propName, value);
|
|
|
|
|
defaultVal = (S32)value;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2024-03-18 18:40:22 +00:00
|
|
|
bool getBool(const char* propName, bool& defaultVal) override
|
2019-02-08 22:25:43 +00:00
|
|
|
{
|
|
|
|
|
F32 value = defaultVal;
|
|
|
|
|
bool ret = getFloat(propName, value);
|
|
|
|
|
defaultVal = (value != 0);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 18:40:22 +00:00
|
|
|
MatrixF getNodeTransform(F32 time) override;
|
|
|
|
|
bool animatesTransform(const AppSequence* appSeq) override;
|
|
|
|
|
bool isParentRoot() override { return (appParent == NULL); }
|
2019-03-24 10:18:20 +00:00
|
|
|
|
|
|
|
|
static void assimpToTorqueMat(const aiMatrix4x4& inAssimpMat, MatrixF& outMat);
|
2019-03-27 16:46:43 +00:00
|
|
|
static aiNode* findChildNodeByName(const char* nodeName, aiNode* rootNode);
|
2024-12-11 15:38:17 +00:00
|
|
|
|
2024-12-11 21:12:55 +00:00
|
|
|
void addChild(AssimpAppNode* child);
|
|
|
|
|
void addMesh(AssimpAppMesh* child);
|
2019-02-08 22:25:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // _ASSIMP_APPNODE_H_
|