[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4369] trunk/py/scripts/addons/ io_scene_3ds/import_3ds.py: patch [#34591] 3DS importer: material transparency value short/float fix
Campbell Barton
ideasman42 at gmail.com
Wed Mar 13 08:21:06 CET 2013
Revision: 4369
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4369
Author: campbellbarton
Date: 2013-03-13 07:21:06 +0000 (Wed, 13 Mar 2013)
Log Message:
-----------
patch [#34591] 3DS importer: material transparency value short/float fix
from Andreas Atteneder (atti)
Modified Paths:
--------------
trunk/py/scripts/addons/io_scene_3ds/import_3ds.py
Modified: trunk/py/scripts/addons/io_scene_3ds/import_3ds.py
===================================================================
--- trunk/py/scripts/addons/io_scene_3ds/import_3ds.py 2013-03-12 18:20:42 UTC (rev 4368)
+++ trunk/py/scripts/addons/io_scene_3ds/import_3ds.py 2013-03-13 07:21:06 UTC (rev 4369)
@@ -19,7 +19,7 @@
# <pep8 compliant>
# Script copyright (C) Bob Holcomb
-# Contributors: Bob Holcomb, Richard L?rk?ng, Damien McGinnes, Campbell Barton, Mario Lapin, Dominique Lorre
+# Contributors: Bob Holcomb, Richard L?rk?ng, Damien McGinnes, Campbell Barton, Mario Lapin, Dominique Lorre, Andreas Atteneder
import os
import time
@@ -44,6 +44,10 @@
VERSION = 0x0002 # This gives the version of the .3ds file
EDITKEYFRAME = 0xB000 # This is the header for all of the key frame info
+#------ Data Chunks, used for various attributes
+PERCENTAGE_SHORT = 0x30
+PERCENTAGE_FLOAT = 0x31
+
#------ sub defines of OBJECTINFO
MATERIAL = 0xAFFF # This stored the texture info
OBJECT = 0x4000 # This stores the faces, vertices, etc...
@@ -574,10 +578,18 @@
elif new_chunk.ID == MAT_TRANSPARENCY:
#print 'elif new_chunk.ID == MAT_TRANSPARENCY:'
read_chunk(file, temp_chunk)
- temp_data = file.read(STRUCT_SIZE_UNSIGNED_SHORT)
- temp_chunk.bytes_read += 2
- contextMaterial.alpha = 1 - (float(struct.unpack('<H', temp_data)[0]) / 100)
+ if temp_chunk.ID == PERCENTAGE_SHORT:
+ temp_data = file.read(STRUCT_SIZE_UNSIGNED_SHORT)
+ temp_chunk.bytes_read += STRUCT_SIZE_UNSIGNED_SHORT
+ contextMaterial.alpha = 1 - (float(struct.unpack('<H', temp_data)[0]) / 100)
+ elif temp_chunk.ID == PERCENTAGE_FLOAT:
+ temp_data = file.read(STRUCT_SIZE_FLOAT)
+ temp_chunk.bytes_read += STRUCT_SIZE_FLOAT
+ contextMaterial.alpha = 1 - float(struct.unpack('f', temp_data)[0])
+ else:
+ print( "Cannot read material transparency")
+
new_chunk.bytes_read += temp_chunk.bytes_read
elif new_chunk.ID == OBJECT_LAMP: # Basic lamp support.
More information about the Bf-extensions-cvs
mailing list