Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2399 - in trunk: Model/MiscObjects scenes


Chronological Thread 
  • From: "Andrew Kensler" < >
  • To:
  • Subject: [Manta] r2399 - in trunk: Model/MiscObjects scenes
  • Date: Wed, 8 Apr 2009 17:17:58 -0600 (MDT)

Author: aek
Date: Wed Apr  8 17:17:56 2009
New Revision: 2399

Modified:
   trunk/Model/MiscObjects/KeyFrameAnimation.cc
   trunk/Model/MiscObjects/KeyFrameAnimation.h
   trunk/scenes/triangleSceneViewer.cc
Log:
* Added fixed interpolation mode to KeyFrameAnimation.  This takes
  fixed-size steps through the animation regardless of wall-clock time.
  The duration becomes the total number of frames to show the animation in.
* Added -fixedAnimation to triangle scene viewer to activate this.
* Added -noLoop to set the looping flag on the animation.

* Fix for stupid bug with .anim files loading last scene twice.



Modified: trunk/Model/MiscObjects/KeyFrameAnimation.cc
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.cc        (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.cc        Wed Apr  8 17:17:56 
2009
@@ -123,7 +123,19 @@
         differentFrame = false;
       }
       else {
-        if (lockedFrames) {
+        if (interpolation == fixed) {
+          float newTime = currTime + 1.0;
+          if (!loop && newTime >= duration)
+            pauseAnimation();
+          else
+          {
+            newTime = wrapTime(newTime);
+            differentFrame = isDifferentFrame(newTime);
+            currTime = newTime;
+            //cerr << "Current frame: " << currTime << "/" << duration << 
endl;
+          }
+        }
+        else if (lockedFrames) {
           if (interpolation == linear) {
             const int fps = 30;
             float oldTime = currTime;
@@ -131,7 +143,7 @@
             if (dur == 0)
               currTime = 0;
             else
-              currTime = wrapTime(currTime + numFrames/(duration*fps));
+              currTime = wrapTime(currTime + numFrames/dur);
             differentFrame = isDifferentFrame(oldTime);
           }
           else if (interpolation == truncate) {
@@ -176,12 +188,13 @@
     float frame = currTime/duration * numFrames;
     int lastFrame = static_cast<int>(frame);
 
-    if (interpolation == linear) {
+    if (interpolation == linear || interpolation == fixed) {
       //do interpolation in parallel
       int start = lastFrame;
-      int end   = (start+1) % (numFrames);
+      int end   = loop ? (start+1) % (numFrames) : min(start+1, numFrames-1);
       float t = frame - start;
 
+
       assert(frames[start+startFrame]->size() == 
frames[end+startFrame]->size());
       std::vector<keyframe_t> keyframes(2);
       keyframes[0].keyframe = frames[start+startFrame];
@@ -283,7 +296,7 @@
 
   time = wrapTime(time);
 
-  if (interpolation == linear)
+  if (interpolation == linear || interpolation == fixed)
     return time != currTime;
 
   if (interpolation == truncate) {

Modified: trunk/Model/MiscObjects/KeyFrameAnimation.h
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.h (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.h Wed Apr  8 17:17:56 2009
@@ -11,7 +11,7 @@
 
   class KeyFrameAnimation : public Object{
   public:
-    enum InterpolationMode{truncate, linear};
+    enum InterpolationMode{truncate, linear, fixed};
 
     KeyFrameAnimation(InterpolationMode interpolation=truncate);
     ~KeyFrameAnimation();

Modified: trunk/scenes/triangleSceneViewer.cc
==============================================================================
--- trunk/scenes/triangleSceneViewer.cc (original)
+++ trunk/scenes/triangleSceneViewer.cc Wed Apr  8 17:17:56 2009
@@ -99,6 +99,8 @@
        << "                       not already contain vertex normals.\n";
   cerr << " -useFaceNormals     - force to use only face normals\n";
   cerr << " -smoothAnimation    - interpolates between keyframes.\n";
+  cerr << " -fixedAnimation     - interpolates between fixed steps over 
-animationLength frames.\n";
+  cerr << " -noloop             - do not loop after an animation cycle.\n";
   cerr << " -triangleType       - Triangle implementation to use.\n"
        << "                       Wald_tri, KS_tri.\n";
   cerr << " -overrideMatl       - Force to use a material.\n"
@@ -325,6 +327,8 @@
   bool interpolateNormals = false;
   bool useFaceNormals = false;
   bool smoothAnimation = false;
+  bool fixedAnimation = false;
+  bool noLoop = false;
   float animationLength = 5; //in seconds
   Material* overrideMatl = 0;
   Material* defaultMatl  = 0;
@@ -381,6 +385,10 @@
       useFaceNormals = true;
     } else if (arg == "-smoothAnimation") {
       smoothAnimation = true;
+    } else if (arg == "-fixedAnimation") {
+      fixedAnimation = true;
+    } else if (arg == "-noLoop") {
+      noLoop = true;
     } else if (arg == "-triangleType") {
       string triangleName;
       if (!getStringArg(i, args, triangleName))
@@ -428,16 +436,16 @@
     fileNames.clear();
     //read in data from modelName and
     ifstream in(modelName.c_str());
-    while (in.good()) {
-      in >> modelName;
+    while (in >> modelName)
       fileNames.push_back(modelName);
-    }
   }
 
   if (fileNames.size() > 1) {
     KeyFrameAnimation *animation = new KeyFrameAnimation();
     if (smoothAnimation)
       animation->setInterpolation(KeyFrameAnimation::linear);
+    if (fixedAnimation)
+      animation->setInterpolation(KeyFrameAnimation::fixed);
 
     group->add(animation);
     animation->useAccelerationStructure(as);
@@ -451,6 +459,7 @@
     }
 
     animation->setDuration(animationLength);
+    animation->loopAnimation(!noLoop);
     animation->startAnimation();
   } else {
     // If we're just a single mesh, load it directly instead of using


  • [Manta] r2399 - in trunk: Model/MiscObjects scenes, Andrew Kensler, 04/08/2009

Archive powered by MHonArc 2.6.16.

Top of page