Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Design. Goals  Bottom Up Design: refactoring fundamental OpenGL functionality  Game Engine 1.0 introduction.

Similar presentations


Presentation on theme: "Object Oriented Design. Goals  Bottom Up Design: refactoring fundamental OpenGL functionality  Game Engine 1.0 introduction."— Presentation transcript:

1 Object Oriented Design

2 Goals  Bottom Up Design: refactoring fundamental OpenGL functionality  Game Engine 1.0 introduction

3 Top Down Requirement Analysis (repeat)  Collect what the different applications/games need to have from the Game Engine  Danger: u Getting carried away: create laundry list of features u Creating specification that cannot be implemented (in time, within budget, …)

4 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

5 General Architecture OpenGL ® Game Contra application middle ware API hardware

6 Refactoring textured square example  Basic structure of OpenGL application is given by init, display, and reshape  Look for code that, in generalized form can be moved from application into middleware layer  => collect these operations and attributes in a class called glWindow

7 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

8 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)

9 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)  => useTexture (“image.png”) u Load texture file if necessary (implement cache)  Assume file is contained in data/ folder relative to codeBase() u Bind texture u Manage name space

10 Produce new application with middleware stuff removed

11 Fat free application package contra; import gl4java.*; import gl4java.utils.textures.*; import java.io.*; public class textureGLWindow extends GLWindowApplet { public void mainDisplay() { useTexture ("borg2.png"); gl.glBegin(GL_POLYGON); gl.glTexCoord2f( 1f, 1f); gl.glVertex3f( 1f, 1f, 0f); gl.glTexCoord2f( 1f, -1f); gl.glVertex3f( 1f, -1f, 0f); gl.glTexCoord2f(-1f, -1f); gl.glVertex3f(-1f, -1f, 0f); gl.glTexCoord2f(-1f, 1f); gl.glVertex3f(-1f, 1f, 0f); gl.glEnd(); }

12 About texture files  Size: 2 n x 2 m u Size cannot be arbitrary u Example  valid: 64 x 512  invalid: 150 x 248  File type u Support only.png u 24 bit: RGB u 32 bit RGBA includes 8 bit transparency

13 Game engine 1.0  GLWindow u Contains scene u Manages resources, e.g. textures  Camera u Control camera parameters  Agent u Scene content

14 ContraCanvas Agents: List of Agent Textures: Hashtable of Name  Id Camera: Camera init() display() useTexture(Name: String) reshape(Height: Integer, Width: Integer)

15 Camera For details see Red Book chapter 3 Camera View: GLWindow eye-x, eye-y, eye-z: Float center-x, center-y, center-z: Float up-x, up-y, up-z: Float Fovy: Float Aspect: Float Near: Float Far: Float aimCamera(eye-x, eye-y, eye-z, center-x, center-y, center-z, up-x, up-y, up-z, Fovy, Aspect, Near, Far: Float)

16 Agent View: GLWindow Name: String x, y, z: Float x-turn, y-turn, z-turn: Float Roll, Pitch, Heading: Float Agents: List of Agent Display()

17 Euler Angles head roll pitch

18 Relative coordinate systems  Example: art dummy  With nested objects/agents coordinate systems should be relative  Rotations need to be nested as well

19 Homework  PROJECT: u Make one object  Use Game engine code:  Each team member could make different object part of final project  Apply Textures u TEST applet (local and over network) u Email URL to Alex & Andri u Due: November 19  READING: u OpenGL Red book chapter 9: Texture Mapping u http://fly.cc.fer.hr/~unreal/theredbook/ http://fly.cc.fer.hr/~unreal/theredbook/ u Due: November 19


Download ppt "Object Oriented Design. Goals  Bottom Up Design: refactoring fundamental OpenGL functionality  Game Engine 1.0 introduction."

Similar presentations


Ads by Google