Virtual Reality over the Internet 2001

Post on 05-Jan-2016

15 views 0 download

description

Virtual Reality over the Internet 2001. Supervisor: Dr. Wenping Wang Second Examiner: Dr. C.L. Wang Group members: Chan Hing Sun, Sun Hui Pui Fan, Martha Siu Chi Man, Siu Wong Wai Kwan, Jimmy. Introduction - Presented by Martha. Introduction – Objectives. - PowerPoint PPT Presentation

Transcript of Virtual Reality over the Internet 2001

Virtual RealityVirtual Reality over over the Internet the Internet 20012001

Supervisor: Dr. Wenping Wang Second Examiner: Dr. C.L. Wang Group members: Chan Hing Sun, Sun

Hui Pui Fan, Martha

Siu Chi Man, Siu

Wong Wai Kwan, Jimmy

Introduction Introduction - - Presented by MarthaPresented by Martha

Introduction Introduction – Objectives

Objectives of the project:

Implement a 3D Chess Game over the Internet Learn how to design, develop & deliver a system Learn about 3D graphics & knowledge required for project

Fundamental requirements:

3D Studio Max MFC OpenGL

Introduction Introduction – The Game

Title of the Game:

King of the Forest Game Environment:

Forest, River, etc

Main Characters: 8 kinds of animals in the forest Elephant, Lion, Tiger, Fox, Dog, Cat, etc

Introduction Introduction – Division of Labor

Modeling: Sun & Martha Parser: Siu OpenGL Display: Jimmy GUI: Martha & Jimmy Sound & Animation: Sun Commun Engine: Sun & Siu

Introduction Introduction – Presentation Outline

Architecture Modeling Parser OpenGL Display Progress Evaluation & Planning Graphical User Interface Sound & Animation Communication Engine Game Logic

Architecture Architecture - - Presented by MarthaPresented by Martha

ArchitectureArchitectureUserUser

Game EngineGame Engine

Game Display EngineGame Display Engine

ParserParser

Sound & AnimationSound & Animation

ServerServer

Communication EngineCommunication Engine

GUIGUI

Modeling Modeling - Presented by - Presented by SunSun

Modeling Modeling - Introduction- Introduction

Modeling is the part to make the 3D models for the game

3 types of model: 3D animal models in the game The environment of the forest The weapon model

Modeling Modeling - Tool- Tool

Discreet 3D Max Studio 4.2 (the newest version)

Why? common Better for a beginner to learn

Modeling Modeling – Animal models– Animal models

Simulating a real game Keep the original animals of the game Totally 8 animals

Elephant

Modeling Modeling – Animal Models– Animal Models

Lion, tiger, panther, fox

Dog, cat and mouse

Modeling Modeling – Scene Objects– Scene Objects

Create a scene similar to the board Many components that found in the forest

tree, mushroom

Bridge and hole

Modeling Modeling – Scene Objects– Scene Objects

Combining all the scene objects:

Modeling Modeling – Scene Objects– Scene Objects

Combining the scene with the animal models

Modeling Modeling – weapon models– weapon models

Create 5 different weapons stick, sword, gun, knife and hammer

Modeling Modeling - Technique- Technique

create a model, consider 2 things its funny and interesting simplicity

Funny increase user’s interest

Simplicity complexity of each model would relate to the game

speed due to the readability of the Parser

Modeling Modeling - Technique- Technique

Created two versions of the models First version

The speed for loading into Parser is quite long

Second version exists commonality between each model their bodies, hands and legs are the same and the

objects are primitive increase the speed for readability

of the parser.

Modeling Modeling - Technique- Technique

First version Second version

Modeling Modeling - Integration- Integration

The parser need to read in the file in vrml format

Export each object from 3d max (.max) to vrml file (.wrl).

Modeling Modeling – Improvement & – Improvement &

difficultiesdifficulties

Efficiency of the parser to read each object is still long for second version of model.

Improve the quality of the model still finding the commonality for each model Modifying export format for each 3d max model redrawing the model with some better primitive objects.

Parser Parser - Presented by Siu- Presented by Siu

Parser Parser – Reason for using parser

