Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-03-13 11:21:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-03-13 11:21:06 +0400
commit477d73fd172f5963f5d74ddffc4372bc948aa9fa (patch)
tree0a0bb78ed3ecbe93ee9186752fcb027bf480b556 /io_scene_3ds
parent2c236d3c8124959434f73f6c93ddc8fe6d13292f (diff)
patch [#34591] 3DS importer: material transparency value short/float fix
from Andreas Atteneder (atti)
Diffstat (limited to 'io_scene_3ds')
-rw-r--r--io_scene_3ds/import_3ds.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/io_scene_3ds/import_3ds.py b/io_scene_3ds/import_3ds.py
index c400bbd9..745dd433 100644
--- a/io_scene_3ds/import_3ds.py
+++ b/io_scene_3ds/import_3ds.py
@@ -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 @@ OBJECTINFO = 0x3D3D # This gives the version of the mesh and is found right bef
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 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
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.