Virtual Reality over the Internet 2001

97
Virtual Reality Virtual Reality over the Internet over the Internet 2001 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

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

Page 1: 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

Page 2: Virtual Reality  over the Internet  2001

Introduction Introduction - - Presented by MarthaPresented by Martha

Page 3: Virtual Reality  over the Internet  2001

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

Page 4: Virtual Reality  over the Internet  2001

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

Page 5: Virtual Reality  over the Internet  2001

Introduction Introduction – Division of Labor

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

Page 6: Virtual Reality  over the Internet  2001

Introduction Introduction – Presentation Outline

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

Page 7: Virtual Reality  over the Internet  2001

Architecture Architecture - - Presented by MarthaPresented by Martha

Page 8: Virtual Reality  over the Internet  2001

ArchitectureArchitectureUserUser

Game EngineGame Engine

Game Display EngineGame Display Engine

ParserParser

Sound & AnimationSound & Animation

ServerServer

Communication EngineCommunication Engine

GUIGUI

Page 9: Virtual Reality  over the Internet  2001

Modeling Modeling - Presented by - Presented by SunSun

Page 10: Virtual Reality  over the Internet  2001

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

Page 11: Virtual Reality  over the Internet  2001

Modeling Modeling - Tool- Tool

Discreet 3D Max Studio 4.2 (the newest version)

Why? common Better for a beginner to learn

Page 12: Virtual Reality  over the Internet  2001

Modeling Modeling – Animal models– Animal models

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

Elephant

Page 13: Virtual Reality  over the Internet  2001

Modeling Modeling – Animal Models– Animal Models

Lion, tiger, panther, fox

Dog, cat and mouse

Page 14: Virtual Reality  over the Internet  2001

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

Page 15: Virtual Reality  over the Internet  2001

Modeling Modeling – Scene Objects– Scene Objects

Combining all the scene objects:

Page 16: Virtual Reality  over the Internet  2001

Modeling Modeling – Scene Objects– Scene Objects

Combining the scene with the animal models

Page 17: Virtual Reality  over the Internet  2001

Modeling Modeling – weapon models– weapon models

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

Page 18: Virtual Reality  over the Internet  2001

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

Page 19: Virtual Reality  over the Internet  2001

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.

Page 20: Virtual Reality  over the Internet  2001

Modeling Modeling - Technique- Technique

First version Second version

Page 21: Virtual Reality  over the Internet  2001

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

Page 22: Virtual Reality  over the Internet  2001

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.

Page 23: Virtual Reality  over the Internet  2001

Parser Parser - Presented by Siu- Presented by Siu

Page 24: Virtual Reality  over the Internet  2001

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

Page 25: Virtual Reality  over the Internet  2001

Parser Parser – Role of parser

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

Bridge between 3D models and OPENGL rendering process

Page 26: Virtual Reality  over the Internet  2001

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

Page 27: Virtual Reality  over the Internet  2001

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

properties Based on VRML 2.0 hierarchical structure Create an object tree

Page 28: Virtual Reality  over the Internet  2001

Parser Parser – Structure component

Main Component: SceneGraph Class

IO manipulation Whole output data structure

Node Class Root Node Children Node Non-children Node etc

Page 29: Virtual Reality  over the Internet  2001

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

Page 30: Virtual Reality  over the Internet  2001

Parser Parser – Example

Root Node DEF Node

Children Node Shape Node

Non-children Node Material Node Appearance Node Geometry Node

Page 31: Virtual Reality  over the Internet  2001

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

Page 32: Virtual Reality  over the Internet  2001

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

Page 33: Virtual Reality  over the Internet  2001

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

Page 34: Virtual Reality  over the Internet  2001

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

Page 35: Virtual Reality  over the Internet  2001

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

Page 36: Virtual Reality  over the Internet  2001

Game Engine Game Engine - - Presented by JimmyPresented by Jimmy

Page 37: Virtual Reality  over the Internet  2001

Game Engine Game Engine - Outline- Outline

Components

Scene Rendering

Game Flow

Event Handling

Improvements

Page 38: Virtual Reality  over the Internet  2001

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

Page 39: Virtual Reality  over the Internet  2001

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

- Location

- Transformation

- Power attributes (for characters only)

Page 40: Virtual Reality  over the Internet  2001

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

CObjectCObject

BackgroundBackground

3D Object3D Object

CharactersCharacters

Page 41: Virtual Reality  over the Internet  2001

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

The Camera class contains:

- Eyes location of the user

- Targeting point

Page 42: Virtual Reality  over the Internet  2001

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

A player class contains:

- The “animals” remaining in the “forest”

- Win/Lose

Page 43: Virtual Reality  over the Internet  2001

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

Contains a list of 3D objects

Page 44: Virtual Reality  over the Internet  2001

Components Components - Game Display En- Game Display Enginegine

Initialize the OpenGL context for drawing

Initialize the lighting of the scene

Define the viewport

Page 45: Virtual Reality  over the Internet  2001

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

Page 46: Virtual Reality  over the Internet  2001

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….

Page 47: Virtual Reality  over the Internet  2001

Game FlowGame FlowProgram startProgram start

Connect to serverConnect to server

Game startGame start

Server SettingServer Setting

Game endGame endQuit gameQuit game

