[MXS] Unwrap_UVW - texture mapping animation

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  03 March 2012
[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.
 
  03 March 2012
Can you precise which parameter of which modifier exactly you want to animate ?
 
  03 March 2012
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.
 
  03 March 2012
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 :(
 
  04 April 2012
Up.
I have not found a solution yet, sadly :( Can anyone help me, please?
 
  04 April 2012
Originally Posted by exjex92: 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.

Last edited by denisT : 04 April 2012 at 01:43 PM.
 
  04 April 2012
Originally Posted by denisT: #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!
 
  04 April 2012
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



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 07:19 PM.


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