From 855de6d13b5345ce39359ef375a1f0fb7e5bcbc4 Mon Sep 17 00:00:00 2001
From: Kalle-Samuli Riihikoski <haikalle@gmail.com>
Date: Sat, 15 Oct 2011 18:10:40 +0000
Subject: [PATCH] Fixed pivot point move when using applink.

---
 io_coat3D/__init__.py |  2 ++
 io_coat3D/coat.py     | 25 +++++++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py
index f051db3cd..c5663d297 100644
--- a/io_coat3D/__init__.py
+++ b/io_coat3D/__init__.py
@@ -71,6 +71,8 @@ def register():
             name="FilePath",
             subtype="DIR_PATH",
         )
+        cursor_loc = FloatVectorProperty(name="Cursor_loc",description="location")
+        
         exchangedir = StringProperty(
             name="FilePath",
             subtype="DIR_PATH"
diff --git a/io_coat3D/coat.py b/io_coat3D/coat.py
index 5eb05e7b9..4a23603df 100644
--- a/io_coat3D/coat.py
+++ b/io_coat3D/coat.py
@@ -201,15 +201,17 @@ class SCENE_OT_export(bpy.types.Operator):
                     looking = False
                     coa.applink_name = checkname
 
-        bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
+
+        coat3D.cursor_loc = obj.location
+        coat3D.cursor_orginal = bpy.context.scene.cursor_location
+
+        
 
         coa.loc = obj.location
         coa.rot = obj.rotation_euler
         coa.sca = obj.scale
         coa.dime = obj.dimensions
 
-        
-
         obj.location = (0,0,0)
         obj.rotation_euler = (0,0,0)
         obj.scale = (1,1,1)
@@ -217,11 +219,21 @@ class SCENE_OT_export(bpy.types.Operator):
         bpy.ops.export_scene.obj(filepath=coa.applink_name,use_selection=True,
         use_apply_modifiers=False,use_blen_objects=True, group_by_material= True,
         use_materials = False,keep_vertex_order = True,axis_forward='X',axis_up='Y')
-        
 
         obj.location = coa.loc
         obj.rotation_euler = coa.rot
         obj.scale = coa.sca
+
+        bpy.context.scene.cursor_location = coat3D.cursor_loc
+
+        
+        
+
+        bpy.context.scene.cursor_location = coat3D.cursor_orginal
+
+      
+
+        
         
         file = open(importfile, "w")
         file.write("%s"%(checkname))
@@ -246,6 +258,7 @@ class SCENE_OT_import(bpy.types.Operator):
         coat = bpy.coat3D
         test = bpy.context.selected_objects
         act_first = bpy.context.scene.objects.active
+        bpy.context.scene.game_settings.material_mode = 'GLSL'
 
         for act_name in test:
             coa = act_name.coat3D
@@ -320,8 +333,7 @@ class SCENE_OT_import(bpy.types.Operator):
                     mtl = mtl.replace('.obj','.mtl')
                     if(os.path.isfile(mtl)):
                         os.remove(mtl)
-
-                    
+                   
                     bpy.ops.import_scene.obj(filepath=path_object,axis_forward='X',axis_up='Y')
                     obj_proxy = scene.objects[0]
                     bpy.ops.object.select_all(action='TOGGLE')
@@ -357,6 +369,7 @@ class SCENE_OT_import(bpy.types.Operator):
                     bpy.ops.object.delete()
                     objekti.select = True
                     objekti.scale = coat3D.dime
+                    
                     bpy.context.scene.objects.active = objekti
 
                 if(os.path.isfile(path3b_n)):
-- 
GitLab