GameSpawn Site Map
Advertisement
GameSpawn Update mailing list
Advertisement

Lee's Lessons

Interpolators! Part 1

2000-05-25

Oh No! This is a lot for one day! Its been another one of those days when I'm fighting with the code! Grrr! Too many exclamation points! Anyway, I read a BUNCH yesterday on Interpolators and Animation and thought it was way too thin yesterday to just leave it alone and go onto RMI so I've decided to continue my look into Interpolators. You can think of this topic as Behaviors->Interpolators and specifically the 5 main Interpolators which are Scale, Position, Transparency, Color, and Rotation. We got a brief look at RotationInterpolator yesterday and it hasn't changed much today because today is just an overview of the main Interpolators. I'll go into each one in more depth tomorrow. I thought this was going to be rather trivial but even getting the most basic of Interpolators up for Transparency and Color has proven to be quite a daunting task. In summary, today is a brief rundown on the 5 main Interpolators.

Considering all the new Interpolators I'm writing I include them in a new package:

package com.gamespawn.lab.mikelee.j3d.examples.interpolators;

The code may not be documented the best and the variables may be off. I'm under a time constraint today and had a lot of problems with this so please bear with some of the ugly code. This should not be a habit. There was just a lot of stuff to cover today and a lot of problems.

I.e.:

// Color3f green = new Color3f(0.0f, 1.0f, 0.0f);

// Color3f white = new Color3f(1.0f, 1.0f, 1.0f);

// app.setMaterial(new Material(white, green, white, green, 1.0f));

This example is because of the Transparency and Color junk! When I get those working I will fix all these here also.

I just thought of something. I wonder if you can share these behaviors between TransformGroups or visual objects. That should cut down massively on CPU time so I'll have to look into this.

RotationInterpolator

Pretty much the same as yesterday. The key line of code is the same as yesterday:

RotationInterpolator rotation = new RotationInterpolator(rotationTime, objTrans);


This is the most basic constructor that rotates the passed transform group, objTrans, around the Y axis for a given time of rotationTime.

PositionInterpolator

This moves the appropriate objects around. Pretty simple. Performs a translation basically. The important code here is:

PositionInterpolator position = new PositionInterpolator(time, objTrans);

This is the most basic constructor also. It just moves the transform group objects positively along the X axis. It takes time to move the transform group from its initial spot to its final spot.

ScaleInterpolator

This, like the others, pretty much does what it says! It interpolates between differing scales. Anyone who has ever taken a 3D graphics class understands that this finishes out, pretty much, the 3 main geometry manipulations. These are scaling, translation, and rotation. You can use these 3 together for some pretty impressive results I'm sure. I will try these together one day. That is beyond the scope of today's lesson. The important code for the ScaleInterpolator is:

ScaleInterpolator scale = new ScaleInterpolator(time, objTrans);

Constructor looks familiar eh? It does the same thing. It Scales the objects in the passed transform group, objTrans, from 0.1f to 1.0f.

ColorInterpolator and TransparencyInterpolator

I'm going to have to continue this tommorrow. I'm having a helluva time trying to get even the most basic of these to work! I'm thinking the problem must be the same between them.
Advertisement
Michael C. Lee, Jr.
Advertisement
About
Account
Arcade
Help
Library