PDA

View Full Version : apply a vertex color map to a surface



Svenart
07-19-2009, 12:29 AM
im trying to write a script wich will color an object with a vertex color map. But its not working, maybe because i dont know how to apply a vertex color map to a surface.

here my code:

moninit(editbegin());

myMap = VMap(VMRGB, "colormap", 2);

foreach(p,points)
{

myMap.setValue(p,<255,255,255>);

monstep();
}
monend();
editend();


can anybody help me with this?

dpont
07-19-2009, 01:21 AM
Did you tried an array of floating values, instead of a vector of integers?

Denis.

evenflcw
07-19-2009, 04:53 AM
myMap = VMap(VMRGB, "colormap", 2);

Shouldn't it be 3 at the end? R, G, B!

dpont is likely correct aswell.

Svenart
07-19-2009, 09:00 AM
thank you for your answers. I changed now the code a little bit, but still nothing happens. It seems that I have to apply the vertexmap to a surface, but I dont know how.

@version 2.6
@warnings
main
{

selmode(USER);
moninit(editbegin());

myMap = VMap(VMRGB, "color",3);

temp[1] = 5;
temp[2] = 5;
temp[3] = 5;

foreach(p,points)
{

myMap.setValue(points[p], temp);

monstep();
}
monend();
editend();

}

dpont
07-19-2009, 09:24 AM
myMap = VMap(VMRGB, "color", 3);//dimension = 3

A color channel (float) is 0.0<->1.0

Denis.

Svenart
07-19-2009, 09:26 AM
thank you. I tried this but still nothing happens unforunately :(

@version 2.6
@warnings
main
{

selmode(USER);
moninit(editbegin());

myMap = VMap(VMRGB, "color", 3);

temp[1] =1.0;
temp[2] = 1.0;
temp[3] = 1.0;

foreach(p,points)
{

myMap.setValue(p, temp);

monstep();
}
monend();
editend();

}

Svenart
07-19-2009, 09:27 AM
it only works, if i create a vmap manually(and apply to surface) and then add color with script. But I cannot create a vmap wich is working with lscript.

dpont
07-19-2009, 09:31 AM
It works here,
I made a simple box in Modeler,
launched the above lscript,
then select a few points and press "i" for
point info.

Denis.

Svenart
07-19-2009, 09:35 AM
thank you. You are right, the color is shown now in the pointinfo window. But I still cannot see the color on the mesh.

dpont
07-19-2009, 09:38 AM
In Surface editor, Advanced tab,
"Vertex Color Map" select your map.

Denis.

Svenart
07-19-2009, 09:39 AM
wow.... thank you very much:) I will try to script this.

Svenart
07-19-2009, 09:52 AM
do you (or anyone else) also know, how I can choose the vmap in the surface with lscript?

evenflcw
07-19-2009, 10:09 AM
Probably this... scroll up for the "channel" constant for colorvmap.

http://www.mikegreen.name/Lscript/Source/Surfaces.htm#setValue

Svenart
07-19-2009, 10:13 AM
yes, but I can only get the value for vertex coloring (%), not the name of the map.

surfObj = Surface();
x=surfObj.getValue(SURFVCOL);
info ("x");

evenflcw
07-19-2009, 10:36 AM
My mistake... I figured the number would be the vmap index. I guess it might not be possible in lscript then.

Sensei
07-21-2009, 05:51 AM
In LWSDK you can do so, by using LWSurfaceFuncs function:

void (*setColorVMap)(LWSurfaceID surf,
const char *vmapName, int type);

So.. rewrite your script in C/C++ and it'll work..

Svenart
07-21-2009, 08:09 AM
thank you Sensei.

Melmoth
10-25-2009, 05:07 AM
O great scripters ! Please hear my wee voice... :bowdown:

Svenart, have you write your script in C/C++ and find a solution?
As You can see below, your script could be a solution for me... a faster way...

http://www.newtek.com/forums/showthread.php?t=62229&highlight=vertex

I always search a "nodal way" to color a polygon or a part of polygons with a vertex color point or a specific pixel... so a specific spot...???
I would like to understand the mysterious " Spot Info"... :cry:

I would like to find a nodal scheme that could point at a specific pixel and give his color to a whole polygon... Is this a dream? Is there a nodal-spot way to do this?

Please :help:

Sensei
10-25-2009, 06:34 AM
Spot Info is just information where ray (usually traveling from camera - primary ray), hit polygon..
Scripts are interpreted, plug-ins are compiled to CPU machine code. You can't write script for node in LScript. There is needed C/C++ plug-in.
What is in thread that you gave link is absolute easy, 5 minutes job, for node programmer.

Melmoth
10-25-2009, 06:46 AM
Yes Sensei,
I guess it's easy but who will accept to do this?
Unfortunately, i'm not a node programmer et don't know anyone...

:cry: