Explorar el Código

Texture offsets. Seems to be a bit buggy, maybe due to a regression in FBX2016

Simon Ferquel hace 10 años
padre
commit
5be4df7aad

+ 14 - 41
Exporters/FBX/BabylonFbxNative/BabylonMaterial.cpp

@@ -307,53 +307,26 @@ BabylonTexture::BabylonTexture(FbxFileTexture* texture){
 		break;
 	}
 
-	auto translation = texture->Translation.Get();
-	auto rot = texture->Rotation.Get();
-	auto scale  = texture->Scaling.Get();
-	uOffset = static_cast<float>(translation[0]);
-	vOffset = static_cast<float>(translation[1]);
-	uScale = static_cast<float>(scale[0]);
-	vScale = static_cast<float>(scale[1]);
-	uAng = static_cast<float>(rot[0] * Euler2Rad);
-	vAng = static_cast<float>(rot[1] * Euler2Rad);
-	wAng = static_cast<float>(rot[2] * Euler2Rad);
+	babylon_vector3 rot = texture->Rotation.Get();
+	babylon_vector3 scaling = texture->Scaling.Get();
+
+	babylon_vector2 trans((float)texture->GetTranslationU(), (float)texture->GetTranslationV());
+	
+	
+	uOffset = trans.x;
+	vOffset = trans.y;
+	uScale = scaling.x;
+	vScale = scaling.y;
+	uAng = rot.x * Euler2Rad;
+	vAng = rot.y * Euler2Rad;
+	wAng = rot.z * Euler2Rad;
 	auto uwrapMode = texture->GetWrapModeU();
 	auto vwrapMode = texture->GetWrapModeV();
 	wrapU = uwrapMode == FbxTexture::eRepeat;
 	wrapV = vwrapMode == FbxTexture::eRepeat;
 
-	auto animStack = texture->GetScene()->GetSrcObject<FbxAnimStack>(0);
-	FbxString animStackName = animStack->GetName();
-	FbxTakeInfo* takeInfo = texture->GetScene()->GetTakeInfo(animStackName);
-	auto animTimeMode = GlobalSettings::Current().AnimationsTimeMode;
-	auto animFrameRate = GlobalSettings::Current().AnimationsFrameRate();
-	auto startFrame = takeInfo->mLocalTimeSpan.GetStart().GetFrameCount(animTimeMode);
-	auto endFrame = takeInfo->mLocalTimeSpan.GetStop().GetFrameCount(animTimeMode);
-	auto animLengthInFrame = endFrame - startFrame + 1;
-	auto uOffsetAnim = std::make_shared<BabylonAnimation<float>>(BabylonAnimationBase::loopBehavior_Cycle, static_cast<int>(animFrameRate), L"uOffset", L"uOffset", true, 0, static_cast<int>(animLengthInFrame), true);
-	auto vOffsetAnim = std::make_shared<BabylonAnimation<float>>(BabylonAnimationBase::loopBehavior_Cycle, static_cast<int>(animFrameRate), L"vOffset", L"vOffset", true, 0, static_cast<int>(animLengthInFrame), true);
 	
-	for (auto ix = 0; ix < animLengthInFrame; ix++) {
-		FbxTime currTime;
-		currTime.SetFrame(startFrame + ix, animTimeMode);
-
-		babylon_animation_key<float> uKey;
-		babylon_animation_key<float> vKey;
-		uKey.frame = ix;
-		vKey.frame = ix;
-		auto currTrans = texture->Translation.EvaluateValue(currTime);
-		uKey.values = static_cast<float>(currTrans[0]);
-		vKey.values = static_cast<float>(currTrans[1]);
-		uOffsetAnim->appendKey(uKey);
-		vOffsetAnim->appendKey(vKey);
-
-	}
-	if (!uOffsetAnim->isConstant()) {
-		animations.push_back(uOffsetAnim);
-	}
-	if (!vOffsetAnim->isConstant()) {
-		animations.push_back(vOffsetAnim);
-	}
+	
 	
 
 }

+ 1 - 1
Exporters/FBX/BabylonFbxNative/BabylonVertex.h

@@ -83,7 +83,7 @@ struct babylon_vector2{
 	float x;
 	float y;
 	babylon_vector2() :x(0), y(0){}
-	babylon_vector2(float x, float y, float z) :x(x), y(y){}
+	babylon_vector2(float x, float y) :x(x), y(y){}
 	babylon_vector2(const babylon_vector2& v) :x(v.x), y(v.y){}
 	babylon_vector2(const FbxDouble2& v) :x(static_cast<float>(v[0])), y(static_cast<float>(v[1])){}
 

+ 0 - 12
Exporters/FBX/FbxExporter/FbxExporter.cpp

@@ -42,16 +42,6 @@ std::string toString(FbxDouble3 value) {
 	s << "(" << value[0] << "," << value[1] << "," << value[2] << ")";
 	return s.str();
 }
-void printNode(BabylonNode& node, int indent = 0) {
-	for (auto i = 0; i < indent; ++i) {
-		std::cout << '\t';
-	}
-	std::cout << node.uniqueId() << " : " << node.name() << " " << toString(node.nodeType()) << " has only skeleton desc : " << node.hasOnlySkeletonDescendants() << std::endl;
-	for (auto i = 0; i < indent; ++i) {
-		std::cout << '\t';
-	}
-	
-}
 
 
 std::string wstringToUtf8(const std::wstring& src){
@@ -250,10 +240,8 @@ int _tmain(int argc, _TCHAR* argv[])
 
 	FbxSceneLoader sceneLoader(wstringToUtf8(wInputPath));
 	auto root = sceneLoader.rootNode();
-	printNode(*root);
 
 	BabylonScene babScene;
-	std::cout << "exporting empty nodes as empty meshes" << std::endl;
 	exploreMeshes(babScene, *root, skipEmptyNodes);
 
 	for (auto& mat : babScene.materials()){