From 6ac61fedc9bc0ab96b1159682736052c4b62d087 Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Mon, 20 Jun 2011 01:33:47 +0000
Subject: [PATCH] fix [#27697] VRML Importing: Extra line segment added,
 orientation changed

---
 io_scene_x3d/__init__.py   | 4 ++--
 io_scene_x3d/import_x3d.py | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/io_scene_x3d/__init__.py b/io_scene_x3d/__init__.py
index 96f099008..c176d95c2 100644
--- a/io_scene_x3d/__init__.py
+++ b/io_scene_x3d/__init__.py
@@ -73,7 +73,7 @@ class ImportX3D(bpy.types.Operator, ImportHelper):
                    ('-Y', "-Y Up", ""),
                    ('-Z', "-Z Up", ""),
                    ),
-            default='-Y',
+            default='Y',
             )
 
     def execute(self, context):
@@ -123,7 +123,7 @@ class ExportX3D(bpy.types.Operator, ExportHelper):
                    ('-Y', "-Y Up", ""),
                    ('-Z', "-Z Up", ""),
                    ),
-            default='-Y',
+            default='Y',
             )
 
     path_mode = path_reference_mode
diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py
index c20afbac9..28c0abac5 100644
--- a/io_scene_x3d/import_x3d.py
+++ b/io_scene_x3d/import_x3d.py
@@ -1551,7 +1551,7 @@ def getFinalMatrix(node, mtx, ancestry, global_matrix):
         mtx = mat * mtx
 
     # worldspace matrix
-    mtx = mtx * global_matrix
+    mtx = global_matrix * mtx
 
     return mtx
 
@@ -1883,8 +1883,7 @@ def importMesh_IndexedLineSet(geom, ancestry):
             continue
         co = points[line[0]]
         nu = bpycurve.splines.new('POLY')
-        nu.points.add(len(line))
-
+        nu.points.add(len(line) - 1)  # the new nu has 1 point to begin with
         for il, pt in zip(line, nu.points):
             pt.co[0:3] = points[il]
 
@@ -2334,7 +2333,7 @@ def importViewpoint(node, ancestry, global_matrix):
 
     mtx = Matrix.Translation(Vector(position)) * translateRotation(orientation)
 
-    bpyob = node.blendObject = bpy.data.objects.new("TODO", bpycam)
+    bpyob = node.blendObject = bpy.data.objects.new(name, bpycam)
     bpy.context.scene.objects.link(bpyob)
     bpyob.matrix_world = getFinalMatrix(node, mtx, ancestry, global_matrix)
 
-- 
GitLab