CGTalk > Software > 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 03-21-2012, 10:57 PM   #1
exjex92
New Member
portfolio
Exjex
None, Italy
 
Join Date: Mar 2012
Posts: 5
[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.
 
Old 03-23-2012, 03:43 PM   #2
MrPingouin
Veteran
 
MrPingouin's Avatar
Laurent Chea
Paris, France
 
Join Date: Aug 2005
Posts: 65
Can you precise which parameter of which modifier exactly you want to animate ?
 
Old 03-23-2012, 05:35 PM   #3
exjex92
New Member
portfolio
Exjex
None, Italy
 
Join Date: Mar 2012
Posts: 5
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.
 
Old 03-27-2012, 10:35 AM   #4
MrPingouin
Veteran
 
MrPingouin's Avatar
Laurent Chea
Paris, France
 
Join Date: Aug 2005
Posts: 65
Can you paste the code here ?
 
Old 03-30-2012, 10:01 PM   #5
exjex92
New Member
portfolio
Exjex
None, Italy
 
Join Date: Mar 2012
Posts: 5
Okay, so I first read the first frame's UV coordinates and faces using this code:
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:
Code:
addModifier obj (Unwrap_UVW())


After this, I loop through each frame and read the coordinates this way:
Code:
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 :(
 
Old 04-08-2012, 07:53 PM   #6
exjex92
New Member
portfolio
Exjex
None, Italy
 
Join Date: Mar 2012
Posts: 5
Up.
I have not found a solution yet, sadly :( Can anyone help me, please?
 
Old 04-09-2012, 01:38 PM   #7
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,511
Send a message via ICQ to denisT
Quote:
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-09-2012 at 01:43 PM.
 
Old 04-11-2012, 10:31 AM   #8
exjex92
New Member
portfolio
Exjex
None, Italy
 
Join Date: Mar 2012
Posts: 5
Quote:
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!
 
Old 04-11-2012, 10:31 AM   #9
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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 10:06 AM.


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