GetFaceColor - without face selection in epoly objs

Hello All,

I read the google for a month about this topic (cpv), but it is a little bit hard. I tried long hours with syntax-tests, could solve everything but one thing...
I'm working on a gameDev tool which can store Diffuse and Lightmask ID-s for every face. The task was that i had to save two IDs by every face (Diffuse & Lightmask). I decided that use the FaceColor data to store this information.

FaceColor: [1,4,255]
--> it means that 1: Diffuse ID, ||| 4: Lightmask ID.

The complete script was created and finished up to 95%, you can see a snapshot here:

but... the process is very slooow in high detailed meshes... (30.000 tri +) - because i have to select face by face to get face colors by: <color by value><EditablePoly>.GetFaceColor <enum>Channel
...because this command means get colors from selected faces.

There is a beautiful SetFaceColor method here: polyop.SetFaceColor <Poly poly> <int mapChannel> <facelist> <Color color>
It could change face colors without selection.

How can i Get faceColors like this syntax without selection in editable poly objs?

Thanks your answer in advance!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Swordslayer's picture


Using polyop.getMapFace get the color of face texture verts for channel 0 with polyop.getMapVert (if you are using #VertexColor) and average that. Depending on how you are using that, multiply the result by 255 and cast to color. Alternatively (which might be faster approach if you are using it on whole mesh and can work with vertices instead), get color of first vertex color vert, use polyop.getVertsByColor to get all verts using this color, subtract them from the vertex color verts, get the first one of the remaining ones and repeat until there are no remaining.

Matyrix's picture

Awesome! Thanks a lot! One

Awesome! Thanks a lot!

One thing left.. I need to read MaterialID datas from the Face/VertexColor, this reading method is very clear and powerful as you wrote (polyop.getVertsByColor etc.), but how can i turn these vertices to face?

So as you wrote for example i catch the first vertex, with the polyop.getVertsByColor i get all the same vertices with the color, and... here is the next step, i have to turn this vertex-selection-data-array to face, because these faces get this ID information fom the color.

Is there any "invert method" for polyop.getMapFace to get faces from texture vertices?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.