Page 48: Virtual Reality  over the Internet  2001

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

Page 49: Virtual Reality  over the Internet  2001

ImprovementsImprovementsTexture mapping of the background objects

Shorten the time to initialize the program

Smooth moving when user changing the view point

Page 50: Virtual Reality  over the Internet  2001

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

MarthaMartha

Page 51: Virtual Reality  over the Internet  2001

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

Page 52: Virtual Reality  over the Internet  2001

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

Page 53: Virtual Reality  over the Internet  2001

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

Page 54: Virtual Reality  over the Internet  2001

Graphical User Graphical User InterfaceInterface

- Presented by - Presented by MarthaMartha

Page 55: Virtual Reality  over the Internet  2001

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

Page 56: Virtual Reality  over the Internet  2001

Graphical User Graphical User Interface Interface – Components

Components of GUI:

Game Stage Interface Interface Objects Textures Interface Event Handler

Page 57: Virtual Reality  over the Internet  2001

Graphical User Graphical User InterfaceInterface – Game Stage Interface

2 Game Stages:

Pre-game stage In-game stage

Page 58: Virtual Reality  over the Internet  2001

Graphical User Graphical User InterfaceInterface – Pre-game stage

Main menu

Logo of the game

Join Watch

settingExit

background

Page 59: Virtual Reality  over the Internet  2001

Graphical User Graphical User InterfaceInterface – Pre-game stage

Setting

Server Options

Connect

background

Back

Page 60: Virtual Reality  over the Internet  2001

Graphical User Graphical User InterfaceInterface – In-game stage

In-game stage:

MessageDialog

background

Scene of Game

Page 61: Virtual Reality  over the Internet  2001

Graphical User Graphical User Interface Interface – Interface Objects

Hierarchy of Interface Objects:

Static object Control object Panel

Page 62: Virtual Reality  over the Internet  2001

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”

Page 63: Virtual Reality  over the Internet  2001

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

Page 64: Virtual Reality  over the Internet  2001

Graphical User Graphical User Interface Interface – Panel

Panel:

Container for storing all related interface objects Reasons:

Easier for handling More structural

Page 65: Virtual Reality  over the Internet  2001

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

Page 66: Virtual Reality  over the Internet  2001

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

Page 67: Virtual Reality  over the Internet  2001

Sound & Sound & AnimationAnimation

- Presented by - Presented by SunSun

Page 68: Virtual Reality  over the Internet  2001

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

Page 69: Virtual Reality  over the Internet  2001

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.

Page 70: Virtual Reality  over the Internet  2001

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.

Page 71: Virtual Reality  over the Internet  2001

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

Page 72: Virtual Reality  over the Internet  2001

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.

Page 73: Virtual Reality  over the Internet  2001

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

Page 74: Virtual Reality  over the Internet  2001

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

Page 75: Virtual Reality  over the Internet  2001

Communication EngiCommunication Engine ne

- Presented by Siu- Presented by Siu

Page 76: Virtual Reality  over the Internet  2001

Communication Communication Engine Engine – Reason for networking

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

Page 77: Virtual Reality  over the Internet  2001

Communication Engine Communication Engine – Role

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

Page 78: Virtual Reality  over the Internet  2001

Communication Engine Communication Engine – Architecture Design

2-tiers levelOne server to many clients

ServerServer

ClientClient ClientClient ClientClient ClientClient

Data

Page 79: Virtual Reality  over the Internet  2001

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

Page 80: Virtual Reality  over the Internet  2001

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

Page 81: Virtual Reality  over the Internet  2001

Communication Engine Communication Engine – Initial connection

WatcherWatcher ServerServer

Launch the gameLaunch the game

Connection request

Connection respond

AcceptedRejected

Page 82: Virtual Reality  over the Internet  2001

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

Page 83: Virtual Reality  over the Internet  2001

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

Page 84: Virtual Reality  over the Internet  2001

Communication Engine Communication Engine – Flow of the game processing

PlayerPlayer ServerServer

Move State

Opponent Move State

PlayerPlayer WatcherWatcher WatcherWatcher WatcherWatcher

Move State

Page 85: Virtual Reality  over the Internet  2001

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)

Page 86: Virtual Reality  over the Internet  2001

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

Page 87: Virtual Reality  over the Internet  2001

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

Page 88: Virtual Reality  over the Internet  2001

Communication Engine Communication Engine – Implementation

Visual C++ project integrationWindows Socket 2

Common and popular choice

TCP/IP protocolThe Internet Standard

Page 89: Virtual Reality  over the Internet  2001

Game Logic Game Logic - - Presented by JimmyPresented by Jimmy

Page 90: Virtual Reality  over the Internet  2001

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

Page 91: Virtual Reality  over the Internet  2001

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

Page 92: Virtual Reality  over the Internet  2001

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

Page 93: Virtual Reality  over the Internet  2001

Conclusion & Conclusion & ScheduleSchedule

- Presented by - Presented by JimmyJimmy

Page 94: Virtual Reality  over the Internet  2001

Conclusion & Schedule Conclusion & Schedule - Conclusion

Page 95: Virtual Reality  over the Internet  2001

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

Page 96: Virtual Reality  over the Internet  2001

DemonstrationDemonstration

Page 97: Virtual Reality  over the Internet  2001

Question & Question & AnswerAnswer