[Bf-extensions-cvs] [df966fb] master: Fix T40904: FBX exporter does not store parameter, which is used in FBX SDKs FbxProperty::IsValid()

Bastien Montagne noreply at git.blender.org
Wed Jul 2 15:54:16 CEST 2014


Commit: df966fb0c54446197e5d72e0e1132ed15459c8b9
Author: Bastien Montagne
Date:   Wed Jul 2 15:39:09 2014 +0200
https://developer.blender.org/rBAdf966fb0c54446197e5d72e0e1132ed15459c8b9

Fix T40904: FBX exporter does not store parameter, which is used in FBX SDKs FbxProperty::IsValid()

Each time I think I have reach the limits of the crappyness of this "format", it manages to amaze
me again! This time, looks like SDK expects always the same values in the 'templates' (Definitions),
else it declares properties as invalid! One would have to explain me the interest/need to write
those default values in the file, up to this point...

Anyway, went over all defaults I could gather from 'official' FBX files, and replaced the few
ones I had change (because it was better suited to Blender's data). Hopefully it'll be OK now.

Thanks to FslNopper (Norbert Nopper), which helped me troubleshooting this stuff!

There is a good thing here though - it made me find how textures are linked to UVMaps
(by mere names, 'UVSet' property of texture nodes).

===================================================================

M	io_scene_fbx/export_fbx.py
M	io_scene_fbx/export_fbx_bin.py

===================================================================

diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py
index bea02a8..ee98019 100644
--- a/io_scene_fbx/export_fbx.py
+++ b/io_scene_fbx/export_fbx.py
@@ -1505,7 +1505,6 @@ def save_single(operator, scene, filepath="",
             raise Exception("invalid mesh_smooth_type: %r" % mesh_smooth_type)
 
         # Write VertexColor Layers
-        # note, no programs seem to use this info :/
         collayers = []
         if len(me.vertex_colors):
             collayers = me.vertex_colors
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 52dabb2..d39ce94 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -123,7 +123,7 @@ def fbx_template_def_model(scene, settings, override_defaults=None, nbr_users=0)
         (b"RotationMaxX", (False, "p_bool", False)),
         (b"RotationMaxY", (False, "p_bool", False)),
         (b"RotationMaxZ", (False, "p_bool", False)),
-        (b"InheritType", (1, "p_enum", False)),  # RSrs
+        (b"InheritType", (0, "p_enum", False)),  # RrSs
         (b"ScalingActive", (False, "p_bool", False)),
         (b"ScalingMin", ((0.0, 0.0, 0.0), "p_vector_3d", False)),
         (b"ScalingMax", ((1.0, 1.0, 1.0), "p_vector_3d", False)),
@@ -155,7 +155,7 @@ def fbx_template_def_model(scene, settings, override_defaults=None, nbr_users=0)
         (b"UpVectorProperty", (None, "p_object", False)),
         (b"Show", (True, "p_bool", False)),
         (b"NegativePercentShapeSupport", (True, "p_bool", False)),
-        (b"DefaultAttributeIndex", (0, "p_integer", False)),
+        (b"DefaultAttributeIndex", (-1, "p_integer", False)),
         (b"Freeze", (False, "p_bool", False)),
         (b"LODBox", (False, "p_bool", False)),
         (b"Lcl Translation", ((0.0, 0.0, 0.0), "p_lcl_translation", True)),
@@ -208,21 +208,21 @@ def fbx_template_def_camera(scene, settings, override_defaults=None, nbr_users=0
         (b"Roll", (0.0, "p_roll", True)),
         (b"OpticalCenterX", (0.0, "p_opticalcenterx", True)),
         (b"OpticalCenterY", (0.0, "p_opticalcentery", True)),
-        (b"BackgroundColor", ((0.8, 0.8, 0.8), "p_color", True)),
+        (b"BackgroundColor", ((0.63, 0.63, 0.63), "p_color", True)),
         (b"TurnTable", (0.0, "p_number", True)),
         (b"DisplayTurnTableIcon", (False, "p_bool", False)),
         (b"UseMotionBlur", (False, "p_bool", False)),
         (b"UseRealTimeMotionBlur", (True, "p_bool", False)),
         (b"Motion Blur Intensity", (1.0, "p_number", True)),
-        (b"AspectRatioMode", (2, "p_enum", False)),  # Fixed ratio, height and width in pixels.
-        (b"AspectWidth", (float(r.resolution_x), "p_double", False)),
-        (b"AspectHeight", (float(r.resolution_y), "p_double", False)),
-        (b"PixelAspectRatio", (float(r.pixel_aspect_x / r.pixel_aspect_y), "p_double", False)),
+        (b"AspectRatioMode", (0, "p_enum", False)),  # WindowSize.
+        (b"AspectWidth", (320, "p_double", False)),
+        (b"AspectHeight", (200, "p_double", False)),
+        (b"PixelAspectRatio", (1.0, "p_double", False)),
         (b"FilmOffsetX", (0.0, "p_number", True)),
         (b"FilmOffsetY", (0.0, "p_number", True)),
-        (b"FilmWidth", (1.2598425196850394, "p_double", False)),
-        (b"FilmHeight", (0.7086614173228346, "p_double", False)),
-        (b"FilmAspectRatio", (1.777777777777778, "p_double", False)),
+        (b"FilmWidth", (0.816, "p_double", False)),
+        (b"FilmHeight", (0.612, "p_double", False)),
+        (b"FilmAspectRatio", (1.3333333333333333, "p_double", False)),
         (b"FilmSqueezeRatio", (1.0, "p_double", False)),
         (b"FilmFormatIndex", (0, "p_enum", False)),  # Assuming this is ApertureFormat, 0 = custom.
         (b"PreScale", (1.0, "p_number", True)),
@@ -232,12 +232,12 @@ def fbx_template_def_camera(scene, settings, override_defaults=None, nbr_users=0
         (b"FilmRollPivotY", (0.0, "p_number", True)),
         (b"FilmRollValue", (0.0, "p_number", True)),
         (b"FilmRollOrder", (0, "p_enum", False)),  # 0 = rotate first (default).
-        (b"ApertureMode", (3, "p_enum", False)),  # 3 = focal length.
+        (b"ApertureMode", (2, "p_enum", False)),  # 2 = Vertical.
         (b"GateFit", (0, "p_enum", False)),  # 0 = no resolution gate fit.
-        (b"FieldOfView", (49.13434207760448, "p_fov", True)),
-        (b"FieldOfViewX", (49.13434207760448, "p_fov_x", True)),
-        (b"FieldOfViewY", (28.841546110078532, "p_fov_y", True)),
-        (b"FocalLength", (35.0, "p_number", True)),
+        (b"FieldOfView", (25.114999771118164, "p_fov", True)),
+        (b"FieldOfViewX", (40.0, "p_fov_x", True)),
+        (b"FieldOfViewY", (40.0, "p_fov_y", True)),
+        (b"FocalLength", (34.89327621672628, "p_number", True)),
         (b"CameraFormat", (0, "p_enum", False)),  # Custom camera format.
         (b"UseFrameColor", (False, "p_bool", False)),
         (b"FrameColor", ((0.3, 0.3, 0.3), "p_color_rgb", False)),
@@ -246,26 +246,28 @@ def fbx_template_def_camera(scene, settings, override_defaults=None, nbr_users=0
         (b"ShowGrid", (True, "p_bool", False)),
         (b"ShowOpticalCenter", (False, "p_bool", False)),
         (b"ShowAzimut", (True, "p_bool", False)),
-        (b"ShowTimeCode", (True, "p_bool", False)),
+        (b"ShowTimeCode", (False, "p_bool", False)),
         (b"ShowAudio", (False, "p_bool", False)),
         (b"AudioColor", ((0.0, 1.0, 0.0), "p_vector_3d", False)),  # Yep, vector3d, not corlorgb… :cry:
-        (b"NearPlane", (1.0, "p_double", False)),
-        (b"FarPlane", (100.0, "p_double", False)),
+        (b"NearPlane", (10.0, "p_double", False)),
+        (b"FarPlane", (4000.0, "p_double", False)),
         (b"AutoComputeClipPanes", (False, "p_bool", False)),
         (b"ViewCameraToLookAt", (True, "p_bool", False)),
         (b"ViewFrustumNearFarPlane", (False, "p_bool", False)),
         (b"ViewFrustumBackPlaneMode", (2, "p_enum", False)),  # 2 = show back plane if texture added.
-        (b"BackPlaneDistance", (100.0, "p_number", True)),
+        (b"BackPlaneDistance", (4000.0, "p_number", True)),
         (b"BackPlaneDistanceMode", (1, "p_enum", False)),  # 1 = relative to camera.
         (b"ViewFrustumFrontPlaneMode", (2, "p_enum", False)),  # 2 = show front plane if texture added.
-        (b"FrontPlaneDistance", (1.0, "p_number", True)),
+        (b"FrontPlaneDistance", (10.0, "p_number", True)),
         (b"FrontPlaneDistanceMode", (1, "p_enum", False)),  # 1 = relative to camera.
         (b"LockMode", (False, "p_bool", False)),
         (b"LockInterestNavigation", (False, "p_bool", False)),
-        (b"BackPlateFitImage", (False, "p_bool", False)),
-        (b"BackPlateCrop", (False, "p_bool", False)),
-        (b"BackPlateCenter", (True, "p_bool", False)),
-        (b"BackPlateKeepRatio", (True, "p_bool", False)),
+        # BackPlate... properties **arggggg!**
+        (b"FitImage", (False, "p_bool", False)),
+        (b"Crop", (False, "p_bool", False)),
+        (b"Center", (True, "p_bool", False)),
+        (b"KeepRatio", (True, "p_bool", False)),
+        # End of BackPlate...
         (b"BackgroundAlphaTreshold", (0.5, "p_double", False)),
         (b"ShowBackplate", (True, "p_bool", False)),
         (b"BackPlaneOffsetX", (0.0, "p_number", True)),
@@ -286,10 +288,10 @@ def fbx_template_def_camera(scene, settings, override_defaults=None, nbr_users=0
         (b"FrontPlaneScaleX", (1.0, "p_number", True)),
         (b"FrontPlaneScaleY", (1.0, "p_number", True)),
         (b"Foreground Texture", (None, "p_object", False)),
-        (b"DisplaySafeArea", (True, "p_bool", False)),
+        (b"DisplaySafeArea", (False, "p_bool", False)),
         (b"DisplaySafeAreaOnRender", (False, "p_bool", False)),
         (b"SafeAreaDisplayStyle", (1, "p_enum", False)),  # 1 = rounded corners.
-        (b"SafeAreaAspectRatio", (1.777777777777778, "p_double", False)),
+        (b"SafeAreaAspectRatio", (1.3333333333333333, "p_double", False)),
         (b"Use2DMagnifierZoom", (False, "p_bool", False)),
         (b"2D Magnifier Zoom", (100.0, "p_number", True)),
         (b"2D Magnifier X", (50.0, "p_number", True)),
@@ -298,9 +300,9 @@ def fbx_template_def_camera(scene, settings, override_defaults=None, nbr_users=0
         (b"OrthoZoom", (1.0, "p_double", False)),
         (b"UseRealTimeDOFAndAA", (False, "p_bool", False)),
         (b"UseDepthOfField", (False, "p_bool", False)),
-        (b"FocusSource", (1, "p_enum", False)),  # 0 = camera interest, 1 = distance from camera interest.
+        (b"FocusSource", (0, "p_enum", False)),  # 0 = camera interest, 1 = distance from camera interest.
         (b"FocusAngle", (3.5, "p_double", False)),  # ???
-        (b"FocusDistance", (10.0, "p_double", False)),
+        (b"FocusDistance", (200.0, "p_double", False)),
         (b"UseAntialiasing", (False, "p_bool", False)),
         (b"AntialiasingIntensity", (0.77777, "p_double", False)),
         (b"AntialiasingMethod", (0, "p_enum", False)),  # 0 = oversampling, 1 = hardware.
@@ -340,32 +342,32 @@ def fbx_template_def_material(scene, settings, override_defaults=None, nbr_users
         (b"ShadingModel", ("Phong", "p_string", False)),
         (b"MultiLayer", (False, "p_bool", False)),
         # Lambert-specific.
-        (b"EmissiveColor", ((0.8, 0.8, 0.8), "p_color", True)),  # Same as diffuse.
-        (b"EmissiveFactor", (0.0, "p_number", True)),
-        (b"AmbientColor", ((0.0, 0.0, 0.0), "p_color", True)),
+        (b"EmissiveColor", ((0.0, 0.0, 0.0), "p_color", True)),
+        (b"EmissiveFactor", (1.0, "p_number", True)),
+        (b"AmbientColor", ((0.2, 0.2, 0.2), "p_color", True)),
         (b"AmbientFactor", (1.0, "p_number", True)),
         (b"DiffuseColor", ((0.8, 0.8, 0.8), "p_color", True)),
-        (b"DiffuseFactor", (0.8, "p_number", True)),
-        (b"TransparentColor", ((0.8, 0.8, 0.8), "p_color", True)),  # Same as diffuse.
+        (b"DiffuseFactor", (1.0, "p_number", True)),
+        (b"TransparentColor", ((0.0, 0.0, 0.0), "p_color", True)),
         (b"TransparencyFactor", (0.0, "p_number", True)),
         (b"Opacity", (1.0, "p_number", True)),
         (b"NormalMap", ((0.0, 0.0, 0.0), "p_vector_3d", False)),
     

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list