|
MS Assistant
|
|||||||||
|
[ Abstract ]
[ Modeling the paper clip ]
[ Modeling a tube ] Killing the MS assistantAbstract
Modeling the paper clipI 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 tubeEach 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)|
B(t) = C't) x C''(t) / |C'(t) x C''(t)|
N(t) = B(t) x T(t)
Implementing the paper clip - BezierTube and BezierMetaTubeThe 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.
Modeling expressions of the eyes
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 productThe GuidePointThe 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 techniquesWith 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 renderingBecause 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:
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 ); Further improvementsThere 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:
References[Hill1990] - Computer Graphics Using Open GL, F.S. Hill, Jr. |