[Bf-extensions-cvs] [7a709b6] temp-x3d_import-T44758: Fixed a bun re:PixelTexture alpha setting
Seva Alekseyev
noreply at git.blender.org
Thu May 28 17:32:42 CEST 2015
Commit: 7a709b6a21cd6b17b818d19cd717ec0797ba8d2b
Author: Seva Alekseyev
Date: Thu May 28 11:32:16 2015 -0400
Branches: temp-x3d_import-T44758
https://developer.blender.org/rBA7a709b6a21cd6b17b818d19cd717ec0797ba8d2b
Fixed a bun re:PixelTexture alpha setting
===================================================================
M io_scene_x3d/import_x3d.py
===================================================================
diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py
index e3ba4e7..65548ba 100644
--- a/io_scene_x3d/import_x3d.py
+++ b/io_scene_x3d/import_x3d.py
@@ -2734,10 +2734,11 @@ def appearance_LoadImageTexture(imageTexture, ancestry, node):
def appearance_LoadTexture(tex_node, ancestry, node):
# Both USE-based caching and desc-based caching
+ # Works for bother ImageTextures and PixelTextures
# USE-based caching
if tex_node.reference:
- return tex_node.parsed
+ return tex_node.getRealNode().parsed
# Desc-based caching. It might misfire on multifile models, where the
# same desc means different things in different files.
@@ -2917,12 +2918,15 @@ def importShape_LoadAppearance(vrmlname, appr, ancestry, node, is_vcol):
def appearance_LoadPixelTexture(pixelTexture, ancestry):
image = pixelTexture.getFieldAsArray('image', 0, ancestry)
- plane_count = image[2]
+ (w, h, plane_count) = image[0:3]
has_alpha = plane_count in {2, 4}
pixels = image[3:]
+ if len(pixels) != w * h:
+ print("ImportX3D warning: pixel count in PixelTexture is off")
+
+ bpyima = bpy.data.images.new("PixelTexture", w, h, has_alpha, True)
+ bpyima.use_alpha = has_alpha
- bpyima = bpy.data.images.new("PixelTexture",
- image[0], image[1], has_alpha, True)
# Conditional above the loop, for performance
if plane_count == 3: # RGB
bpyima.pixels = [(cco & 0xff) / 255 for pixel in pixels
More information about the Bf-extensions-cvs
mailing list