[Bf-extensions-cvs] [5928902] master: fixed mark_as_ramp_end_point handling

beta-tester noreply at git.blender.org
Sat Jan 11 11:35:13 CET 2014


Commit: 5928902647ebd2850b54b52e2156cfe7c9a9b367
Author: beta-tester
Date:   Sat Jan 11 11:34:56 2014 +0100
https://developer.blender.org/rBAC5928902647ebd2850b54b52e2156cfe7c9a9b367

fixed mark_as_ramp_end_point handling

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

M	io_scene_fpx/__init__.py
M	io_scene_fpx/fpx_import.py

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

diff --git a/io_scene_fpx/__init__.py b/io_scene_fpx/__init__.py
index f1b0f24..1817f96 100644
--- a/io_scene_fpx/__init__.py
+++ b/io_scene_fpx/__init__.py
@@ -25,7 +25,7 @@
 
 # ##### BEGIN COPYRIGHT BLOCK #####
 #
-# initial script copyright (c)2013 Alexander Nussbaumer
+# initial script copyright (c)2013, 2014 Alexander Nussbaumer
 #
 # ##### END COPYRIGHT BLOCK #####
 
@@ -34,7 +34,7 @@ bl_info = {
     'name': "Future Pinball FPx format (.fpm/.fpl/.fpt)",
     'description': "Import Future Pinball Model, Library and Table files",
     'author': "Alexander Nussbaumer",
-    'version': (0, 0, 201310152),
+    'version': (0, 0, 201401111),
     'blender': (2, 68, 0),
     'location': "File > Import",
     'warning': "",
@@ -72,6 +72,7 @@ bl_info = {
 # - todo: align models only on .fpt import not as currently on .fpm level.
 #       find a way to get a general method, to align model position alignment at .fpt level, not on .fpm level.
 #       (more hardcoding?)
+# - todo: improve mark_as_ramp_end_point handling (see def create_ramp_curve_points).
 #
 # - maybe: add a pop-up message/dialog to inform the user, that the import process takes its time.
 #       progress bar/text - is there something like that available in blender?
diff --git a/io_scene_fpx/fpx_import.py b/io_scene_fpx/fpx_import.py
index 9202209..da70fc5 100644
--- a/io_scene_fpx/fpx_import.py
+++ b/io_scene_fpx/fpx_import.py
@@ -2123,8 +2123,6 @@ class FptImporter():
             last_bezier_point = bezier_point
             last_fpx_point = fpx_point
 
-            #fpx_point.get_value("mark_as_ramp_end_point")
-
             type = fpx_point.get_value("ring_type")
             raw_model_name = wire_ring_model[type]
             if raw_model_name is None:
@@ -2346,30 +2344,45 @@ class FptImporter():
 
     def create_ramp_curve_points(self, spline, fpx_points, z, z0, z1, w0=1.0, w1=1.0):
         ramp_length_sum = 0.0
+        ramp_length_sum2 = 0.0
         ramp_length = []
         last_point = None
-        for fpx_point in fpx_points:
+
+        reached_end_point = False
+        for index, fpx_point in enumerate(fpx_points):
             fpx_position_xy = Vector(fpx_point.get_value("position"))
             if last_point:
                 length = (fpx_position_xy - last_point).length
                 ramp_length_sum += length
+                if not reached_end_point:
+                    ramp_length_sum2 += length
             ramp_length.append(ramp_length_sum)
             last_point = fpx_position_xy
 
+            is_end_point = fpx_point.get_value("mark_as_ramp_end_point")
+            if is_end_point:
+                reached_end_point = True
+
         # create_curve_points & radius
         spline.bezier_points.add(len(fpx_points) - 1)
 
         for index, fpx_point in enumerate(fpx_points):
             fpx_position_xy = fpx_point.get_value("position")
             fpx_smooth = fpx_point.get_value("smooth")
+            is_end_point = fpx_point.get_value("mark_as_ramp_end_point")
 
             factor = (ramp_length[index] / ramp_length_sum)
+            factor2 = (ramp_length[index] / ramp_length_sum2)
+            if factor2 > 1.0:
+                factor2 = 1.0
             offset = (z1 - z0) * factor
+            offset2 = (z1 - z0) * factor2
 
             bezier_point = spline.bezier_points[index]
-            bezier_point.co = self.geometry_correction((fpx_position_xy[0], fpx_position_xy[1], (z + z0 + offset)))
+            bezier_point.co = self.geometry_correction((fpx_position_xy[0], fpx_position_xy[1], (z + z0 + offset2)))
             bezier_point.radius = (w0 + ((w1 - w0) * factor)) / w0
 
+            #if fpx_smooth and not is_end_point: (TODO)
             if fpx_smooth:
                 handle_type = 'AUTO'
             else:



More information about the Bf-extensions-cvs mailing list