|
Fighting Bots
|
|
|
[ Abstract ]
[ Introduction ]
[ Methods and solutions ] Fighting BotsAbstractThis is my assignment in the computer graphics course at Høgskolen i Østfold. The project consists of several parts, the main part being an Open GL animation using Magician for Java by Arcane Technologies Ltd. The animation features two robots going into a fist fight and the Microsoft paper clip assistant being beaten up in the end.In this project I have used several techniques within Java and Open GL programming. The most important once are:
Introduction The inspiration
to make a fighting robot I got from the running on web page of the course.
It's beauty lies in it's simplicity. I spent several hours drawing sketches
of simple box men. I got more inspiration from fighting games. The chest
of my robot is indeed inspired by a drawing in Tom Teigen's "Frihåndstegning".
To make the animations necessary, I figured I needed some kind of tool to set the robot into the right positions. I therefore developed a stand-alone application to edit the body. The positions are saved to file and later used in the animation. Along the way I also got the idea to include text in the animation. Thus the 3D text editor was born. To easy the development of this rather large project, I have taken advantage of software reuse where I found it useful. I have used packages made by others and also some of my own classes from earlier projects. The most important external package besides Magician is the Bean Shell interpreter. During the implementation and debugging phases it allowed Java statements to be interpreted and executed runtime. In the final product it is still used as an easy way of loading data from file. To draw the paper clip from my first assignment, I've used most of the classes from that project. They were already implemented in a way which made them fairly easy to integrate with the robot animations. Methods and solutionsIn the early phase of the project I sent a lot of time drawing the robot body. I made several sketches and finally a 2D description of the chest in Corel Draw. The coordinates from these drawing were save to own made data files is now loaded by Bean Shell.The next steps consists of hours and hours of Java implementation. Rational Rose was used to design some of the classes, but I could have taken even more advantage of that tool in the early design phase. The most interesting part of the body animation is a rather small algorithm which finds the shortest way to rotate around an axis. For example, if one of the axis of an arm is rotated to 20 degrees and should be animated to 350 degrees, the axis should be rotated clock-wise. It sound rather simple, and indeed it is. The algorithm took some time to develop, though, but proved indeed successful in the end. Most of this work is done by the moveVec-method of the BodyAnimationEngine class. To render 3D text in Java I spent some time studying the java.awt.font package. Here lies most of the frame work to retrieve glyph information about fonts. The fonts are loaded from the underling OS into the Java VM. Through some object traversing it is possible to get the glyphs describes as lines, curves and Bezier curves. The rest of the job lies in the hands of Open GL. Java classesMost of the classes constructed were specific for this project, while some turned out to be more general classes which will come in handy for later Java and Open GL programming. Below they are all shortly described. The report also includes a class diagram showing most of them.net.hblok.awtEnvironmentSettings - Returns information about the graphics environment.GenericMenuBar - Constructs a simple menu bar based on a String array net.hblok.ioSimpleSequenceFileHandler - Read and writes Serializable objects.SunFileFilter - Extends javax.swing.filechooser.FileFilter and implements java.util.FileFilter to handle filtering of file names. net.hblok.opengl.fightAnimationRenderingComponent - Handles the rendering of the animation.Body - Draws a robot. BodyAnimationEngine - Handles movement of the robot. EditorRenderingComponent - Handles the rendering for the editor. Example3DFonts - Example application to show rendering of 3D fonts. FightingBotsAnimation - The main class for the animation. FightingBotsApp - The main and entry class for the project. FightingBotsEditor - The main class for the editor. LoadingSplashScreen - Splash screen shown when the application is loading data. PositionControler - JPanel used within the SequenceDialog. PositionInfo - Data holder class for a single position of the body. SequenceDialog - JDialog to control the positions of a complete movement. net.hblok.opengl.msassistantClippyStandAlone - The MS assistant as a drawable Open GL component.PaperClipEye - The eyes of the assistant. net.hblok.opengl.shapeBezierMetaTube - Meta curve composted of several BezierTubes.BezierTube - Draws a Bezier curve as a tube, fire frame tube or line. Fonts - Draws 3D letters using Java's own frame work to retrieve glyph information. net.hblok.opengl.utilGuidePoint - Performs the same operation simultaneously for several Vec3f points.Material - Sets Open GL material attributes. Created by Børre Stenseth, ported to Java by Hans Gunnar Hansen. Vec3f - Own implementation of com.hermetica.vecmath.Vec3f. Implements Serializable. Further improvementsThere are several improvements and fixes I'd want to do the this project:
References[Hill1990] - Computer Graphics Using Open GL, F.S. Hill, Jr.[Teigen1992] - Frihåndstegning, Tom Teigen |