logo   login
right
Home Forums Downloads Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Forum Info
Forum Members: 18,679
Total Threads: 8,804
Posts: 95,886

Administrators:
DeeZire, Redemption

There are currently 22 users online.
Partner Links

Free Credit Repair

Learn the Ticket Broker Secrets
Advertisements

DeeZire Online > Editing Community > Command and Conquer Editing > Generals & Zero Hour Editing » A script to export animation correctly to .3ds format

Generals & Zero Hour Editing Discuss any modding related issues to do with Generals and Zero Hour here.

Reply
 
LinkBack Thread Tools
Old 12-06-2004, 09:33 AM   #1 (permalink)
Senior Member
 
Join Date: Aug 2003
Posts: 1,087
Default A script to export animation correctly to .3ds format

If you have ever used any complex rigs in 3d Studio Max(such as a Character Studio biped or custom skeleton), and then tried to export that rigs animation correctly to .3ds file format, then Im sure you are familiar with the problem of your animation being messed up when you import that .3ds file.Problems can occur from hierarchy, and from motion controllers not supported by 3ds(ie: anything thats not TCB motion).

This script makes the process of correctly exporting animation to .3ds much easier.


Quote:
Instructions (uses the current active frame range)

*steps 1,2, 3 only need to be done the first time.

(1) On the top menu(where file, edit, tools etc are) goto MAXScript-->New Script

(2) Copy and paste the code below to the new script window that has opened

(3) In the script window, goto file-->save and give it a name(it doesnt matter, whatever is easy for you to remember), choose a location to save the file, and click save.

(4) Select all the objects that you want to export animation from, then goto MAXScript-->Run Script and select the script you just saved.

*The script creates a sphere at the pivot of each object, which assumes the objects name with the prefix 'SUB_'.Each sphere is keyframed with the animation of the object it is matched to.If you have a complex scene, computation can take a while.Still, its better than manual

(5) Press the 'H' key.Highlight all the objects from the list with the 'SUB_' prefix.Click Select

(6) Goto File-->Export Selected..., and save as .3ds file.

When you import the .3ds file, the animation plays correctly.

Code:
sel1 = selection as array
(
for i in sel1 do
(
ref_name = i.name
(
bon_sphere = Sphere radius:1.0 segs:4 
bon_sphere.name = "SUB_" + ref_name
bon_sphere.pos.controller = tcb_position ()
bon_sphere.rotation.controller = tcb_rotation ()
bon_sphere.scale.controller = tcb_scale ()

for t = animationrange.start to animationrange.end do 
(
sliderTime = t 
set animate on
bon_sphere.transform = i.transform
set animate off
)
)
)
)
While this script is functional, it could do with some optimisation.My knowledge of MaxScript is *fledgling*, and at the moment Ive got it looping through the entire animation once for every sphere created.It would be a lot faster if it created all the spheres first and then cycled through each once per frame setting the keys.Im still a bit sketchy though on arrays and general syntax.

While I do plan to optimise it myself, it would be great if Coolfile or Flyby or another maxscript wiz (killa perhaps? ) could take a look and speed it up.

Ill implement a User Interface sometime where you can specify the radius of the spheres and prefix used, and some better method of launching perhaps.Also, once optimised, Ill be able to add an option where you can specify the hierarchy of the spheres before animation is created on them(currently they are all unlinked, or effectively linked to 'world').Maybe Ill add some other functions if I can think of them or they are suggested.

Anyway, let me know what you think.
key0p is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-06-2004, 01:53 PM   #2 (permalink)
Senior Member
 
Join Date: Apr 2003
Location: England
Posts: 349
Send a message via MSN to killakanz
Default

sorry m8, I'm not a pro maxscripter
killakanz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-06-2004, 11:21 PM   #3 (permalink)
Senior Member
 
Join Date: Feb 2004
Location: China
Posts: 356
Default

the following code would make it faster, perhaps. then the loop of animation flames would NOT be needed.
Code:
bon_sphere.parent = i.parent
bon_sphere.pos.controller = i.pos.controller
bon_sphere.rotation.controller = i.rotation.controller
bon_sphere.scale.controller = i.scale.controller
btw, why don't you use bones instead of spheres?
Code:
bon_sphere = Bone name:("sub_" + i.name) pos:i.pos rotation:i.rotation
coolfile is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-07-2004, 12:04 AM   #4 (permalink)
Senior Member
 
