Why doesn’t .getRGBA() return something like [R, G, B, A] instead of a value like -65536…what is that???
How can I convert [R, G, B, A] values into one of these numbers so I may set vertex colors in realtime?
Please help!
getRGBA() and setRGBA return and expect 32bit signed integer values.
here are a couple functions to convert back and forth between RGBA and integer formats:
def RGBA2int(R, G, B, A):
"Takes a list in format [R, G, B, A] and maps it to an integer."
return (A << 24) + (B << 16) + (G << 8) + R
def int2RGBA(value):
"Returns a list of RGBA values from an integer."
return [value & 255, (value >> 8) & 255, (value >> 16) & 255, (value >> 24) & 255]
Add these to the top of your script and use them to convert your RGBA lists to a value that setRGBA() can use, and to understand the values returned by getRGBA()
I hope this helps
Thanks alot wiseman303, exactly what I needed!
Okay I’m having trouble:
When the mesh only has one texture every vertex in the mesh has it’s RGBA changed but, when I set the vertex RGBA on a mesh with multiple textures only parts of the mesh that have a certain texture are set. (The texture is randomly chosen everytime I run the game.)
Whats a solution to this problem?
That’s probably because whatever method you’re using to get the vertices is only getting the vertices of one material. The first argument in getVertex() Is the material number.
I fixed the problem, it works perfectly now!!
I forgot to use the material number on getVertexArrayLength()
I just left it with ‘0’
Glad to hear you got it working