Object Oriented Design
Goals Feedback homework 8 Top Down Design: analyzing the requirements Bottom Up Design: refactoring fundamental OpenGL functionality
The makings of the glutplane Assumption: runtime environment is set up u Windows: GL4Java*.dlls installed u Mac: GL4Java*.zips installed in MRJClasses Find file “glutplane.java” and “glutplane.html” Install compile/link time environment u Windows: add GL4Java.jar to classpath u Mac: add GL4Java*.zips to project
Tools Basic level tools u Javac (part of Sun’s JDK) u Jikes: IDEs u Jbuilder (Windows, OS X) u CodeWarrior (Windows, OS X, OS 9, …)
Modify source Edit “glutplane.java” Replace 3 calls to add_plane(); with 20 calls u Hint: use a “for” loop instead of typing add_plane(); 20 times! Compile/run/test Upload binary files (.class) and.html file to Web server u glutplane.class u glutplane$planeobj.class u glutplane$glutplaneCanvas.class Test applet on server URL referring to html file.
More information Provided by the Game Engine builders /contra/installation.html /contra/installation.html Chris Schenk: Luke Swanson:
Top Down Requirement Analysis Collect what the different applications/games need to have from the Game Engine Danger: u Getting carried away u Creating specification that cannot be implemented (in time, within budget, …)
Requirement for Game engine Camera aimed at character u Multiple cameras Shapes Aggregate shapes Rotation of shapes and camera Collision detection IIII Clipping Physics II u Particles Text Infinite backgrounds (repetitive textures, sky domes, …) Foreground/messages/score keeping
Camera Control Multiple cameras u Switching between cameras: no gui Camera tracking (stay on object) zoom Multiple views at the same time Independent control of camera
Shapes Box, sphere, circle, rectangle, plane, line, point, cylinder, triangle strip, Single / aggregate shapes Rotation Move in scene Add textures to shape Loading models u Load.obj files
Collision Detection iii Detect collision of shapes and groups of shapes Approximation with u spheres u Cubes
Clipping no
Physics Particles Airplanes, skis, bikes Simple gravity (would be nice)
Text no
Backgrounds Flat but repetitive Sky domes, Sky boxes
Information panels Score keeper Output message Dialogs (hard) u Use OpenGL, Swing or AWT? Menus (hard) u Use OpenGL, Swing or AWT?
Bottom Up system design Refactor existing functionality (the OpenGL mega blob) into service classes Approach: look at instances of applications containing functionality that could be factored out of the application into a the middle ware layer => the Game Engine Danger: u Feature oriented: contrast between cool and necessary functions
Refactoring textured square example Basic structure of OpenGL application is give by init, display, and reshape Look for code that, in generalized form could be pushed into game engine => collect these operations and attributes in a class called glWindow
INIT Collect a set of good initializations that make sense for most applications Turn most features ON (lighting, texture mode) In worst case application can overwrite or extend INIT
DISPLAY Refactor display method into u preDisplay: low level initializations that most applications would need anyway, e.g, clearing buffer. Translating, rotating individual objects u mainDisplay: leave this to application to specialize u postDisplay: Cleanup, error handling Buffer swapping (to implement double buffering)
Factor out utility functions Example: texture manager Replace complex implementations of texture loading with single calls of texture managing functions located in middle ware (game engine)
Produce new application with middleware stuff removed
Homework PROJECT: u Finish game proposal document u to Alex & Andri u Due: November 12 READING: u OpenGL Red book chapter 3; Viewing u u Due: November 12