Trespasser supports Animation scripts!

Released! - TresCom Ops' TC Act 2 Archive Forum.

Moderators: scallenger, Hilwo, Kovu

Remdul
-=TresCom Developer=-
-=TresCom Developer=-
Posts: 1845
Joined: Mon Jul 22, 2002 12:35 pm
Location: Holland, Europe

Post by Remdul »

Code: Select all

utility AsaExp "AsaExp"
(
 group "About"
 (
  label lab1 "Animation Script Exporter"
  label lab2 "Version 0.1 Beta"
  label lab3 "by Martijn Buijs"
  label lab4 "Copyright TresCom, 2003"
 )
 group "Export"
 (
  checkbox chkForcedRate "Forced Framerate" enabled: false checked: true
  button cmdExport "Export Animation"
 )
 on cmdExport pressed do
 (
  filename = getSaveFileName caption:"Export Animation" types:"Animation Script (*.asa)|*.asa|Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
  if filename != undefined then
  (
   fileobj = createfile filename
   format "version 2\n" to: fileobj
   if chkForcedRate.checked then
   (
    format "forced_rate %\n\n" frameRate to: fileobj
   ) else (
    format "forced_rate 0\n\n" to: fileobj
   )
   for i=1 to objects.count do
   (
    ExpObj objects[i] chkForcedRate.checked
   )
   close fileobj
  )
 )
)

fn WriteFrames obj =
(
 for j=animationRange.start to animationRange.end do
 ( 
  sliderTime = j
  format "frame %\n" ((j/160) as integer) to: fileobj
  format "pos % % %\n" obj.position.x obj.position.y obj.position.z to: fileobj
  format "rot % % % %\n" obj.rotation.x obj.rotation.y obj.rotation.z obj.rotation.w to: fileobj
  format "scale %\n\n" ((obj.scale.x + obj.scale.y + obj.scale.z) / 3) to: fileobj
 )
)

fn ExpObj obj forcedrate = 
( 
 --MaxScript is a bit buggy :-(
 --Workaround starts here...
 if (superclassof(obj) == GeometryClass) do
 (
  format "object %\n\n" obj.name to: fileobj
 )
 --...and ends here.
 case superclassof(obj) of
 (
  GeometryClass:
   --format "object %\n\n" obj.name to: fileobj --this crashes for some weird reason, see workaround above
   if forcedrate then
   (
    WriteFrames obj
   ) else (
    --WriteKeyFrames obj
   )
  camera:
   if classof(obj) == FreeCamera do
   (
    format "object Camera\n\n" obj.name to: fileobj
    if forcedrate then
    (
     WriteFrames obj
    ) else (
     --WriteKeyFrames obj
    )
   )
 )
 format "end_object\n\n" to: fileobj
)
Here's the maxscript code. It's a bit of a mess but I'll clean it up in a future version.

Works with all primitives and meshes (Geometry class to be exact). What it does is loop thru all objects and prints the position, rotation, scale (averaged x,y,z scale) for each frame. That means that bone systems, noise controllers (for camera shake for example) and other helpers/tools in MAX can be used to animate them.

Haven't implemented keyframes. Would make the animation scripts smaller, but it doesn't work for non-linear trajectories.
Also, MAX's camera rotations (FreeCamera only) don't apear be like that of other nodes and I haven't figured out how it does work.

It's pretty cool to animate stuff like this... :)
Andres
-=TresCom Developer=-
-=TresCom Developer=-
Posts: 113
Joined: Thu Nov 14, 2002 8:35 pm
Contact:

Post by Andres »

I did some quick tests trying to animate a dinosaur. Can animate "RaptorB" but the dino is frozen in default position. Then for the following, must at least mention RaptorB in the script or nothing at all happens: can animate the physics objects ("Head" etc.) fine. But when trying to move joints the dino just sat there twitching.
Don't let me put you off trying yourself, as animated dinos would be very cool and my tests weren't very thorough.

(From my tests it seemed that in Trespasser the default Camera orientation is Y-axis "forward" and Z-axis "up", and the rotation is applied to that.)
Remdul
-=TresCom Developer=-
-=TresCom Developer=-
Posts: 1845
Joined: Mon Jul 22, 2002 12:35 pm
Location: Holland, Europe

Post by Remdul »

Hmm, I checked out the generated .asb files and it seems as if these include many more keyframes than the original ASCII script (hence the bigger file size). My 3d file visualization app shows a swirling rows of dots (forming a path), which most likely are positions, an curve which probably are the rotations.

Not really that interesting, but I'm trying to figure out whether these could have been use for dino animations...
User avatar
Rebel
-=TresCom Developer=-
-=TresCom Developer=-
Posts: 6123
Joined: Sun Nov 10, 2002 10:26 pm
Location: That country nobody likes (you know the one)
Contact:

Post by Rebel »

Just a personal opinion, but I think that were just considering the animations for cinematic views and perhaps puzzlin problems like those energy cells in pv (though that's probably a stretch).
Remdul
-=TresCom Developer=-
-=TresCom Developer=-
Posts: 1845
Joined: Mon Jul 22, 2002 12:35 pm
Location: Holland, Europe

Post by Remdul »

Yeah, I'm afraid you are right. They wouldn't need the camera to move for any dino animations, but I'm still hoping that the animations wheren't hard coded (in the form of mathematical calculations) so thy can be altered to our needs...
Locked