PDA

View Full Version : animate vertex color - do i need a hack?


jectpro
08-06-2008, 08:57 PM
I am attempting to animate vertex color, but have read so many parts of the maxscript documentation over the last few days that i think i am beginning to confuse myself.

I have no problem doing this without animation. Working with a box, i change it to an editable mesh then do:

meshop.setVertColor myBox 0 #{1} (color 0 0 0)

Then to have this actually render do:

materialShowVert = standard()
materialShowVert.diffusemap = vertex_color()
myBox.material = materialShowVert

This renders fine, but i am now sort of stuck, and slightly confused. Much of the documentation of vertex+color points to the "Mesh Color-Per-Vertex Methods" and "Mesh Texture Vertex Methods" which I don't think I want because they work on channel 1, and my info is in channel 0 and is already referencing my material that references the verex colors, so i have no need to use these UV mapping methods (?). As far as I see, all I need to do now is use keyframes to set new values, but I can't figure out what block controller I need to be referencing!

I'm also wondering why in meshop I can only set a color, it would be nice to eventually be able to get a vertex color, but getVertColor is again in the legacy "Mesh Texture Vertex Methods".

So then what is the best way to go about all this? Is there any hacks I should be looking into? One thing I was thining about was copying channel info from one to another to gain access to methods that only exist in channel 1 using methods form "Meshop Vertex Data Methods"? Before taking any odd road, wanted to check in with the vetrans. Thanks for any help on my information overload.

jectpro
08-13-2008, 08:28 PM
*bump* i dont know if im asking for something beyond max, or if my ways of trying to go about it dont make sense? any feedback would be very appreciated!

what i am trying to do is animate a mesh color, sort of like when "soft seleciton" is used and shown on the viewport. I'd like that have a color band "travel through" the mesh, for example, the circle like in the attachment getting bigger. I'm looking at animating the vertex colors so that max can deal with extrapolating the wire color.

kikialex
08-14-2008, 11:54 PM
macroScript Uvw_Vertex_paint_Animation_Tool
category:"Alex_tools"
toolTip:""
(
local qwasdew1234bbbbbbbbbbb = false
--------------------------------------------------
fn GetPos unwrap_uvw1 f v =
(
unwrap_uvw1.unwrap.getVertexPosition 0 (unwrap_uvw1.unwrap.getVertexIndexFromFace f v)
)

fn save_uv =
(
----------------
unwrap_uvw1 = undefined
for m in selection[1].modifiers do
if ((classof m) == unwrap_uvw) do
(
unwrap_uvw1 = m
)

if unwrap_uvw1 != undefined then
(
out_name = ((GetDir #export)+"/uvw_.dat")
out_file = createfile out_name
frm = ticksPerFrame * sliderTime
num_faces = unwrap_uvw1.unwrap.numberPolygons()
format "%,%,%\n" num_faces frm ticksPerFrame to:out_file
for f = 1 to num_faces do
(
num_verts = unwrap_uvw1.unwrap.numberPointsInFace f
format "%,%\n" f num_verts to:out_file
for v = 1 to num_verts do
format "%,%,%\n" f v (GetPos unwrap_uvw1 f v) to:out_file
)
close out_file
)
else
(
MessageBox("You don't have a Uvw_Unwrap modiffier on that object")
)
)


fn load_uv =
(
animate on --
(
time1 = 1 * sliderTime
---------------
unwrap_uvw1 = undefined
for m in selection[1].modifiers do
if ((classof m) == unwrap_uvw) do
(
unwrap_uvw1 = m
)
---------------
in_name = ((GetDir #export)+"/uvw_.dat")
in_file = openFile in_name
if (in_file != undefined) and (unwrap_uvw1 != undefined) then
(
num_faces = readValue in_file
dummy1 = readValue in_file
dummy2 = readValue in_file
for f = 1 to num_faces do
(
dummy1 = readValue in_file
num_verts = readValue in_file
for v = 1 to num_verts do
(
dummy1 = readValue in_file
dummy2 = readValue in_file
vert = readValue in_file
idx1 = unwrap_uvw1.unwrap.getVertexIndexFromFace f v
at time time1 unwrap_uvw1.unwrap.setVertexPosition time1 idx1 vert
)
)
close in_file
)
else
(
MessageBox("You don't have a Uvw_Unwrap modiffier on that object")
)
)
)

rollout uvw_123qweRollout "UVW" width:162 height:90
(
button btn1 "Copy_UVW" pos:[8,4] width:145 height:32
button btn3 "?" pos:[8,37] width:145 height:16
button btn2 "Paste_UVW" pos:[8,54] width:145 height:32


on uvw_123qweRollout close do
(
qwasdew1234bbbbbbbbbbb = false
)

on btn1 pressed do
(
save_uv()
)
on btn2 pressed do
(
load_uv()
)
on btn3 pressed do
(
MessageBox "-You clone the object that you want to animate
-You change the vertex-color on the clone
for vertex paint you:
- Add a Unwrap UVW on the clone and set the channel on : Vertex Color Channel
- press Reset UVWs
- Add a Unwrap UVW on the original and set the channel on : Vertex Color Channel
- press Reset UVWs
-Select the clone and press Copy_UVW
-Select the original,and on the frame you want to press Paste_UVW
" title:"How to?"
)
)

on execute do
(
if qwasdew1234bbbbbbbbbbb != true do
(
createDialog uvw_123qweRollout
qwasdew1234bbbbbbbbbbb = true
)
)
)

-You clone the object that you want to animate
-You change the vertex-color on the clone
for vertex paint you:
- Add a Unwrap UVW on the clone and set the channel on : Vertex Color Channel
- press Reset UVWs
- Add a Unwrap UVW on the original and set the channel on : Vertex Color Channel*
- press Reset UVWs*
(*you need only one Unwrap UVW on the original object,for all the frames that you are going to make)
-Select the clone and press Copy_UVW
-Select the original,and on the frame you want to press Paste_UVW

jectpro
08-18-2008, 05:17 AM
Thanks for this code kikialex! I'll have to study this some as i have not scripted with uvw mapping before, but im not sure if this approach will take me where i want to go in a direct route.

From what i can gather thus far from your code (i think..), the way that the vertex colors change is by cloning the object, then stripping the mapping on the object, manually changing the vertex paint that was on there (or have a pre-existing one), then loading in this changed color as new map on to the vertices of a cloned object.

I was hoping to avoid uvw mapping completely since i dont have any uvw maps - i was wanting to define color changes as functions that max can calculate, then represent that caclulation in the form of color. So for example, in my attached jpg, vertices would be colored as a function of how they are from the center of the color circle, and as the radius grows in the animation, more of the vertices are therefore colored in a predefined gradient.

If UVW mapping is the only way to go, i will basically have to do a simulation in another program other than max to algothymically get all my colors, then save images, then use uvw mapping to show what some other program did. Doable, but I would rather have the whole project in max, partically do practice my maxscripting, and also to get a better pipeline going for any similar simulations.

kikialex
08-18-2008, 07:50 AM
For 3D Max there is no difference between vertex-color and UVW's ,this script is working with that
You don't need mapping for the objects affected by this script.

CGTalk Moderation
08-18-2008, 07:50 AM
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.