Sign Håvard Rast Blok

MS Assistant

Abstract ] [ Modeling the paper clip ] [ Modeling a tube ]
Implementing the paper clip - BezierTube and BezierMetaTube ]
Modeling expressions of the eyes ] [ Animation and final product ]
Further improvements ]

Killing the MS assistant

Abstract


This is my first assignment in the computer graphics course at Høgskolen i Østfold. I've set out to torture the MS paper clip assistant for a while and finally kill it. :) The hole animation will be programmed using Magician's implementation of OpenGL. I've identified the following sub tasks of the assignment:

  • Modeling of tubes to make up the paper clip
  • Modeling of expressions using only eyes and eyebrows
  • Animation of the paper clip being stretched and broken
  • Maybe texture to get a rusty paper clip (not included)
  • Maybe effects like blood, or even better: Windows API code flowing from the assistant. (not included)
This paper is intended to be a presentation of the project at my web page and a report for the final product. Please have this in mind while continuing further on.
 

Modeling the paper clip

I plan to model the paper clip using Bezier curves. The pictures below was made with Corel Draw and shows the six curves making up the clip. The right picture shows the control points of the Bezier curves. Each joint (or node) share control points for the start of the curve and the end of the curve. The joints are smooth (but not symmetrical), so the control points form collinear vectors but not of same length.

 
 
 
 

Modeling a tube

Each Bezier curve making up the clip would be modeled as a tube to illustrate the depth of the object. However it turned out to be a bug in the implemented algorithm drawing the tube and it was therefore not included in the delivered project. Hopefully, I will be able to correct this problem at a later stage, and present it at this web page. Still, I have included the an briefly explanation of the algorithm below.

The algorithm consists of two part reasoning by Hill. "Building Segmented Extrusions: Tubes and Snakes" and "Rotations about an Arbitrary Axis" [Hill1990]. Hill states that a tube may be drawn by employing a sequence of extrusions along a curve, C(t). In may case C(t) describes a Bezier curve. For each value of t, a local coordinate system is found, a so called Frenet frame. This coordinate system retrieves it's axis from the tangent of the curve and it's perpendicular vectors.

Unit tangent vector (normalized derivative, C '(t) ):

T(t) = C't) / |C'(t)|


"Unit binormal" vector (normalized cross product of derivative and second derivative, C ''(t) ):

B(t) = C't) x C''(t) / |C'(t) x C''(t)|


Vector perpendicular to both T(t) and B(t) (normalized since both T(t) and B(t) are normalized)

N(t) = B(t) x T(t)


When a local coordinate system is obtained, polygons are drawn at a given distance along one of the perpendicular lines, T(t) or B(t), of the curve. This is repeated while rotating about the tangent of the curve. Special causing has to be made to join the polygons from neighboring Frenet frames.
 

Implementing the paper clip - BezierTube and BezierMetaTube

The class BezierTube would have contained the implementation of the algorithm above. At this stage, however, it only contains an implementation to draw a thick line along the Bezier curve. This was my backup plan for making the paper clip, and I had to go with that plan. When the problem of the tube is fixed, it easy to add some new, private methods of the BezierTube class. The only change in the classes using BezierTube needed, is switching a boolean value.

To implement the paper clip composed of six Bezier curves, I created the class BezierMetaTube. As it's name suggests, this class holds several BezierTubes. Changes to the meta tube, like line thickness, are passed on to the contained BezierTube objects. The BezierMetaTube also controls how the joints between the BezierTubes behaves. 
 
 
 
 
 
 
 

Both BezierTube and BezierMetaTube features a updating system to make the editing of control points convenient. The update system is turned off by default. At the BezierTube level updates follow these rules when the tube is "updateable". Control point 1 and 4 are the end points of the curve. Control point 2 and 3 are the seconds points of the derivative direction.

  • When control point 1 is moved, it's attached control point 2, is changed by the same vector.
  • Changes to control point 2 does not affect other control points.
  • Changes to control point 3 does not affect other control points.
  • When control point 4 is moved, it's attached control point 3, is changed by the same vector.
When several tubes are linked together, changes to the control points are supervised by the BezierMetaTube, which follow these rules.
  • When control point 1 or 4 are moved, changes are made to 2 or 3 as described above. Then the neighboring tube is notified of the change and it's control points 4 or 1 and 3 or 2 are changed equally.
  • When control points 2 or 3 are moved and the joint is cusp, no other points are affected.
  • When control points 2 or 3 are moved and the joint is smooth, control point 3 or 2 of the neighboring tube is moved in the opposite rotation around the joint. The length between point 3 and 4 or 2 and 1 of the neighboring curve is preserved.
  • When control points 2 or 3 are moved and the joint is symmetrical, control point 3 or 2 of the neighboring tube is moved in the opposite direction. The length between point 3 and 4 or 2 and 1 is the same on both sides of the joint.

Modeling expressions of the eyes


The images below are early tests in Corel Draw. The red eyes are drawn using customized, predefined textures in Corel Draw.
 

When modeling the eyes, I made the following assumptions: The pupils move symmetrical, as do the eyebrows. This makes it fairly simple to model one eyeball and eyebrow and mirror the eyebrow when the other eye is drawn. Eyebrows are modeled using the two BezierTubes contained in a BezierMetaTube. The eyeball is composed of two scaled spheres; one for the eyeball and one for the pupil. The PaperClipEye class implements this.

The eyeball and pupil as scaled spheres.

Animation and final product

The GuidePoint

The very general behavior of the objects discusses so far, proved indeed useful when creating the animation. However, I needed one more helping class to ease the movement of the objects; the GuidePoint. Usually, when you come up with a brilliant idea, it drags along a whole set of new problems to be solved. The conception of the GuidePoint was merely brilliant. :-)

