-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.h
73 lines (66 loc) · 2.18 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#include <fbxsdk.h>
#include <igCore/igMetaObject.h>
#include <igAttrs/igAttr.h>
#include <igSg/igAttrSet.h>
#include <igSg/igIterateGraph.h>
using namespace Gap;
using namespace Core;
using namespace Attrs;
using namespace Sg;
using namespace fbxsdk;
namespace Converter
{
namespace Utils
{
template<class T>
T* findAttribute(igAttrSet* attributes, igInt unitID = -1)
{
igAttr* attribute = NULL;
for (igInt i = 0; i < attributes->getAttrCount(); i++)
if ((attribute = attributes->getAttr(i)) && attribute->isOfType(T::getClassMeta()) && (unitID < 0 || attribute->getUnitID() == unitID))
return static_cast<T*>(attribute);
return NULL;
};
template<class T>
T* findParentAttribute(igNode* node, igInt unitID = -1)
{
igAttrSet* attributes = NULL;
T* attribute = NULL;
while (node->getParentCount())
if ((attributes = igAttrSet::dynamicCast(node = node->getParent(0))) && (attribute = findAttribute<T>(attributes, unitID)))
return attribute;
return NULL;
};
template<class T>
T* findParentAttribute(igIterateGraph* iterator, igInt unitID = -1)
{
const igNonRefCountedNodeList* path = iterator->getCurrentPath();
igAttrSet* attributes = NULL;
T* attribute = NULL;
for (igInt i = path->getCount() - 2; i >= 0; i--)
if ((attributes = igAttrSet::dynamicCast(path->get(i))) && (attribute = findAttribute<T>(attributes, unitID)))
return attribute;
return NULL;
};
template<class T>
T* findParentNode(igIterateGraph* iterator)
{
const igNonRefCountedNodeList* path = iterator->getCurrentPath();
igNode* node = NULL;
for (igInt i = path->getCount() - 2; i >= 0; i--)
if ((node = path->get(i)) && node->isOfType(T::getClassMeta()))
return static_cast<T*>(node);
return NULL;
};
FbxDouble3 ig2FbxDouble3(igVec3f vec);
FbxDouble3 ig2FbxDouble3(igVec4f vec);
FbxDouble3 quaternion2FbxDouble3(igQuaternionf quat);
FbxVector2 ig2FbxVector2(igVec2f vec);
FbxVector4 ig2FbxVector4(igVec3f vec);
FbxVector4 ig2FbxVector4(igVec4f vec);
FbxColor ig2FbxColor(igVec4f rgba);
FbxMatrix ig2FbxMatrix(igMatrix44f mat);
void matrix2TRS(igMatrix44f* mat, igVec3f& t, igQuaternionf& r, igVec3f& s);
}
}