Hello everyone, I'm new to this community and I'm posting here to seek for help. I am actually pretty new to 3DS Max in general, and even newer to Maxscript. However, having a past programming experience, it wasn't that hard to understand how things work there. I managed to create two importers for some 3D file formats of a game, using purely maxscript.
Mesh building, uv coordinates, and animations work perfectly, the only problem I have is when it comes to UV coordinates animation. This format stores UV coordinates for every single frame, so my problem is not where to get the data from: it's actually how to apply it and make it animated. It seems that Unwrap_UVW supports UV animations, but I wasn't able to get it working using maxscript, it only works when doing the work manually (and it's a great hassle, to be honest). So, question is: how do I get this damn modifier to animate my texture mappings through maxscript? Does anyone have any example I can start from? Thank you in advance.

MrPingouin

03 March 2012, 03:43 PM

Can you precise which parameter of which modifier exactly you want to animate ?

exjex92

03 March 2012, 05:35 PM

It's the Unwrap_UVW modifier, or at least I think so. Doing some researches, it seemed like it was the only modifier able to animate UV mappings. Thing is, following the documentation I have found a function, SetVertexPosition, which even accepts a time parameter. I tried using that, but it does not work. I think it does not set the keys somehow, but I have no idea why.

MrPingouin

03 March 2012, 10:35 AM

Can you paste the code here ?

exjex92

03 March 2012, 10:01 PM

Okay, so I first read the first frame's UV coordinates and faces using this code:
setNumTVerts obj UVMapCount

After this, I loop through each frame and read the coordinates this way:
animate on
(
for i = 1 to numFrames - 1 do
(
at time i
(

... [some other code here, unrelevant] ...

for j = 1 to UVMapCount do
(
tu = ReadFloat f
tv = ReadFloat f
print("UV Coordinates at time "+(i as string)+", vertex "+(j as string)+": "+(tu as string)+", "+(tv as string))
obj.Unwrap_UVW.SetVertexPosition i j [tu, tv, 0.0]
--meshOp.setMapVert obj 1 j [tu, tv, 0.0]
)
)
)
)
But it does not work. It does not move the UV coordinates, or, even worse, it looks like it just considers the last coordinates for the whole animation. I do really have no idea why this would happen, I am new to this but by reading the documentation, this seems to be how UV animations should be treated... but I probably misunderstood something :(

exjex92

04 April 2012, 07:53 PM

Up.
I have not found a solution yet, sadly :( Can anyone help me, please?

denisT

04 April 2012, 01:38 PM

Up.
I have not found a solution yet, sadly :( Can anyone help me, please?
#1 you have to force MAX create controllers for Unwrap_UVW points.
you can do it selecting all verts and calling:
with animate on $.Unwrap_UVW.MoveSelected [0,0,0]

#2 you have to create a key for every point controller
like:
addnewkey $.Unwrap_UVW[<k>].controller 0f

#3 use animate context (with animate on) when you set position (or move) vertices.

you have to understand that to make everything work the modifier has to be current modified object and UV Editor has to be opened.

exjex92

04 April 2012, 10:31 AM

#1 you have to force MAX create controllers for Unwrap_UVW points.
you can do it selecting all verts and calling:
with animate on $.Unwrap_UVW.MoveSelected [0,0,0]

#2 you have to create a key for every point controller
like:
addnewkey $.Unwrap_UVW[<k>].controller 0f

#3 use animate context (with animate on) when you set position (or move) vertices.

you have to understand that to make everything work the modifier has to be current modified object and UV Editor has to be opened.
Hello denisT,
thank you so much for your post! This helped me a lot, I managed to figure out the problem and it all works perfectly fine now! The problem was I weren't selecting the object, so the Unwrap_UVW modifier wasn't "active". I was already using the animate context, and the function I used to move the vertices is Unwrap_UVW.SetVertexPosition. It is working just fine right now, thank you again!

CGTalk Moderation

04 April 2012, 10:31 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.

Follow Us On:

The CGSociety

The CGSociety is the most respected and accessible global organization for creative digital artists. The CGS supports artists at every level by offering a range of services to connect, inform, educate and promote digital artists worldwide. More about us on TheArtSociety.com