Get Vertex Color from Mesh

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  12 December 2010
Get Vertex Color from Mesh

Hi Guy,

i have a newbie question. I have look here at other Treads, but i don´t unterstand. How can i get a the Vertex Color of Vertex[24] from a Mesh?

my_color = my_mesh.getVertexcolor[24] ( don´t work )

hot chip
  12 December 2010
my_color = getVertColor my_mesh 24
  12 December 2010
hi AnoPrkl,

thank you for help. I have convert my Poly Object to a Mesh Object, but it comes a error message: "vertex index out of range"

for i=1 to vertex_anzahl do (

vertex_farbe = getVertColor th_mesh i


and what must i do, when my mesh is a editable Poly, because my mesh is a editable Poly Object.

hot chip
  12 December 2010
You can use,

$.SetVertexColor (color 128 128 128) #VertexColor

This is for an EditablePoly Object, but you have to be in sub-object level 1 I believe with the vertex selected, otherwise it doesn't work.

Hope that helps.
  12 December 2010
hi matthew

thank you. How can i say Vertex 24 for example, and i must read all Vertex of Poly-Object and check if the Color Red, Green or Blue.
  12 December 2010
That command works on the selected vertex.

So you would loop through all the verts like...


local theMesh = selection[1]
setCommandPanelTaskMode #modify
subObjectLevel = 1

For v = 1 to theMesh.mesh.verts.count do
theMesh.EditablePoly.SetSelection #Vertex #{v}
local theVertColor = theMesh.getVertexColor #VertexColor
print theVertColor

  12 December 2010
Super It work´s. Thank you very much.

hot chip
  12 December 2010

check MXS Help:
Editable_Poly Mapping Methods
Vertex Colors

the Vertex Color Channel is Map Channel #0

	n = converttopoly (box())
	polyop.setvertcolor n 0 #{1,4} red 
	polyop.setvertcolor n 0 #{2,5,7} blue 
	polyop.setvertcolor n 0 #{3} green 
	polyop.setvertcolor n 0 #{6,8} black
	format "red:%\n" (polyop.getvertsbycolor n red 0 0 0 channel:0) 
	format "blue:%\n" (polyop.getvertsbycolor n blue 0 0 0 channel:0) 
	format "green:%\n" (polyop.getvertsbycolor n green 0 0 0 channel:0) 

Last edited by denisT : 12 December 2010 at 07:29 PM.
  12 December 2010
Hi Denis,

thank you to the code. From time to time, i understand more and more.
  12 December 2010
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 05:36 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.