Now importing bone / skeleton structure from FBX files.
Object names from FBX files are now concatenated with the FBX numerical ID to ensure that they are unique --HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40178
This commit is contained in:
@@ -103,6 +103,10 @@
|
||||
E47C25A513F4F66F00FF4370 /* KRShader.h in Headers */ = {isa = PBXBuildFile; fileRef = E47C25A413F4F66F00FF4370 /* KRShader.h */; };
|
||||
E47C25A713F4F6AB00FF4370 /* KRShaderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */; };
|
||||
E47C25A913F4F6DD00FF4370 /* KRShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47C25A813F4F6DD00FF4370 /* KRShader.cpp */; };
|
||||
E480BE681671C641004EC8AD /* KRBone.h in Headers */ = {isa = PBXBuildFile; fileRef = E480BE671671C641004EC8AD /* KRBone.h */; };
|
||||
E480BE691671C641004EC8AD /* KRBone.h in Headers */ = {isa = PBXBuildFile; fileRef = E480BE671671C641004EC8AD /* KRBone.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E480BE6C1671C653004EC8AD /* KRBone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E480BE6B1671C653004EC8AD /* KRBone.cpp */; };
|
||||
E480BE6D1671C653004EC8AD /* KRBone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E480BE6B1671C653004EC8AD /* KRBone.cpp */; };
|
||||
E488399415F928CA00BD66D5 /* KRBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E488399215F928CA00BD66D5 /* KRBundle.cpp */; };
|
||||
E488399515F928CA00BD66D5 /* KRBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E488399215F928CA00BD66D5 /* KRBundle.cpp */; };
|
||||
E488399615F928CA00BD66D5 /* KRBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = E488399315F928CA00BD66D5 /* KRBundle.h */; };
|
||||
@@ -306,6 +310,8 @@
|
||||
E47C25A413F4F66F00FF4370 /* KRShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRShader.h; path = Classes/KRShader.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRShaderManager.cpp; path = Classes/KRShaderManager.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRShader.cpp; path = Classes/KRShader.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
E480BE671671C641004EC8AD /* KRBone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRBone.h; path = Classes/KRBone.h; sourceTree = "<group>"; };
|
||||
E480BE6B1671C653004EC8AD /* KRBone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRBone.cpp; path = Classes/KRBone.cpp; sourceTree = "<group>"; };
|
||||
E48278AE15F03010001C9431 /* visualize_overlay.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = visualize_overlay.vsh; path = Shaders/visualize_overlay.vsh; sourceTree = "<group>"; };
|
||||
E488399215F928CA00BD66D5 /* KRBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRBundle.cpp; path = Classes/KRBundle.cpp; sourceTree = "<group>"; };
|
||||
E488399315F928CA00BD66D5 /* KRBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRBundle.h; path = Classes/KRBundle.h; sourceTree = "<group>"; };
|
||||
@@ -643,6 +649,8 @@
|
||||
E461A171152E599E00F2044A /* Lights */,
|
||||
E4F975311536220900FD60B2 /* KRNode.h */,
|
||||
E4F975351536221C00FD60B2 /* KRNode.cpp */,
|
||||
E480BE671671C641004EC8AD /* KRBone.h */,
|
||||
E480BE6B1671C653004EC8AD /* KRBone.cpp */,
|
||||
);
|
||||
name = "Scene Graph Nodes";
|
||||
sourceTree = "<group>";
|
||||
@@ -832,6 +840,7 @@
|
||||
E428C311166971FF00A16EDF /* KRAnimationLayer.h in Headers */,
|
||||
E428C3161669A24B00A16EDF /* KRAnimationAttribute.h in Headers */,
|
||||
E416AA9916713749000F6786 /* KRAnimationCurveManager.h in Headers */,
|
||||
E480BE681671C641004EC8AD /* KRBone.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -883,6 +892,7 @@
|
||||
E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */,
|
||||
E4030E4D160A3CF000592648 /* KRStockGeometry.h in Headers */,
|
||||
E4B175AF161F5A1000B8FB80 /* KRTexture.h in Headers */,
|
||||
E480BE691671C641004EC8AD /* KRBone.h in Headers */,
|
||||
E4B175B5161F5FAF00B8FB80 /* KRTextureCube.h in Headers */,
|
||||
E4CA10E61637BD0A005D9400 /* KRTexturePVR.h in Headers */,
|
||||
E4CA10ED1637BD47005D9400 /* KRTextureTGA.h in Headers */,
|
||||
@@ -1024,6 +1034,7 @@
|
||||
E428C313166971FF00A16EDF /* KRAnimationLayer.cpp in Sources */,
|
||||
E428C3191669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */,
|
||||
E416AA9C1671375C000F6786 /* KRAnimationCurveManager.cpp in Sources */,
|
||||
E480BE6C1671C653004EC8AD /* KRBone.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -1080,6 +1091,7 @@
|
||||
E428C314166971FF00A16EDF /* KRAnimationLayer.cpp in Sources */,
|
||||
E428C31A1669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */,
|
||||
E416AA9D1671375C000F6786 /* KRAnimationCurveManager.cpp in Sources */,
|
||||
E480BE6D1671C653004EC8AD /* KRBone.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -121,11 +121,12 @@ void KRAnimationCurve::setFrameStart(int frame_number)
|
||||
|
||||
float KRAnimationCurve::getValue(int frame_number)
|
||||
{
|
||||
//printf("frame_number: %i\n", frame_number);
|
||||
int clamped_frame = frame_number;
|
||||
if(frame_number < 0) {
|
||||
clamped_frame = frame_number;
|
||||
} else if(frame_number > getFrameCount()) {
|
||||
clamped_frame = getFrameCount();
|
||||
} else if(frame_number >= getFrameCount()) {
|
||||
clamped_frame = getFrameCount()-1;
|
||||
}
|
||||
float *frame_data = (float *)((char *)m_pData->getStart() + sizeof(animation_curve_header));
|
||||
return frame_data[clamped_frame];
|
||||
|
||||
34
KREngine/KREngine/Classes/KRBone.cpp
Normal file
34
KREngine/KREngine/Classes/KRBone.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// KRBone.cpp
|
||||
// KREngine
|
||||
//
|
||||
// Created by Kearwood Gilbert on 2012-12-06.
|
||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#include "KRBone.h"
|
||||
|
||||
KRBone::KRBone(KRScene &scene, std::string name) : KRNode(scene, name)
|
||||
{
|
||||
}
|
||||
|
||||
KRBone::~KRBone()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string KRBone::getElementName() {
|
||||
return "bone";
|
||||
}
|
||||
|
||||
tinyxml2::XMLElement *KRBone::saveXML( tinyxml2::XMLNode *parent)
|
||||
{
|
||||
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
void KRBone::loadXML(tinyxml2::XMLElement *e)
|
||||
{
|
||||
KRNode::loadXML(e);
|
||||
}
|
||||
29
KREngine/KREngine/Classes/KRBone.h
Normal file
29
KREngine/KREngine/Classes/KRBone.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// KRBone.h
|
||||
// KREngine
|
||||
//
|
||||
// Created by Kearwood Gilbert on 2012-12-06.
|
||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef KRBONE_H
|
||||
#define KRBONE_H
|
||||
|
||||
#import "KRResource.h"
|
||||
#import "KRNode.h"
|
||||
#import "KRTexture.h"
|
||||
|
||||
class KRBone : public KRNode {
|
||||
public:
|
||||
KRBone(KRScene &scene, std::string name);
|
||||
virtual ~KRBone();
|
||||
virtual std::string getElementName();
|
||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -6,8 +6,8 @@
|
||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef KREngine_KRLight_h
|
||||
#define KREngine_KRLight_h
|
||||
#ifndef KRLIGHT_H
|
||||
#define KRLIGHT_H
|
||||
|
||||
#import "KRResource.h"
|
||||
#import "KRNode.h"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#import "KRParticleSystemNewtonian.h"
|
||||
#import "KRAABB.h"
|
||||
#import "KRQuaternion.h"
|
||||
#import "KRBone.h"
|
||||
|
||||
|
||||
KRNode::KRNode(KRScene &scene, std::string name) : KRContextObject(scene.getContext())
|
||||
@@ -165,6 +166,8 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
|
||||
faces_camera = false;
|
||||
}
|
||||
new_node = new KRInstance(scene, szName, szName, e->Attribute("light_map"), lod_min_coverage, receives_shadow, faces_camera);
|
||||
} else if(strcmp(szElementName, "bone") == 0) {
|
||||
new_node = new KRBone(scene, szName);
|
||||
}
|
||||
|
||||
if(new_node) {
|
||||
@@ -252,33 +255,45 @@ bool KRNode::hasPhysics()
|
||||
|
||||
void KRNode::SetAttribute(node_attribute_type attrib, float v)
|
||||
{
|
||||
const float DEGREES_TO_RAD = M_2_PI / 360.0f;
|
||||
|
||||
printf("%s - ", m_name.c_str());
|
||||
switch(attrib) {
|
||||
case KRENGINE_NODE_ATTRIBUTE_TRANSLATE_X:
|
||||
printf("translate_x: %f\n", v);
|
||||
setLocalTranslation(KRVector3(v, m_localTranslation.y, m_localTranslation.z));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Y:
|
||||
printf("translate_y: %f\n", v);
|
||||
setLocalTranslation(KRVector3(m_localTranslation.x, v, m_localTranslation.z));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Z:
|
||||
printf("translate_z: %f\n", v);
|
||||
setLocalTranslation(KRVector3(m_localTranslation.x, m_localTranslation.y, v));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_SCALE_X:
|
||||
printf("scale_x: %f\n", v);
|
||||
setLocalScale(KRVector3(v, m_localScale.y, m_localScale.z));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_SCALE_Y:
|
||||
printf("scale_y: %f\n", v);
|
||||
setLocalScale(KRVector3(m_localScale.x, v, m_localScale.z));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_SCALE_Z:
|
||||
printf("scale_z: %f\n", v);
|
||||
setLocalScale(KRVector3(m_localScale.x, m_localScale.y, v));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_ROTATE_X:
|
||||
setLocalRotation(KRVector3(v / M_PI_2, m_localRotation.y, m_localRotation.z));
|
||||
printf("rotate_x: %f\n", v);
|
||||
setLocalRotation(KRVector3(v * DEGREES_TO_RAD, m_localRotation.y, m_localRotation.z));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_ROTATE_Y:
|
||||
setLocalRotation(KRVector3(m_localRotation.x, v / M_PI_2, m_localRotation.z));
|
||||
printf("rotate_y: %f\n", v);
|
||||
setLocalRotation(KRVector3(m_localRotation.x, v * DEGREES_TO_RAD, m_localRotation.z));
|
||||
break;
|
||||
case KRENGINE_NODE_ATTRIBUTE_ROTATE_Z:
|
||||
setLocalRotation(KRVector3(m_localRotation.x, m_localRotation.y, v / M_PI_2));
|
||||
printf("rotate_z: %f\n", v);
|
||||
setLocalRotation(KRVector3(m_localRotation.x, m_localRotation.y, v * DEGREES_TO_RAD));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "KRNode.h"
|
||||
#include "KRScene.h"
|
||||
#include "KRQuaternion.h"
|
||||
#include "KRBone.h"
|
||||
|
||||
#ifdef IOS_REF
|
||||
#undef IOS_REF
|
||||
@@ -48,21 +49,20 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
//void BakeNode(KFbxNode* pNode);
|
||||
KRNode *LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, FbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
||||
KRNode *LoadLight(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode);
|
||||
std::string GetFbxObjectName(FbxObject *obj, char *prefix);
|
||||
KRNode *LoadSkeleton(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode);
|
||||
std::string GetFbxObjectName(FbxObject *obj);
|
||||
|
||||
const float KRAKEN_FBX_ANIMATION_FRAMERATE = 30.0f; // FINDME - This should be configurable
|
||||
|
||||
|
||||
std::string GetFbxObjectName(FbxObject *obj, char *prefix)
|
||||
std::string GetFbxObjectName(FbxObject *obj)
|
||||
{
|
||||
|
||||
std::stringstream st;
|
||||
st << prefix;
|
||||
st << "fbx_";
|
||||
st << obj->GetUniqueID();
|
||||
if(strlen(obj->GetName()) != 0) {
|
||||
st << " (";
|
||||
st << "_";
|
||||
st << obj->GetName();
|
||||
st << ")";
|
||||
}
|
||||
return st.str();
|
||||
}
|
||||
@@ -325,7 +325,7 @@ KRAnimation *LoadAnimation(KRContext &context, FbxAnimStack* pAnimStack)
|
||||
|
||||
KRAnimationCurve *LoadAnimationCurve(KRContext &context, FbxAnimCurve* pAnimCurve)
|
||||
{
|
||||
std::string name = GetFbxObjectName(pAnimCurve, "fbx_curve");
|
||||
std::string name = GetFbxObjectName(pAnimCurve);
|
||||
printf("Loading animation curve: \"%s\"\n", name.c_str());
|
||||
FbxTimeSpan time_span;
|
||||
if(!pAnimCurve->GetTimeInterval(time_span)) {
|
||||
@@ -520,6 +520,7 @@ KRAnimationLayer *LoadAnimationLayer(KRContext &context, FbxAnimLayer *pAnimLaye
|
||||
void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource *> &resources, FbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
||||
KFbxVector4 lTmpVector;
|
||||
pNode->UpdatePropertiesFromPivotsAndLimits();
|
||||
|
||||
// Transform = T * Roff * Rp * Rpre * R * Rpost * inverse(Rp) * Soff * Sp * S * inverse(Sp)
|
||||
|
||||
// Import animated properties
|
||||
@@ -536,8 +537,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
FbxAnimCurve *pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -545,8 +546,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -554,8 +555,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclRotation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_ROTATE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -563,8 +564,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -572,8 +573,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -581,8 +582,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclTranslation.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_TRANSLATE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -590,8 +591,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_X);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -599,8 +600,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_Y);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -608,8 +609,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
pAnimCurve = pNode->LclScaling.GetCurve(pFbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);
|
||||
if(pAnimCurve) {
|
||||
KRAnimationAttribute *new_attribute = new KRAnimationAttribute(parent_node->getContext());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve, "fbx_curve"));
|
||||
new_attribute->setTargetName(pNode->GetName());
|
||||
new_attribute->setCurveName(GetFbxObjectName(pAnimCurve));
|
||||
new_attribute->setTargetName(GetFbxObjectName(pNode));
|
||||
new_attribute->setTargetAttribute(KRNode::KRENGINE_NODE_ATTRIBUTE_SCALE_Z);
|
||||
pAnimationLayer->addAttribute(new_attribute);
|
||||
}
|
||||
@@ -655,7 +656,6 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
// printf(" Local Scaling: %f %f %f\n", local_scale[0], local_scale[1], local_scale[2]);
|
||||
|
||||
KRNode *new_node = NULL;
|
||||
|
||||
KFbxNodeAttribute::EType attribute_type = (pNode->GetNodeAttribute()->GetAttributeType());
|
||||
switch(attribute_type) {
|
||||
case KFbxNodeAttribute::eMesh:
|
||||
@@ -664,11 +664,14 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
case KFbxNodeAttribute::eLight:
|
||||
new_node = LoadLight(parent_node, resources, pNode);
|
||||
break;
|
||||
case KFbxNodeAttribute::eSkeleton:
|
||||
new_node = LoadSkeleton(parent_node, resources, pNode);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if(pNode->GetChildCount() > 0) {
|
||||
// Create an empty node, for inheritence of transforms
|
||||
new_node = new KRNode(parent_node->getScene(), pNode->GetName());
|
||||
new_node = new KRNode(parent_node->getScene(), GetFbxObjectName(pNode));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -690,8 +693,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, std::vector<KRResource
|
||||
}
|
||||
|
||||
KRNode *LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, FbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
||||
|
||||
printf("Mesh: %s\n", pNode->GetName());
|
||||
std::string name = GetFbxObjectName(pNode);
|
||||
printf("Mesh: %s\n", name.c_str());
|
||||
KFbxMesh* pSourceMesh = (KFbxMesh*) pNode->GetNodeAttribute();
|
||||
KFbxMesh* pMesh = pGeometryConverter->TriangulateMesh(pSourceMesh);
|
||||
|
||||
@@ -994,7 +997,7 @@ KRNode *LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, FbxG
|
||||
std::string light_map = pNode->GetName();
|
||||
light_map.append("_lightmap");
|
||||
|
||||
KRInstance *new_instance = new KRInstance(parent_node->getScene(), pNode->GetName(), pNode->GetName(), light_map, 0.0f, true, false);
|
||||
KRInstance *new_instance = new KRInstance(parent_node->getScene(), name, pNode->GetName(), light_map, 0.0f, true, false);
|
||||
return new_instance;
|
||||
} else {
|
||||
return NULL;
|
||||
@@ -1002,6 +1005,12 @@ KRNode *LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, FbxG
|
||||
|
||||
}
|
||||
|
||||
KRNode *LoadSkeleton(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode) {
|
||||
std::string name = GetFbxObjectName(pNode);
|
||||
KRBone *new_bone = new KRBone(parent_node->getScene(), name.c_str());
|
||||
return new_bone;
|
||||
}
|
||||
|
||||
KRNode *LoadLight(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode) {
|
||||
const GLfloat PI = 3.14159265;
|
||||
const GLfloat d2r = PI * 2 / 360;
|
||||
|
||||
Reference in New Issue
Block a user