[Bf-extensions-cvs] [713953a] temp-x3d_import-T44758: Fixed the bug with explicit normals in IndexedFaceSet, bug with extrusions misoriented.
Seva Alekseyev
noreply at git.blender.org
Sun May 24 17:11:51 CEST 2015
Commit: 713953a29be5030729a04c36ccaad409af260d32
Author: Seva Alekseyev
Date: Sun May 24 11:11:32 2015 -0400
Branches: temp-x3d_import-T44758
https://developer.blender.org/rBA713953a29be5030729a04c36ccaad409af260d32
Fixed the bug with explicit normals in IndexedFaceSet, bug with extrusions misoriented.
===================================================================
M io_scene_x3d/import_x3d.py
===================================================================
diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py
index e183599..e3ba4e7 100644
--- a/io_scene_x3d/import_x3d.py
+++ b/io_scene_x3d/import_x3d.py
@@ -1917,7 +1917,7 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
normals = geom.getChildBySpec('Normal')
if normals:
per_vertex = geom.getFieldAsBool('normalPerVertex', True, ancestry)
- vectors = normals.getFieldAsArray('vector', 0, ancestry)
+ vectors = normals.getFieldAsArray('vector', 3, ancestry)
normal_index = geom.getFieldAsArray('normalIndex', 0, ancestry)
if per_vertex:
co = [co for f in processPerVertexIndex(normal_index)
@@ -1925,8 +1925,7 @@ def importMesh_IndexedFaceSet(geom, ancestry, bpyima):
bpymesh.vertices.foreach_set("normal", co)
else:
co = [co for (i, f) in enumerate(faces) for j in f
- for co in vectors[normal_index[i]
- if normal_index else i]]
+ for co in vectors[normal_index[i] if normal_index else i]]
bpymesh.polygons.foreach_set("normal", co)
# Apply vertex/face colors
@@ -2146,7 +2145,7 @@ def importMesh_Extrusion(geom, ancestry, bpyima):
def findFirstAngleNormal():
for i in range(1, ns - 1):
spt = spine[i]
- z = (spine[i + 1] - spt).cross(spt - spine[i - 1])
+ z = (spine[i + 1] - spt).cross(spine[i - 1] - spt)
if z.length > EPSILON:
return z
# All the spines are collinear. Fallback to the rotated source
@@ -2168,15 +2167,14 @@ def importMesh_Extrusion(geom, ancestry, bpyima):
sprev = spine[(i - 1 + ns) % ns]
y = snext - sprev
vnext = snext - spt
- vprev = spt - sprev
+ vprev = sprev - spt
try_z = vnext.cross(vprev)
# Might be zero, then all kinds of fallback
if try_z.length > EPSILON:
- if z and try_z.dot(z) < 0:
+ if z is not None and try_z.dot(z) < 0:
try_z.negate()
z = try_z
- elif not z:
- # No previous z.
+ elif not z: # No z, and no previous z.
# Look ahead, see if there's at least one point where
# spines are not collinear.
z = findFirstAngleNormal()
@@ -2639,7 +2637,9 @@ def importMesh_Box(geom, ancestry, bpyima):
# Textures are processed elsewhere.
def appearance_CreateMaterial(vrmlname, mat, ancestry, is_vcol):
- # all values between 0.0 and 1.0, defaults from VRML docs
+ # Given an X3D material, creates a Blender material.
+ # texture is applied later, in appearance_Create().
+ # All values between 0.0 and 1.0, defaults from VRML docs.
bpymat = bpy.data.materials.new(vrmlname)
bpymat.ambient = mat.getFieldAsFloat('ambientIntensity', 0.2, ancestry)
diff_color = mat.getFieldAsFloatTuple('diffuseColor',
More information about the Bf-extensions-cvs
mailing list