The GuidePoint class extends Vec3f class of Magician and overrides all the methods that changes the values of the vector. To achieve this, I had to decompile the com.hermetica.vecmath.Vec3f class, remove the final keywords of each method and recompile my own version. Thus my project imports my own Vec3f, net.hblok.opengl.util.Vec3f class.

A GuidePoint class may have an unlimited number of connected Vec3f points which perform the same operation simultaneously with the GuidePoint. The implemented methods of the class pass on the operation to the super class and all the connected points. A GuidePoint may itself be added as a connected point, thus enabling  nested GuidePoints.

Download:  net.hblok.opengl.util.Vec3f - net.hblok.opengl.util.GuidePoint
 

Animation techniques

With all these helping classes and features, the animation now comes down to changing control points and GuidePoints. The coordinates of the control points for the eyebrows and paper clip I grabbed from my Corel Draw models and inserted as constants in the source code. The 14 scenes of the animation are show in the appendix of the report.

To ease the flow of the scenes, I reflected the 14 drawing as switch statements containing 14 case keywords. Each scene is made up of an initialization of movement parameters and the invocation of descriptive methods. For example: movePupils( PUPILS_FRONT, 0 );

When several points where to be moved linearly, I connected them using the GuidePoint. The pupils are examples of such similar movement. 
 
 
 

Final rendering

Because my application features no user interaction, I found it useful to grab screen shoots of each frame of the animation and build a standard movie from these images. This approach has several advantages: The CPU load of each frame is of no concern as there is no rush to grab the frames. The animation may be presented to people not familiar with OpenGL, Magician or Java. All you need is a media player. If desirable, sound, frame transitions and other effects may be added with animation software.

To make my final animation, I went through these steps:

  • Added the PPMWriter of Magician.

  • This was indeed simple. These two lines are that is need at the end of the display() method.
    gl.glFlush();
    PPMWriter ppm = new PPMWriter( glc );
  • The Portable PixelMap files were converted to JPEG images, as each image took up about 4 MB. This was done using Photo Shop Pro 7.0 from Jasc Software.
  • Now the final step was to import the JPEG images to Adobe Premiere, and save the animation to the desired format. To get this right, I had to be careful to adjust the frame and duration settings correctly. Each of the 153 screen shoot were set to last for 5 frames in the animation. The animation uses a rate of 30 frames per second. This results in 6 screen shoots being displayed a second which makes the length of the complete animation 25 seconds.

Further improvements

There is always room for improvements in such a project. If I were to continue the work in this one, I would add and improve some of these features:
  • Fix the tube problem to get a "real" paper clip
  • Fix a small bug in the eyebrow movements. Too few control points are described in these movements.
  • Take further advantage of my Java Interactive system to insert Java statements runtime. This could be used to easily load the values of the control points from file.
  • Use more screen shoots to get a smoother animation. Adobe Premiere could also be used to blend the transitions of each frame.
  • Add texture to the eyeballs and paper clip.
  • Add a back ground image. A Word session, of course. :)
  • Add sound to the final animation
  • Add gadgets like "The End" and "A Håvard Rast Blok production" :)

References

[Hill1990] - Computer Graphics Using Open GL, F.S. Hill, Jr.
 


site: Håvard Rast Blok
mail:
updated: 20 July 2006