[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1994] trunk/py/scripts/addons/ io_scene_x3d/export_x3d.py: minor improvements in api usage
Campbell Barton
ideasman42 at gmail.com
Thu Jun 2 10:33:23 CEST 2011
Revision: 1994
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1994
Author: campbellbarton
Date: 2011-06-02 08:33:23 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
minor improvements in api usage
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-06-02 05:13:50 UTC (rev 1993)
+++ trunk/py/scripts/addons/io_scene_x3d/export_x3d.py 2011-06-02 08:33:23 UTC (rev 1994)
@@ -127,7 +127,6 @@
def writeHeader(ident):
filepath = fw.__self__.name
- #bfile = sys.expandpath( Blender.Get('filepath') ).replace('<', '<').replace('>', '>')
bfile = repr(os.path.basename(filepath).replace('<', '<').replace('>', '>'))[1:-1] # use outfile name
fw('%s<?xml version="1.0" encoding="UTF-8"?>\n' % ident)
if use_h3d:
@@ -766,7 +765,7 @@
emit = mat.emit
ambient = mat.ambient / 3.0
- diffuseColor = tuple(mat.diffuse_color)
+ diffuseColor = mat.diffuse_color[:]
if world:
ambiColor = tuple(((c * mat.ambient) * 2.0) for c in world.ambient_color)
else:
@@ -907,14 +906,14 @@
elif uniform['type'] == gpu.GPU_DYNAMIC_LAMP_DYNCOL:
# odd we have both 3, 4 types.
lamp = bpy.data.objects[uniform['lamp']].data
- value = '%.6g %.6g %.6g' % (mathutils.Vector(lamp.color) * lamp.energy)[:]
+ value = '%.6g %.6g %.6g' % (lamp.color * lamp.energy)[:]
if uniform['datatype'] == gpu.GPU_DATA_3F:
fw('%s<field name="%s" type="SFVec3f" accessType="inputOutput" value="%s" />\n' % (ident, uniform['varname'], value))
elif uniform['datatype'] == gpu.GPU_DATA_4F:
fw('%s<field name="%s" type="SFVec4f" accessType="inputOutput" value="%s 1.0" />\n' % (ident, uniform['varname'], value))
else:
assert(0)
-
+
elif uniform['type'] == gpu.GPU_DYNAMIC_LAMP_DYNVEC:
if uniform['datatype'] == gpu.GPU_DATA_3F:
value = '%.6g %.6g %.6g' % (mathutils.Vector((0.0, 0.0, 1.0)) * (global_matrix * bpy.data.objects[uniform['lamp']].matrix_world).to_quaternion()).normalized()[:]
@@ -1164,18 +1163,13 @@
global_matrix=None,
):
- if use_compress:
- if not filepath.lower().endswith('.x3dz'):
- filepath = '.'.join(filepath.split('.')[:-1]) + '.x3dz'
- else:
- if not filepath.lower().endswith('.x3d'):
- filepath = '.'.join(filepath.split('.')[:-1]) + '.x3d'
+ py.path.ensure_ext(filepath, '.x3dz' if use_compress else '.x3d')
if bpy.ops.object.mode_set.poll():
bpy.ops.object.mode_set(mode='OBJECT')
file = None
- if filepath.lower().endswith('.x3dz'):
+ if use_compress:
try:
import gzip
file = gzip.open(filepath, 'w')
More information about the Bf-extensions-cvs
mailing list