[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2566] trunk/py/scripts/addons/ io_scene_x3d/export_x3d.py: replace %g string formatting with %f, also use quat.to_axis_angle()
Campbell Barton
ideasman42 at gmail.com
Wed Nov 2 10:15:15 CET 2011
Revision: 2566
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2566
Author: campbellbarton
Date: 2011-11-02 09:15:15 +0000 (Wed, 02 Nov 2011)
Log Message:
-----------
replace %g string formatting with %f, also use quat.to_axis_angle()
Modified Paths:
--------------
trunk/py/scripts/addons/io_scene_x3d/export_x3d.py
Modified: trunk/py/scripts/addons/io_scene_x3d/export_x3d.py
===================================================================
--- trunk/py/scripts/addons/io_scene_x3d/export_x3d.py 2011-11-02 07:33:36 UTC (rev 2565)
+++ trunk/py/scripts/addons/io_scene_x3d/export_x3d.py 2011-11-02 09:15:15 UTC (rev 2566)
@@ -327,15 +327,17 @@
def writeViewpoint(ident, obj, matrix, scene):
view_id = quoteattr(unique_name(obj, 'CA_' + obj.name, uuid_cache_view, clean_func=clean_def, sep="_"))
- loc, quat, scale = matrix.decompose()
+ loc, rot, scale = matrix.decompose()
+ rot = rot.to_axis_angle()
+ rot = rot[0][:] + (rot[1], )
ident_step = ident + (' ' * (-len(ident) + \
fw('%s<Viewpoint ' % ident)))
fw('DEF=%s\n' % view_id)
fw(ident_step + 'centerOfRotation="0 0 0"\n')
fw(ident_step + 'position="%3.2f %3.2f %3.2f"\n' % loc[:])
- fw(ident_step + 'orientation="%3.2f %3.2f %3.2f %3.2f"\n' % (quat.axis.normalized()[:] + (quat.angle, )))
- fw(ident_step + 'fieldOfView="%.3g"\n' % obj.data.angle)
+ fw(ident_step + 'orientation="%3.2f %3.2f %3.2f %3.2f"\n' % rot)
+ fw(ident_step + 'fieldOfView="%.3f"\n' % obj.data.angle)
fw(ident_step + '/>\n')
def writeFog(ident, world):
@@ -349,8 +351,8 @@
ident_step = ident + (' ' * (-len(ident) + \
fw('%s<Fog ' % ident)))
fw('fogType="%s"\n' % ('LINEAR' if (mtype == 'LINEAR') else 'EXPONENTIAL'))
- fw(ident_step + 'color="%.3g %.3g %.3g"\n' % clamp_color(world.horizon_color))
- fw(ident_step + 'visibilityRange="%.3g"\n' % mparam.depth)
+ fw(ident_step + 'color="%.3f %.3f %.3f"\n' % clamp_color(world.horizon_color))
+ fw(ident_step + 'visibilityRange="%.3f"\n' % mparam.depth)
fw(ident_step + '/>\n')
else:
return
@@ -372,12 +374,14 @@
else:
fw('\n')
- loc, quat, sca = matrix.decompose()
+ loc, rot, sca = matrix.decompose()
+ rot = rot.to_axis_angle()
+ rot = rot[0][:] + (rot[1], )
- fw(ident_step + 'translation="%.6g %.6g %.6g"\n' % loc[:])
- # fw(ident_step + 'center="%.6g %.6g %.6g"\n' % (0, 0, 0))
- fw(ident_step + 'scale="%.6g %.6g %.6g"\n' % sca[:])
- fw(ident_step + 'rotation="%.6g %.6g %.6g %.6g"\n' % (quat.axis.normalized()[:] + (quat.angle, )))
+ fw(ident_step + 'translation="%.6f %.6f %.6f"\n' % loc[:])
+ # fw(ident_step + 'center="%.6f %.6f %.6f"\n' % (0, 0, 0))
+ fw(ident_step + 'scale="%.6f %.6f %.6f"\n' % sca[:])
+ fw(ident_step + 'rotation="%.6f %.6f %.6f %.6f"\n' % rot)
fw(ident_step + '>\n')
ident += '\t'
return ident
@@ -413,14 +417,14 @@
ident_step = ident + (' ' * (-len(ident) + \
fw('%s<SpotLight ' % ident)))
fw('DEF=%s\n' % lamp_id)
- fw(ident_step + 'radius="%.4g"\n' % radius)
- fw(ident_step + 'ambientIntensity="%.4g"\n' % amb_intensity)
- fw(ident_step + 'intensity="%.4g"\n' % intensity)
- fw(ident_step + 'color="%.4g %.4g %.4g"\n' % clamp_color(lamp.color))
- fw(ident_step + 'beamWidth="%.4g"\n' % beamWidth)
- fw(ident_step + 'cutOffAngle="%.4g"\n' % cutOffAngle)
- fw(ident_step + 'direction="%.4g %.4g %.4g"\n' % orientation)
- fw(ident_step + 'location="%.4g %.4g %.4g"\n' % location)
+ fw(ident_step + 'radius="%.4f"\n' % radius)
+ fw(ident_step + 'ambientIntensity="%.4f"\n' % amb_intensity)
+ fw(ident_step + 'intensity="%.4f"\n' % intensity)
+ fw(ident_step + 'color="%.4f %.4f %.4f"\n' % clamp_color(lamp.color))
+ fw(ident_step + 'beamWidth="%.4f"\n' % beamWidth)
+ fw(ident_step + 'cutOffAngle="%.4f"\n' % cutOffAngle)
+ fw(ident_step + 'direction="%.4f %.4f %.4f"\n' % orientation)
+ fw(ident_step + 'location="%.4f %.4f %.4f"\n' % location)
fw(ident_step + '/>\n')
def writeDirectionalLight(ident, obj, matrix, lamp, world):
@@ -442,10 +446,10 @@
ident_step = ident + (' ' * (-len(ident) + \
fw('%s<DirectionalLight ' % ident)))
fw('DEF=%s\n' % lamp_id)
- fw(ident_step + 'ambientIntensity="%.4g"\n' % amb_intensity)
- fw(ident_step + 'color="%.4g %.4g %.4g"\n' % clamp_color(lamp.color))
- fw(ident_step + 'intensity="%.4g"\n' % intensity)
- fw(ident_step + 'direction="%.4g %.4g %.4g"\n' % orientation)
+ fw(ident_step + 'ambientIntensity="%.4f"\n' % amb_intensity)
+ fw(ident_step + 'color="%.4f %.4f %.4f"\n' % clamp_color(lamp.color))
+ fw(ident_step + 'intensity="%.4f"\n' % intensity)
+ fw(ident_step + 'direction="%.4f %.4f %.4f"\n' % orientation)
fw(ident_step + '/>\n')
def writePointLight(ident, obj, matrix, lamp, world):
@@ -466,12 +470,12 @@
ident_step = ident + (' ' * (-len(ident) + \
fw('%s<PointLight ' % ident)))
fw('DEF=%s\n' % lamp_id)
- fw(ident_step + 'ambientIntensity="%.4g"\n' % amb_intensity)
- fw(ident_step + 'color="%.4g %.4g %.4g"\n' % clamp_color(lamp.color))
+ fw(ident_step + 'ambientIntensity="%.4f"\n' % amb_intensity)
+ fw(ident_step + 'color="%.4f %.4f %.4f"\n' % clamp_color(lamp.color))
- fw(ident_step + 'intensity="%.4g"\n' % intensity)
- fw(ident_step + 'radius="%.4g" \n' % lamp.distance)
- fw(ident_step + 'location="%.4g %.4g %.4g"\n' % location)
+ fw(ident_step + 'intensity="%.4f"\n' % intensity)
+ fw(ident_step + 'radius="%.4f" \n' % lamp.distance)
+ fw(ident_step + 'location="%.4f %.4f %.4f"\n' % location)
fw(ident_step + '/>\n')
def writeIndexedFaceSet(ident, obj, mesh, matrix, world):
@@ -627,10 +631,10 @@
ident_step = ident + (' ' * (-len(ident) + \
fw('%s<TextureTransform ' % ident)))
fw('\n')
- # fw('center="%.6g %.6g" ' % (0.0, 0.0))
- fw(ident_step + 'translation="%.6g %.6g"\n' % loc)
- fw(ident_step + 'scale="%.6g %.6g"\n' % (sca_x, sca_y))
- fw(ident_step + 'rotation="%.6g"\n' % rot)
+ # fw('center="%.6f %.6f" ' % (0.0, 0.0))
+ fw(ident_step + 'translation="%.6f %.6f"\n' % loc)
+ fw(ident_step + 'scale="%.6f %.6f"\n' % (sca_x, sca_y))
+ fw(ident_step + 'rotation="%.6f"\n' % rot)
fw(ident_step + '/>\n')
if use_h3d:
@@ -743,26 +747,26 @@
fw('%s<Coordinate ' % ident)
fw('point="')
for x3d_v in vert_tri_list:
- fw('%.6g %.6g %.6g ' % mesh_vertices[x3d_v[1]].co[:])
+ fw('%.6f %.6f %.6f ' % mesh_vertices[x3d_v[1]].co[:])
fw('" />\n')
if use_normals or is_force_normals:
fw('%s<Normal ' % ident)
fw('vector="')
for x3d_v in vert_tri_list:
- fw('%.6g %.6g %.6g ' % mesh_vertices[x3d_v[1]].normal[:])
+ fw('%.6f %.6f %.6f ' % mesh_vertices[x3d_v[1]].normal[:])
fw('" />\n')
if is_uv:
fw('%s<TextureCoordinate point="' % ident)
for x3d_v in vert_tri_list:
- fw('%.4g %.4g ' % x3d_v[0][slot_uv])
+ fw('%.4f %.4f ' % x3d_v[0][slot_uv])
fw('" />\n')
if is_col:
fw('%s<Color color="' % ident)
for x3d_v in vert_tri_list:
- fw('%.3g %.3g %.3g ' % x3d_v[0][slot_col])
+ fw('%.3f %.3f %.3f ' % x3d_v[0][slot_col])
fw('" />\n')
if use_h3d:
@@ -777,7 +781,7 @@
fw('numComponents="2" ')
fw('value="')
for x3d_v in vert_tri_list:
- fw('%.4g %.4g ' % x3d_v[0][slot_uv])
+ fw('%.4f %.4f ' % x3d_v[0][slot_uv])
fw('" />\n')
else:
assert(0)
@@ -799,7 +803,7 @@
# --- Write IndexedFaceSet Attributes (same as IndexedTriangleSet)
fw('solid="%s"\n' % ('true' if mesh.show_double_sided else 'false'))
if is_smooth:
- fw(ident_step + 'creaseAngle="%.4g"\n' % mesh.auto_smooth_angle)
+ fw(ident_step + 'creaseAngle="%.4f"\n' % mesh.auto_smooth_angle)
if use_normals:
# currently not optional, could be made so:
@@ -852,7 +856,7 @@
fw('DEF=%s\n' % mesh_id_coords)
fw(ident_step + 'point="')
for v in mesh.vertices:
- fw('%.6g %.6g %.6g ' % v.co[:])
+ fw('%.6f %.6f %.6f ' % v.co[:])
fw('"\n')
fw(ident_step + '/>\n')
@@ -864,7 +868,7 @@
fw('DEF=%s\n' % mesh_id_normals)
fw(ident_step + 'vector="')
for v in mesh.vertices:
- fw('%.6g %.6g %.6g ' % v.normal[:])
+ fw('%.6f %.6f %.6f ' % v.normal[:])
fw('"\n')
fw(ident_step + '/>\n')
@@ -872,7 +876,7 @@
fw('%s<TextureCoordinate point="' % ident)
for i in face_group:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list