00001 /*
00002 File: Animator.cc
00003
00004 Function: Little command line interface to the Animation class.
00005
00006 Author: Andrew Willmott
00007
00008 Notes:
00009 */
00010
00011 #include "Animation.h"
00012 #include "cl/ArgParse.h"
00013
00014 Int main(Int argc, Char *argv[])
00015 {
00016 Animation anim;
00017 Double fps = 24.0;
00018 Int startFrame = -1, endFrame = -1, frameStep = 1;
00019 Int frame;
00020 GCLReal time;
00021 Char *file1;
00022
00023 // command-line options
00024
00025 if (arg_parse(argc, argv,
00026 "", "usage: anim [options]",
00027
00028 "%S", &file1, "animation file",
00029 "-fps %F", &fps, "set frames per sec [default 24]",
00030 "-start %d", &startFrame, "start frame [1]",
00031 "-end %d", &endFrame, "end frame [24]",
00032 "-step %d", &frameStep, "frame step [1]",
00033 "-d", ARG_FLAG(&anim.addDash), "add dashes to variables",
00034 "-q", ARG_FLAG(&anim.quiet), "quiet",
00035 "-o %S", &anim.tag, "output tag_<frame>",
00036
00037 0) < 0)
00038 exit(1);
00039
00040 anim.ParseAnimFile(file1);
00041 if (startFrame < 0)
00042 {
00043 startFrame = 1;
00044 if (endFrame < 0)
00045 endFrame = Int(anim.length * fps);
00046 }
00047 else if (endFrame < 0)
00048 endFrame = startFrame;
00049
00050 for (frame = startFrame; frame <= endFrame; frame += frameStep)
00051 {
00052 time = (frame - 1) / fps;
00053 anim.DumpAvars(time, frame);
00054 }
00055 }
00056