Implemented KRLocator::getUserAttributes(), which returns a list of additional properties enumerated from fbx files so client code can convert locators into application-specific objects
--HG-- branch : nfb
This commit is contained in:
@@ -33,3 +33,8 @@ void KRLocator::loadXML(tinyxml2::XMLElement *e)
|
|||||||
{
|
{
|
||||||
KRNode::loadXML(e);
|
KRNode::loadXML(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unordered_map<std::string, boost::variant<int, double, bool, std::string> > &KRLocator::getUserAttributes()
|
||||||
|
{
|
||||||
|
return m_userAttributes;
|
||||||
|
}
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
#include "KRNode.h"
|
#include "KRNode.h"
|
||||||
#include "KRTexture.h"
|
#include "KRTexture.h"
|
||||||
|
|
||||||
|
#include "boost/variant.hpp"
|
||||||
|
|
||||||
class KRLocator : public KRNode {
|
class KRLocator : public KRNode {
|
||||||
public:
|
public:
|
||||||
KRLocator(KRScene &scene, std::string name);
|
KRLocator(KRScene &scene, std::string name);
|
||||||
@@ -20,7 +22,10 @@ public:
|
|||||||
virtual std::string getElementName();
|
virtual std::string getElementName();
|
||||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
|
unordered_map<std::string, boost::variant<int, double, bool, std::string> > &getUserAttributes();
|
||||||
|
|
||||||
|
private:
|
||||||
|
unordered_map<std::string, boost::variant<int, double, bool, std::string> > m_userAttributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/variant.hpp>
|
||||||
#include <fbxsdk.h>
|
#include <fbxsdk.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -1610,6 +1611,40 @@ KRNode *LoadLocator(KRNode *parent_node, FbxScene* pFbxScene, FbxNode* pNode) {
|
|||||||
|
|
||||||
KRLocator *new_locator = new KRLocator(parent_node->getScene(), name.c_str());
|
KRLocator *new_locator = new KRLocator(parent_node->getScene(), name.c_str());
|
||||||
|
|
||||||
|
// Enumerate fbx properties so client code can convert locators into application-specific objects
|
||||||
|
FbxProperty fbx_property = pNode->GetFirstProperty();
|
||||||
|
while(fbx_property.IsValid()) {
|
||||||
|
std::string property_name = fbx_property.GetNameAsCStr();
|
||||||
|
boost::variant<int, double, bool, std::string> property_value = "";
|
||||||
|
switch(fbx_property.GetPropertyDataType().GetType()) {
|
||||||
|
case eFbxInt:
|
||||||
|
property_value = fbx_property.Get<FbxInt>();
|
||||||
|
break;
|
||||||
|
case eFbxDouble:
|
||||||
|
property_value = fbx_property.Get<FbxDouble>();
|
||||||
|
break;
|
||||||
|
case eFbxBool:
|
||||||
|
property_value = fbx_property.Get<FbxBool>();
|
||||||
|
break;
|
||||||
|
case eFbxFloat:
|
||||||
|
property_value = fbx_property.Get<FbxDouble>();
|
||||||
|
break;
|
||||||
|
case eFbxString:
|
||||||
|
property_value = std::string(fbx_property.Get<FbxString>().Buffer());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
fprintf(stderr, "FBX property not imported due to unsupported data type: %s.%s\n", name.c_str(), property_name.c_str());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::transform(property_name.begin(), property_name.end(), property_name.begin(), ::tolower);
|
||||||
|
|
||||||
|
new_locator->getUserAttributes()[property_name] = property_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//static bool GetBindPoseContaining(FbxScene* pScene, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
|
//static bool GetBindPoseContaining(FbxScene* pScene, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
|
||||||
// PoseList pose_list;
|
// PoseList pose_list;
|
||||||
// FbxArray<int> pose_indices;
|
// FbxArray<int> pose_indices;
|
||||||
|
|||||||
Reference in New Issue
Block a user