[MXS] Unwrap_UVW - texture mapping animation


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.


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


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.


Can you paste the code here ?


Okay, so I first read the first frame’s UV coordinates and faces using this code:

setNumTVerts obj UVMapCount
  for i = 1 to UVMapCount do
  	 tu = ReadFloat f
  	 tv = ReadFloat f
  	 setTVert obj i tu tv 0.0
  buildTVFaces obj
 for i = 1 to (facesCount / 3) do
  	 uvface1 = (ReadLong f) + 1
  	  uvface2 = (ReadLong f) + 1
  	  uvface3 = (ReadLong f) + 1
  	 setTVFace obj i uvface1 uvface2 uvface3

and then I add the modifier:

addModifier obj (Unwrap_UVW())

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 :frowning:


I have not found a solution yet, sadly :frowning: 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:
[b]with animate on $.Unwrap_UVW.MoveSelected [0,0,0]

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

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

[/b]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!


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.