1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbximplementationutils.h
13#ifndef _FBXSDK_SCENE_SHADING_IMPLEMENTATION_UTILS_H_
14#define _FBXSDK_SCENE_SHADING_IMPLEMENTATION_UTILS_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/scene/shading/fbximplementation.h>
19#include <fbxsdk/scene/shading/fbxbindingoperator.h>
20#include <fbxsdk/scene/shading/fbxoperatorentryview.h>
21#include <fbxsdk/scene/shading/fbxpropertyentryview.h>
22
23#include <fbxsdk/fbxsdk_nsbegin.h>
24
25/** Get FbxImplementation from FbxObject.
26 * \param pObject FbxObject to get FbxImplementation.
27 * \param pImplementationTarget Name of the implementation property to get.
28 * \return FbxImplementation Pointer to FbxImplementation.
29 */
30FBXSDK_DLL const FbxImplementation* GetImplementation( const FbxObject* pObject, const char* pImplementationTarget );
31
32/** Get bound property value from FbxBindingTable.
33 * \param pBindingTable FbxBindingTable to get bound property value.
34 * \param pEntryName Name of the Entry type to get.
35 * \param pImplementation FbxImplementation of the bound property value to get if the Entry type is FbxOperatorEntryView::sEntryType.
36 * \param pBoundObject FbxObject of the bound property value to get if the Entry type is FbxPropertyEntryView::sEntryType.
37 * \param pValue Pointer to bound property value from FbxBindingTable.
38 * \return Whether get bound property value success or not.
39 */
40template <typename T> bool GetBoundPropertyValue(const FbxBindingTable* pBindingTable,
41 const char* pEntryName,
42 const FbxImplementation* pImplementation,
43 const FbxObject* pBoundObject,
44 T& pValue)
45{
46 if ((NULL != pImplementation) && (NULL != pBindingTable) && (NULL != pBoundObject) && (NULL != pEntryName))
47 {
48 const FbxBindingTableEntry* lEntry = pBindingTable->GetEntryForDestination(pEntryName);
49
50 if (NULL != lEntry)
51 {
52 if (strcmp(lEntry->GetEntryType(true), FbxPropertyEntryView::sEntryType) == 0)
53 {
54 const char* lPropName = lEntry->GetSource();
55 FbxProperty lProp = pBoundObject->FindPropertyHierarchical(lPropName);
56 if (lProp.IsValid())
57 {
58 pValue = lProp.Get<T>();
59 return true;
60 }
61 }
62 else if (strcmp(lEntry->GetEntryType(true), FbxOperatorEntryView::sEntryType) == 0)
63 {
64 const char* lOperatorName = lEntry->GetSource();
65 const FbxBindingOperator* lOp = pImplementation->GetOperatorByTargetName(lOperatorName);
66 if (lOp)
67 {
68 return lOp->Evaluate(pBoundObject, &pValue);
69 }
70 }
71 }
72 }
73
74 return false;
75}
76
77#include <fbxsdk/fbxsdk_nsend.h>
78
79#endif /* _FBXSDK_SCENE_SHADING_IMPLEMENTATION_UTILS_H_ */
80