Advertisement

blender: exporting vertex material

Started by March 30, 2010 07:50 AM
5 comments, last by Wilhelm van Huyssteen 14 years, 8 months ago
Hey. My python blender export script can export the materialIndex(colour) of a face just fine but i would like to get the materialIndex of the vertices instead. Is this possible? Thnx in Advance
I'm pretty sure that the material index is stored in the face data structure, so you need to look up the face you care about and use that. Keep in mind that vertices can be shared between faces.

Cheers,

Bob

[size="3"]Halfway down the trail to Hell...
Advertisement
Thnx. Ok so the vertex itself cannot have a colour? i mean what if i wanted to create a face that blends between two colours. wouldnt i somehow have to asighn those different colours to the vertices of the face. Or am i just confused.
Quote: Original post by EternityZA
Thnx. Ok so the vertex itself cannot have a colour? i mean what if i wanted to create a face that blends between two colours. wouldnt i somehow have to asighn those different colours to the vertices of the face. Or am i just confused.


Exactly, you do it to the face vertices, or in other words, the indices contained in the face data structure.

Sorry im stil a bit lost. How would i do that? the vertices in the face data structure does not seem to contain any material information. unless im missing it.
Look Here, mat gives you the face material index, so you get the material as follows:

material = mesh.materials[face.mat]


face.verts gives you references to the vertices and uv texturing coordinates for each vertex.

Note that verts are of type MVert a wrapper or reference object around the actual vertex coordinates.


Here is a link to the whole API documentation.
Advertisement
thnx

This topic is closed to new replies.

Advertisement