3
11

Update for Blender 3.x #3

Merged
Sebastian Sille merged 4 commits from blender-v3.0-release into blender-v3.1-release 2023-02-17 22:50:13 +01:00
Showing only changes of commit 44cf5e2209 - Show all commits

View File

@ -65,6 +65,7 @@ MAT_SHIN2 = 0xA041 # Shininess of the object/material (percent)
MAT_SHIN3 = 0xA042 # Reflection of the object/material (percent) MAT_SHIN3 = 0xA042 # Reflection of the object/material (percent)
MAT_TRANSPARENCY = 0xA050 # Transparency value of material (percent) MAT_TRANSPARENCY = 0xA050 # Transparency value of material (percent)
MAT_SELF_ILLUM = 0xA080 # Self Illumination value of material MAT_SELF_ILLUM = 0xA080 # Self Illumination value of material
MATSELFILPCT = 0xA084 # Self illumination strength (percent)
MAT_WIRE = 0xA085 # Only render's wireframe MAT_WIRE = 0xA085 # Only render's wireframe
MAT_TEXTURE_MAP = 0xA200 # This is a header for a new texture map MAT_TEXTURE_MAP = 0xA200 # This is a header for a new texture map
@ -467,6 +468,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SE
pct = 50 pct = 50
contextWrapper.emission_color = contextMaterial.line_color[:3] contextWrapper.emission_color = contextMaterial.line_color[:3]
contextWrapper.emission_strength = contextMaterial.line_priority / 100
contextWrapper.base_color = contextMaterial.diffuse_color[:3] contextWrapper.base_color = contextMaterial.diffuse_color[:3]
contextWrapper.specular = contextMaterial.specular_intensity contextWrapper.specular = contextMaterial.specular_intensity
contextWrapper.roughness = contextMaterial.roughness contextWrapper.roughness = contextMaterial.roughness
@ -669,6 +671,18 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SE
print("Cannot read material transparency") print("Cannot read material transparency")
new_chunk.bytes_read += temp_chunk.bytes_read new_chunk.bytes_read += temp_chunk.bytes_read
elif new_chunk.ID == MATSELFILPCT:
read_chunk(file, temp_chunk)
if temp_chunk.ID == PERCENTAGE_SHORT:
temp_data = file.read(SZ_U_SHORT)
temp_chunk.bytes_read += SZ_U_SHORT
contextMaterial.line_priority = int(struct.unpack('H', temp_data)[0])
elif temp_chunk.ID == PERCENTAGE_FLOAT:
temp_data = file.read(SZ_FLOAT)
temp_chunk.bytes_read += SZ_FLOAT
contextMaterial.line_priority = (float(struct.unpack('f', temp_data)[0]) * 100)
new_chunk.bytes_read += temp_chunk.bytes_read
elif new_chunk.ID == MAT_TEXTURE_MAP: elif new_chunk.ID == MAT_TEXTURE_MAP:
read_texture(new_chunk, temp_chunk, "Diffuse", "COLOR") read_texture(new_chunk, temp_chunk, "Diffuse", "COLOR")
@ -686,11 +700,18 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SE
read_texture(new_chunk, temp_chunk, "Bump", "NORMAL") read_texture(new_chunk, temp_chunk, "Bump", "NORMAL")
elif new_chunk.ID == MAT_BUMP_PERCENT: elif new_chunk.ID == MAT_BUMP_PERCENT:
read_chunk(file, temp_chunk)
if temp_chunk.ID == PERCENTAGE_SHORT:
temp_data = file.read(SZ_U_SHORT) temp_data = file.read(SZ_U_SHORT)
new_chunk.bytes_read += SZ_U_SHORT temp_chunk.bytes_read += SZ_U_SHORT
contextWrapper.normalmap_strength = (float(struct.unpack('<H', temp_data)[0]) / 100) contextWrapper.normalmap_strength = (float(struct.unpack('<H', temp_data)[0]) / 100)
elif temp_chunk.ID == PERCENTAGE_FLOAT:
temp_data = file.read(SZ_FLOAT)
temp_chunk.bytes_read += SZ_FLOAT
contextWrapper.normalmap_strength = float(struct.unpack('f', temp_data)[0])
new_chunk.bytes_read += temp_chunk.bytes_read new_chunk.bytes_read += temp_chunk.bytes_read
elif new_chunk.ID == MAT_SHIN_MAP: elif new_chunk.ID == MAT_SHIN_MAP:
read_texture(new_chunk, temp_chunk, "Shininess", "ROUGHNESS") read_texture(new_chunk, temp_chunk, "Shininess", "ROUGHNESS")