Why should we use the parser? Difficult to render attractive 3D models Efficient way to break down models Easy to trace the nodes of the models

Parser Parser – Role of parser

Transformation of VRML file into C++ recognizable data format.

Bridge between 3D models and OPENGL rendering process

3D Studio3D Studio ParserParser

Object CollectC++ recognizable data format

Object CollectC++ recognizable data formatDisplay EngineDisplay Engine

DisplayDisplay

VRML files

Parser Parser – Flow of the rendering process

Parser objects

Parser Parser – Structure design Class which parses and stores VRML nodes and

properties Based on VRML 2.0 hierarchical structure Create an object tree

Parser Parser – Structure component

Main Component: SceneGraph Class

IO manipulation Whole output data structure

Node Class Root Node Children Node Non-children Node etc

Parser Parser – Structure hierarchy

Non-Children NodeNon-Children Node

SceneGraphSceneGraph

Root NodeRoot NodeRoot NodeRoot Node Grouping NodeGrouping Node

Grouping NodeGrouping Node Children NodeChildren Node

Grouping NodeGrouping Node

Children NodeChildren Node Non-Children NodeNon-Children Node

Parser Parser – Example

Root Node DEF Node

Children Node Shape Node

Non-children Node Material Node Appearance Node Geometry Node

Parser Parser – Implementation Approach Object-Oriented Approach

Ready to be used in several place High cohesion

Each node has its separate class to represent its properties

Low coupling Class is provided API to facilitate its function

Parser Parser – Implementation Classes written in C++ Integrate into Visual C++ 6.0 Project Tokenizer

Use of flex and bison functions in Unix Help analysis input and pattern matching

Parser Parser – Mechanism Read a VRML 2.0 file Tokenize the VRML file into token Store the data if the token is valid Drop the data if the token is invalid Output a C++ recognizable data structure

Parser Parser – Difficulties and limitation Suitable for parsing primitive objects Long Processing time when parsing lots of

complex objects High performance computer should be used

Parser Parser – Improvement Reduce VRML file size Using primitive objects Good design of game flow

Reuse parsed objects CPU processing is much faster than IO

processing Adding animation information in the object

data file

Game Engine Game Engine - - Presented by JimmyPresented by Jimmy

Game Engine Game Engine - Outline- Outline

Components

Scene Rendering

Game Flow

Event Handling

Improvements

Components Components - 3D Objects- 3D ObjectsInherits from CObject class in MFC

A class for all the 3D objects

- Characters

- Background Objects (e.g. ground, river, sky…)

Components Components - 3D Objects- 3D ObjectsAn 3D Object contains:

- Location

- Transformation

- Power attributes (for characters only)

Components Components - Hierarchy of 3D o- Hierarchy of 3D objectsbjects

CObjectCObject

BackgroundBackground

3D Object3D Object

CharactersCharacters

Components Components - Camera- CameraDefines the users’ point of view in the game

The Camera class contains:

- Eyes location of the user

- Targeting point

Components Components - Players- PlayersDefine a player status in the game

A player class contains:

- The “animals” remaining in the “forest”

- Win/Lose

Components Components - Scene- SceneModel a virtual reality environment (the game environment)

Contains a list of 3D objects

Components Components - Game Display En- Game Display Enginegine

Initialize the OpenGL context for drawing

Initialize the lighting of the scene

Define the viewport

Scene RenderingScene Rendering3D objects in the scene are stored in a list

Transformation is applied to the 3D objects

The game engine will call the object collection to render the 3D objects

Scene RenderingScene RenderingObject CollectionObject Collection

Object ListObject List

ObjectObject

Store all imported 3D objects

A list of objects to form a 3D objects

Primitive objects, e.g. sphere, box….

Game FlowGame FlowProgram startProgram start

Connect to serverConnect to server

Game startGame start

Server SettingServer Setting

Game endGame endQuit gameQuit game

Event HandlingEvent HandlingHandling user input event

Use arrows to move the view point

Use the left mouse click to select an animal (to move that animal)

User can trigger a dialog box to chat with the opponent

ImprovementsImprovementsTexture mapping of the background objects