Join Date: Aug 2003
Posts: 1,087
Default

Im am using TCB controllers rather than the original bones controllers because rotation tangents are only saved with TCB in .3ds.Any other type of controller on the object can(and almost certainly will) create errors during export.

I didnt use bones because of hierarchy - in some situations bone behaviour is not desirable.Default bones keep the same distance between pivots.I may wish to build a simplified export hierarchy where I omit cretain bones in chains.The resulting linkage would mean that some child/parent links would need thier pivots to be able to move closer or further apart.If Im going to turn off this bone feature, theres not much point using bones.In general they are also more complicated objects to deal with in maxscript.Add to that Im not really very knowledgable yet

Ive now got the sub skeleton added to a new array in the same order as the first array(created from the selected objects), Ive just got to figure out how to get 'x' in the second array to reference 'x' in the first array then I can do away with looping the animation over and over.
key0p is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-07-2004, 05:46 AM   #5 (permalink)
Senior Member
 
Join Date: Aug 2003
Posts: 1,087
Default

I figured out how to optimise it

The scene in the picture from the first post took 4 min 20 sec for the first script to run through.After optimising the script, it only took 8 seconds.

Code:
sel1 = selection as array
sel2 = #()
(
for i in sel1 do
(
ref_name = i.name
(
bon_sphere = Sphere radius:4.0 segs:4 
bon_sphere.name = "SUB_" + ref_name
bon_sphere.pos.controller = tcb_position ()
bon_sphere.rotation.controller = tcb_rotation ()
bon_sphere.scale.controller = tcb_scale ()
append sel2 bon_sphere
)
)
)
(
for t = animationrange.start to animationrange.end do 
(
sliderTime = t 
for j = 1 to sel1.count do
(
set animate on
(sel2[j]).transform = (sel1[j]).transform
set animate off
)
)
)
Now I can get around to putting in a UI and hierarchy options
key0p is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-09-2004, 09:07 AM   #6 (permalink)
Senior Member
 
Join Date: May 2004
Posts: 134
Default

i met a bit problem by using your script, i made the animation without bones, just used links, when i exported it out and imported in renx, some rotate animation were missing!
can you check it out?
homura is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-09-2004, 12:48 PM   #7 (permalink)
Senior Member
 
Join Date: Aug 2003
Posts: 1,087
Default

Sure, Ill need a copy of the 3dmax scene you are trying to export.Send it to key0p at h0tmail dot c0m

The script works on scene nodes, so it shouldnt matter what objects you take the animation from.
key0p is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-10-2004, 12:00 AM   #8 (permalink)
Senior Member
 
Join Date: May 2004
Posts: 134
Default

ok, i 've sent you a mail with my model file.
homura is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-10-2004, 04:23 AM   #9 (permalink)
Senior Member
 
Join Date: Aug 2003
Posts: 1,087
Default

3ds max 7.0 scene eh? Time for me to download the trial I guess

*Edit I just tried it on your scene and it worked fine, the animation was captured correctly on export.Ive malied you the .3ds file.

I made the script with bone based animations in mind, however, when I finish it up for a release Ill add proper features for object based animation too.
key0p is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-10-2004, 08:38 AM   #10 (permalink)
Senior Member
 
Join Date: May 2004
Posts: 134
Default

yes, the 3ds file you send me works well, and retried the script on the same model, the result was the same as before, but i tried a shorter animationed model(120 frames), your script works fine, i wonder if there is a frame limit in your script? can you check it out and fix it? cause i want to use the SDF-1 as a superweapon, it transform only at the superweapon is ready, so i want to keep this long time transform animation.
homura is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Animation Script goblinsleez Generals & Zero Hour Editing 0 03-20-2005 03:04 AM
Animation Script goblinsleez Generals & Zero Hour Editing 0 03-20-2005 03:03 AM
3dsmax export w3d? homura Generals & Zero Hour Editing 21 12-10-2004 08:53 AM
How to make this deploy animation in script. Bart Generals & Zero Hour Editing 0 09-14-2004 06:22 AM
Artillery doesnt fire correctly oobootsy1 Generals & Zero Hour Editing 3 07-06-2004 12:48 PM


All times are GMT -4. The time now is 07:01 AM.


Design By: Miner Skinz.com
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.