From e873c49f0f4851f347ad4cdda263b0968360946c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Jan 2011 23:56:23 +0000 Subject: minor edit for better float precision with testing. --- io_scene_x3d/export_x3d.py | 53 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'io_scene_x3d') diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py index 5b4c8805..b81e8cf9 100644 --- a/io_scene_x3d/export_x3d.py +++ b/io_scene_x3d/export_x3d.py @@ -191,10 +191,10 @@ class x3d_class: safeName = self.cleanStr(ob.name) if world: ambi = world.ambient_color - ambientIntensity = ((ambi[0] + ambi[1] + ambi[2]) / 3.0) / 2.5 + amb_intensity = ((ambi[0] + ambi[1] + ambi[2]) / 3.0) / 2.5 del ambi else: - ambientIntensity = 0.0 + amb_intensity = 0.0 # compute cutoff and beamwidth intensity = min(lamp.energy / 1.75, 1.0) @@ -204,57 +204,58 @@ class x3d_class: dx, dy, dz = matrix_direction(mtx) - location = mtx.translation_part() + location = mtx.translation_part()[:] radius = lamp.distance * math.cos(beamWidth) # radius = lamp.dist*math.cos(beamWidth) self.file.write("\n\n" % (round(location[0], 3), round(location[1], 3), round(location[2], 3))) + self.file.write("radius=\"%.4f\" " % radius) + self.file.write("ambientIntensity=\"%.4f\" " % amb_intensity) + self.file.write("intensity=\"%.4f\" " % intensity) + self.file.write("color=\"%.4f %.4f %.4f\" " % round_color(lamp.color, 4)) + self.file.write("beamWidth=\"%.4f\" " % beamWidth) + self.file.write("cutOffAngle=\"%.4f\" " % cutOffAngle) + self.file.write("direction=\"%.4f %.4f %.4f\" " % (dx, dy, dz)) + self.file.write("location=\"%.4f %.4f %.4f\" />\n\n" % location) def writeDirectionalLight(self, ob, mtx, lamp, world): safeName = self.cleanStr(ob.name) if world: ambi = world.ambient_color # ambi = world.amb - ambientIntensity = ((float(ambi[0] + ambi[1] + ambi[2])) / 3.0) / 2.5 + amb_intensity = ((float(ambi[0] + ambi[1] + ambi[2])) / 3.0) / 2.5 else: ambi = 0 - ambientIntensity = 0 + amb_intensity = 0.0 intensity = min(lamp.energy / 1.75, 1.0) dx, dy, dz = matrix_direction(mtx) self.file.write("\n\n" % (round(dx, 4), round(dy, 4), round(dz, 4))) + self.file.write("ambientIntensity=\"%.4f\" " % amb_intensity) + self.file.write("color=\"%.4f %.4f %.4f\" " % round_color(lamp.color, 4)) + self.file.write("intensity=\"%.4f\" " % intensity) + self.file.write("direction=\"%.4f %.4f %.4f\" />\n\n" % (dx, dy, dz)) def writePointLight(self, ob, mtx, lamp, world): safeName = self.cleanStr(ob.name) if world: ambi = world.ambient_color # ambi = world.amb - ambientIntensity = ((float(ambi[0] + ambi[1] + ambi[2])) / 3) / 2.5 + amb_intensity = ((float(ambi[0] + ambi[1] + ambi[2])) / 3) / 2.5 else: - ambi = 0 - ambientIntensity = 0 + ambi = 0.0 + amb_intensity = 0.0 - location = mtx.translation_part() + intensity = min(lamp.energy / 1.75, 1.0) + location = mtx.translation_part()[:] self.file.write("\n\n" % (round(location[0], 3), round(location[1], 3), round(location[2], 3))) + self.file.write("intensity=\"%.4f\" " % intensity) + self.file.write("radius=\"%.4f\" " % lamp.distance) + self.file.write("location=\"%.4f %.4f %.4f\" />\n\n" % location) def secureName(self, name): name = name + str(self.nodeID) -- cgit v1.2.3