CGTalk > Software Specific Forums > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 08-06-2008, 07:57 PM   #1
jectpro
Veteran
m
Canada
 
Join Date: Aug 2007
Posts: 56
animate vertex color - do i need a hack?

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:

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


Then to have this actually render do:

Code:
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.
 
Old 08-13-2008, 07:28 PM   #2
jectpro
Veteran
m
Canada
 
Join Date: Aug 2007
Posts: 56
*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.
Attached Images
File Type: jpg eg1.jpg (94.8 KB, 17 views)
 
Old 08-14-2008, 10:54 PM   #3
kikialex
New Member
Popescu
Ubisoft
Buchuresti, Romania
 
Join Date: Jul 2006
Posts: 22
Code:
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

Last edited by kikialex : 08-15-2008 at 07:09 AM.
 
Old 08-18-2008, 04:17 AM   #4
jectpro
Veteran
m
Canada
 
Join Date: Aug 2007
Posts: 56
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.
 
Old 08-18-2008, 06:50 AM   #5
kikialex
New Member
Popescu
Ubisoft
Buchuresti, Romania
 
Join Date: Jul 2006
Posts: 22
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.
 
Old 08-18-2008, 06:50 AM   #6
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:20 AM.


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