Get Vertex Color

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
  04 April 2008
Get Vertex Color

Hi, I´m trying to do a dome-light type script getting the lights color and position from from verts. My problem is that I can´t find a method get the color from a selected vertex. There is a getVertColor method, but the color number and the vertex number it is not the same. So if I have:
vert = getVert obj i
It is any way to get the color from "vert".

  04 April 2008
Get Vertex Color

" vert = getVert obj i "
This will only get the position value of vertex " i ", not the vertex color.

Maybe you can do something like this,
num_verts = getNumCPVVerts $

for i = 1 to num_verts do
vert_color = getVertColor $ i
print vert_color
And, you need to have color value on Vetex Color Channel "0".
Means that you have to genertate Vertex Color for the geometry first before you get vertex color.

Hope this is what you are looking for.
  04 April 2008
Here is a bit hack to do that. I don't think this is the best way but...

I don't know why you have to add 1 to theMapV at the end (0 index based versus 1 :?!). And when you assign a target to the light you can't assign a material to the source object!
	with undo off
		objTransform = selection[1]
		if classof objTransform == Editable_Poly then
			uvChannel = 0 --Usado por vertex Color			
			obj = selection[1].EditablePoly

			for vertexIndex=1 to obj.GetNumVertices() do --loop through all vertices
				theFace = obj.GetVertexFace vertexIndex 1 --Primera cara que comparte ese vertice
				indexInFace = 1 --Aqui guardo en qué indice de la cara está nuestro vértice
				--Recorro la cara y descubro el vértice en qué indice está
				for faceVertex = 1 to (obj.GetFaceDegree theFace) do
					theVertexIndex =  obj.GetFaceVertex theFace faceVertex 
					if theVertexIndex == vertexIndex then --Son iguales, guardo el índice
						indexInFace = faceVertex 
				--Y ahora hago un lookup del indice UV de esa cara en el indice en el que está nuestro
				theMapV = obj.GetMapFaceVertex uvChannel theFace indexInFace
				kolorea = ((obj.getMapVertex uvChannel (theMapV+1))*255) as color
				vert = (obj.getVertex vertexIndex)*objTransform.transform --Coger el vértice en mundo
				argia = Directionallight rgb:kolorea pos:[vert.x,vert.y,vert.z] target:objTransform
				argia.wirecolor = kolorea
Borja Morales

Last edited by Reality3D : 04 April 2008 at 08:19 PM.
  04 April 2008
Thank Geng.
Thank you Borja! That is what I'm looking for. Great work as always. I'm going to add a UI.
Thanks again.
  04 April 2008
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 09:02 AM.

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