Shorten the time to initialize the program

Smooth moving when user changing the view point

Progress & Progress & Planning Planning - Presented by - Presented by

MarthaMartha

Progress & Planning Progress & Planning – progress evaluation

Modeling including 8 animal characters, some weapons and some

scene objects 3D models being exported as VRML format

Parser successfully decompose VRML 3D model files into C++

recognizable data format

Progress & Planning Progress & Planning – progress evaluation

(Cont)Game Engine

Successfully import the 3D objects to the game engine and render them on the screen

Users can change the view point

Progress & Planning Progress & Planning – planning

Graphical User Interface Sound & Animation Communication Engine Game Logic

design and goals of each of these components the tools & techniques to be used its integration to other parts of the system

Graphical User Graphical User InterfaceInterface

- Presented by - Presented by MarthaMartha

Graphical User Graphical User Interface Interface – Why is it used?

Allow users interact with the game Make the whole system’s outlook become more fanta

stic Critical concern: achieve user-friendliness

requirement

Graphical User Graphical User Interface Interface – Components

Components of GUI:

Game Stage Interface Interface Objects Textures Interface Event Handler

Graphical User Graphical User InterfaceInterface – Game Stage Interface

2 Game Stages:

Pre-game stage In-game stage

Graphical User Graphical User InterfaceInterface – Pre-game stage

Main menu

Logo of the game

Join Watch

settingExit

background

Graphical User Graphical User InterfaceInterface – Pre-game stage

Setting

Server Options

Connect

background

Back

Graphical User Graphical User InterfaceInterface – In-game stage

In-game stage:

MessageDialog

background

Scene of Game

Graphical User Graphical User Interface Interface – Interface Objects

Hierarchy of Interface Objects:

Static object Control object Panel

Graphical User Graphical User Interface Interface – static object

Static Object:

No interaction with players Display information only E.g.: Logo of the game in “main menu interface”

Graphical User Graphical User Interface Interface – control object

Control Object: Have interaction with user Handling mouse & keyboard event is required Including:

Buttons (e.g. Connect, Exit, etc) Text field Pop up box

Graphical User Graphical User Interface Interface – Panel

Panel:

Container for storing all related interface objects Reasons:

Easier for handling More structural

Graphical User Graphical User InterfaceInterface – Texture

2 Approaches: Pre-game stage: use OpenGL

Texture mapping is used for those pre-stage interface objects

In-game stage: use MFC MFC standard control is used to draw the in-game stage

objects Map the interface bitmap onto the standard button

Graphical User Graphical User InterfaceInterface – Interface Event Handler

Pass user events from game engine to the stage interface In pre-game stage:

Mouse & keyboard events will be handled to drive actions (both drawing the interface & handling user request)

In in-game stage: Mouse & keyboard events will be handled by MFC event

handler

Sound & Sound & AnimationAnimation

- Presented by - Presented by SunSun

Sound & Animation Sound & Animation – sound

Sound, make our game more funny

Three methods to implement sound effect to our game:

PlaySound function provided by Microsoft Win32 API

The Media Control Interface (MCI library)

The DirectSound component of the DirectX SDK

Sound & Animation Sound & Animation - sound

PlaySound functionAdvantage of easy to use

DisadvantagesIt can only be used to play waveform audio.

The latency for PlaySound is large.

It does not have the capability for playing two or more wave audio files simultaneously.

Sound & Animation Sound & Animation - sound

Media Control InterfaceProvides a device-independent interface to multimedia devices and media files

Advantage:play various kind of sound easily

Disadvantage:cannot solve the problem of playing several sounds simultaneously.

Sound & Animation Sound & Animation - sound

The DirectSoundOne of the components of DirectX

Advantages:provides high CPU usage for mixing audio channels or no support for mixing audio channel

high latency between when a sound is requested to play and when it is delivered through the speakers

Disadvantages:impossible for playing sound

simply

Sound & Animation Sound & Animation - sound

Our game few to happen that sounds simultaneously

It is better for us to implement sound using MCI.

MCI can play various types of sound and it is easy to use.

Sound & Animation Sound & Animation – animation

