Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] interpolating between objects


Chronological Thread 
  • From: Thiago Ize <thiago@cs.utah.edu>
  • To: manta@sci.utah.edu
  • Subject: [MANTA] interpolating between objects
  • Date: Fri, 30 Mar 2007 20:00:24 -0600

I'm trying to add object interpolation so that it's possible to interpolate an animation between two (or more for fancier interpolation schemes) keyframes. The objects could be simple things like spheres and triangles, or large things like heightfields and meshes. I guess we would only be interpolating between the same Object types (i.e. always sphere/sphere, never between a sphere and a triangle). My problem is that there are a bunch of different ways to do this and I'm having a hard time coming up with the best method (I'm not a fan of software architecting...). Here are some ideas:

Assume we are interpolating spheres for now.

-Create an InterpolatingSphere class that derives from Primitive and contains an array or stl vector of Spheres (or Sphere pointers?), where each element corresponds to a keyframe. We can then either store a copy of a Sphere and compute and store the interpolated sphere center and radius once per frame (at the expense of write operations, and assuming we have a way to modify the sphere private data), or recompute those values each time they are needed by Intersect or ComputeBounds (but that would require modifying the Sphere's intersect and ComputeBounds functions to use the interpolated sphere data).

-Create an InterpolatingSphere class that derives from Sphere and contains an array/vector of Sphere keyframes. Then we have easy access to the sphere data (if it's private we would need to change it to protected) when we want to compute and store the interpolated values.

-Create interpolate functions in the Sphere class (or in a derived class of Sphere) that take the two keyframes (for linear interpolation) and the t value and updates it's sphere data to the interpolated value. This is probably the easiest to implement, but doesn't allow for on the fly recomputing of the interpolated values whenever it's needed.

These classes would be stored inside of an AnimationGroup class that figures out what the current time and frame are and gets called at the start of each frame and updates it's list of objects (which is stored in a Group). Or, we could have each object store a ptr to an Animation class that contains the current time and frame, but wouldn't be able to signal each object to update itself, which is fine if we are always recomputing on the fly.

If we go the derived class route, should we create some sort of animation/interpolation interface that they should also derive from so that there is a guaranteed common function prototype?

We don't want to have to reallocate memory each time we do an interpolation (imagine interpolating a 1M triangle mesh 30 times a second), so we must have an object that gets reused, rather than creating a new object each time. This though can be a problem since getting that reusable object is rather hard. The user will just supply a bunch of Objects that correspond to each frame. Some of the Objects might be spheres, others meshes, and some heightfields. We can't modify these objects since they are the keyframes, so we would need to make our own. One way to do this would be to have each class implement a "clone"function that returns a copy of itself, but maybe there are better ways? The other option is to force the user to supply a copy of each object, but this puts extra work on the user...

Finally, how about handling nearest neighbor interpolation? In this case we don't need to actually do any work and can skip the copying of values if we just render the actual keyframe. An architecture that allows this would be nice, especially since it lets us have something like an animation with only one keyframe (static scene) without any performance loss compared to the traditional static scene.

Thiago





Archive powered by MHonArc 2.6.16.

Top of page