Get Vertex Color

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2008   #1
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".
Thanks

__________________
Blogger
 
Old 04 April 2008   #2
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.
 
Old 04 April 2008   #3
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
			disableSceneRedraw()

			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
				--vertice
				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
			)
			enableSceneRedraw()
		)
	)
)
__________________
Borja Morales
r3D

Last edited by Reality3D : 04 April 2008 at 08:19 PM.
 
Old 04 April 2008   #4
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.
__________________
Blogger
 
Old 04 April 2008   #5
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 08:43 AM.


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