2
0
Эх сурвалжийг харах

Right values for near and far plane

Scale of the camera have to be considered.
While a fbx from 3DS Max usually has a scale of 1 in Blender you usually
export with a scale of 100.
hammeron-art 10 жил өмнө
parent
commit
19745923b0

+ 6 - 2
tools/encoder/src/FBXSceneEncoder.cpp

@@ -737,9 +737,13 @@ void FBXSceneEncoder::loadCamera(FbxNode* fbxNode, Node* node)
         id.append("_Camera");
         camera->setId(id);
     }
+
+	// Clip planes have to by divided by the forward scale of the camera (x-axis) to get right values
+	float scale = (float)fbxCamera->GetNode()->LclScaling.Get()[0];
+
     camera->setAspectRatio(getAspectRatio(fbxCamera));
-    camera->setNearPlane((float)fbxCamera->NearPlane.Get());
-    camera->setFarPlane((float)fbxCamera->FarPlane.Get());
+	camera->setNearPlane((float)fbxCamera->NearPlane.Get() / scale);
+	camera->setFarPlane((float)fbxCamera->FarPlane.Get() / scale);
 
     if (fbxCamera->ProjectionType.Get() == FbxCamera::eOrthogonal)
     {