Animation, make the game more interesting and attractive

Two approaches for animation implementation:

First,make an animate model by 3D studio max

export it as vrml file

using the parser to load this animation vrml file

draw it out by openGL

Sound & Animation Sound & Animation - animation

Second,use a timer to trigger the motion of the movable part of a model.E.g., the elephant walks forward

use parser to generate the object-list of the elephant. find the leg’s node in the object-list.at time 0, at position Eat time 1, translated to the position F.at time 2, translated to the position G.

Elephant will walk from E to G.

1 or 2?Depends on efficiency and probability

Communication EngiCommunication Engine ne

- Presented by Siu- Presented by Siu

Communication Communication Engine Engine – Reason for networking

Why needs Communication Engine?Multi-player online gameCommunication between clients and serverExchange data between players

Communication Engine Communication Engine – Role

Connections between clients; clients and serverSynchronize the data between clientsServe as middleman between players

Communication Engine Communication Engine – Architecture Design

2-tiers levelOne server to many clients

ServerServer

ClientClient ClientClient ClientClient ClientClient

Data

Communication Engine Communication Engine – Architecture Design

2 componentsClient side communication engine

Player module – play the game, chat with opponentGame watcher module – only watch the game

Server side communication engine

Communication Engine Communication Engine – Initial connection

Common features (player and watcher)

Connection to the serverSend a connect request to the serverGet responds for the statues from the serverStart the game if the client is acceptedPrompt clients an error message if the server reject the client

Communication Engine Communication Engine – Initial connection

WatcherWatcher ServerServer

Launch the gameLaunch the game

Connection request

Connection respond

AcceptedRejected

Communication Engine Communication Engine – Initial connection

Different featureAfter connection establishServer sends opponent’s IP to the client

Chat purpose

Server sends the game statue to watcher

Watcher launches in the middle of the game

Communication Engine Communication Engine – Flow of the game processing

One player sends the move to the serverServer forwards the move to the opponent and watchersWait to receive the opponent’s moveMove againOpponent side runs the same procedure

Communication Engine Communication Engine – Flow of the game processing

PlayerPlayer ServerServer

Move State

Opponent Move State

PlayerPlayer WatcherWatcher WatcherWatcher WatcherWatcher

Move State

Communication Engine Communication Engine – Chat Function

Only 2 players can talk to each otherAfter connection establishmentEach player receives opponent’s IPDirect connection for the chat function

AdvantageReduce server’s workloadShorten the communication link

DisadvantageDisclose player’s IP (security problem)

Communication Engine Communication Engine – Checking Disconnection

Server will be implemented a function for checking clients statue

Reasonable time interval to ping the clientAlive or disconnectedNotification to the other clients when one client is detected to be disconnected

Communication Engine Communication Engine – Implementation Approach

Object-OrientedMaking a class provided with API to facilitate its function call

High cohesionDifferent function proceeds with different part of connection

Communication Engine Communication Engine – Implementation

Visual C++ project integrationWindows Socket 2

Common and popular choice

TCP/IP protocolThe Internet Standard

Game Logic Game Logic - - Presented by JimmyPresented by Jimmy

Game Logic Game Logic - rules- rules

8 “animals” VS 8 “animals” in the game

Win condition

- kill all opponent’s “animals”

- capture one of the cave of the opponent

Game Logic Game Logic - rules- rulesAnimals are ranked, highest rank is elephant while mouse is the lowest rank one

Higher ranking animals can eat lower ranking animals (but mouse can eat elephant!!)

Game Logic Game Logic - approach- approachCheck the win condition after every move

Save the position on the play board of the animals (a 7 x 9 board)

Check for invalid move

Conclusion & Conclusion & ScheduleSchedule

- Presented by - Presented by JimmyJimmy

Conclusion & Schedule Conclusion & Schedule - Conclusion

Conclusion & Conclusion & Schedule Schedule - Schedule

Sound Engine: End of JanGUI: Mid of FebAnimation: Mid of FebGame Engine: End of FebComm. Engine: End of FebIntegration: Early of MarchTesting: Mid of March

DemonstrationDemonstration

Question & Question & AnswerAnswer