Sign Håvard Rast Blok

Fighting Bots

Abstract ] [ Introduction ] [ Methods and solutions ]
Java classes ] [ Further improvements ] [ References ]

Fighting Bots

Abstract

This 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:

  • interpolating between postions to make human like movements
  • rendering of 3D fonts in Java
  • creating figures using several Bezier curves
  • hit detection on Open GL objects
  • different light sources and materials
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.

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 solutions

In 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 classes

Most 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.awt

EnvironmentSettings - Returns information about the graphics environment.
GenericMenuBar - Constructs a simple menu bar based on a String array

net.hblok.io

SimpleSequenceFileHandler - 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.fight

AnimationRenderingComponent - 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.msassistant

ClippyStandAlone - The MS assistant as a drawable Open GL component.
PaperClipEye - The eyes of the assistant.

net.hblok.opengl.shape

BezierMetaTube - 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.util

GuidePoint - 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 improvements

There are several improvements and fixes I'd want to do the this project:
  • Make a longer animation with more fighting moves
  • Use more color on the robots
  • Add some background to the fighting scene.
  • Draw a real Bezier tube for the paper clip
  • Look for possible improvements to the speed of the animations
  • Use another algorithm to render the fonts

References

[Hill1990] - Computer Graphics Using Open GL, F.S. Hill, Jr.
[Teigen1992] - Frihåndstegning, Tom Teigen
 


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