Add feature #12: Scale geometry options for shape import #16

Merged
Cedric Steiert merged 3 commits from Hombre57/io_scene_x3d:import-scale into main 2024-09-10 00:49:23 +02:00
2 changed files with 8 additions and 7 deletions
Showing only changes of commit 5054c31689 - Show all commits

View File

@ -56,7 +56,7 @@ class ImportX3D(bpy.types.Operator, ImportHelper):
default=1.0,
Hombre57 marked this conversation as resolved
Review

please also add step=1.0,. Currently it steps in intervals of 0.03, 0.01 seems more appropriate (or is 0.03 more comfy?). Could be also adjusted for the x3d exporter in line 220.

please also add `step=1.0,`. Currently it steps in intervals of 0.03, 0.01 seems more appropriate (or is 0.03 more comfy?). Could be also adjusted for the x3d exporter in line 220.
Review

Done

Done
precision=4,
step=1.0,
description="Scale value used when 'File Unit' is set to 'Use scale'",
description="Scale value used when 'File Unit' is set to 'CUSTOM'",
Bujus_Krachus marked this conversation as resolved Outdated

'Use scale' now needs to be adjusted to the new name (CUSTOM)

'Use scale' now needs to be adjusted to the new name (CUSTOM)
)
def execute(self, context):

View File

@ -815,7 +815,6 @@ class vrmlNode(object):
# print(child_array)
# Normal vrml
array_data = child_array.array_data
apply_scale = scale_factor != 1.0
# print('array_data', array_data)
if group == -1 or len(array_data) == 0:
@ -828,13 +827,15 @@ class vrmlNode(object):
flat = False
break
apply_scale = scale_factor != 1.0
# make a flat array
if flat:
flat_array = array_data # we are already flat.
if apply_scale:
# applying scale
for item in array_data:
item *= scale_factor
flat_array = [n*scale_factor for n in array_data] # scaling the data
else:
flat_array = array_data # we are already flat.
else:
flat_array = []
@ -1511,7 +1512,7 @@ def translateScale(sca):
def translateTransform(node, ancestry):
cent = node.getFieldAsFloatTuple('center', None, ancestry, conversion_scale) # (0.0, 0.0, 0.0)
rot = node.getFieldAsFloatTuple('rotation', None, ancestry) # (0.0, 0.0, 1.0, 0.0)
sca = node.getFieldAsFloatTuple('scale', None, ancestry, conversion_scale) # (1.0, 1.0, 1.0)
sca = node.getFieldAsFloatTuple('scale', None, ancestry) # (1.0, 1.0, 1.0)
scaori = node.getFieldAsFloatTuple('scaleOrientation', None, ancestry) # (0.0, 0.0, 1.0, 0.0)
tx = node.getFieldAsFloatTuple('translation', None, ancestry, conversion_scale) # (0.0, 0.0, 0.0)
@ -1693,7 +1694,7 @@ def importMesh_ReadVertices(bpymesh, geom, ancestry):
# IndexedFaceSet presumes a 2D one.
# The case for caching is stronger over there.
coord = geom.getChildBySpec('Coordinate')
points = coord.getFieldAsArray('point', 0, ancestry)
points = coord.getFieldAsArray('point', 0, ancestry, conversion_scale)
bpymesh.vertices.add(len(points) // 3)
bpymesh.vertices.foreach_set("co", points)