Searched the forums for this rookie problem but nothing seems to work.
I started up an old panda project of mine and working on getting it up to speed with 1.7 (I think I last touched it with panda 1.6.0). I copySubImage a PNMImage from a 256 color bitmap image, addAlpha() to it, and then setAlpha() anytime the pixel is white.
On the model I set setTransparency(TransparencyAttrib.MDual). Put the PNM into a texture, put the texture on the model, but no transparency. All the white parts are still visible.
What alpha value are you setting where you want to have transparency? The convention is that alpha = 0 means fully transparent, while alpha = 1 means fully opaque.
Manual says addAlpha() fills with 0 (transparent), and then whenever the pixel is not white, alpha is set to 1.
The maddening thing is the code use to work, so I am flabbergasted.
def Tile(sourceImgPath = '', alphaColor = (None, None, None), tileSize = (0, 0), location = (0,0)):
sourceImage = PNMImage()
textureFile = Filename(sourceImgPath)
sourceImage.read(textureFile)
tile = PNMImage(tileSize[0], tileSize[1])
tile.copySubImage(tiles, 0, 0, location[0], location[1])
tile.addAlpha()
for x in range(tile.getXSize()):
for y in range(tile.getYSize()):
if tile.getXel(x,y) == VBase3D(alphaColor[0], alphaColor[1], alphaColor[2]):
pass
else:
tile.setAlpha(x,y,1)
return tile