The XVR project Rapid development of VR applications Franco - - PowerPoint PPT Presentation

the xvr project rapid development of vr applications
SMART_READER_LITE
LIVE PREVIEW

The XVR project Rapid development of VR applications Franco - - PowerPoint PPT Presentation

The XVR project Rapid development of VR applications Franco Tecchia PERCRO Scuola Superiore S.Anna (ex-UCL) Background / Recap 03/26/07 What is a state for a VR application? In theory: a collection of information about the


slide-1
SLIDE 1

The XVR project – Rapid development of VR applications

Franco Tecchia PERCRO Scuola Superiore S.Anna (ex-UCL)‏

slide-2
SLIDE 2

03/26/07

Background / Recap

slide-3
SLIDE 3

03/26/07 3

What is a “state” for a VR application?

3D 3D meshes meshes

  • In theory: a collection of information about the virtual world

In theory: a collection of information about the virtual world

  • In practice: a collection of data structures and variables

In practice: a collection of data structures and variables

VR World “state”

Positions Positions Orientations Orientations Forces Forces Speed Speed Accelerations Accelerations

slide-4
SLIDE 4

03/26/07 4

The state evolves over time…

Depends on the tasks performed! Depends on the tasks performed! The computer simulation makes the state evolving, The computer simulation makes the state evolving, advancing in a discrete sequence of steps advancing in a discrete sequence of steps Fundamental question Fundamental question: how frequently should the : how frequently should the state get updated? state get updated?

t0 t1 t2 t3

… …

slide-5
SLIDE 5

03/26/07 5

The simplest VR architecture: a single loop

One loop to manage everything: One loop to manage everything:

  • Graphic Rendering

Graphic Rendering

  • User Input

User Input

  • Animation

Animation

  • Collision detection

Collision detection

  • Physical simulation

Physical simulation

~ 60 Hz

Refresh rate is usually the upper bound Refresh rate is usually the upper bound Collision and physics can give troubles Collision and physics can give troubles

slide-6
SLIDE 6

03/26/07 6

But things are really not that simple

Trying to use a single loop to manage everything is bad Trying to use a single loop to manage everything is bad practice practice

  • Some activities need to be performed at different rates

Some activities need to be performed at different rates

  • Easy to get stuck. Adding features can be a nightmare

Easy to get stuck. Adding features can be a nightmare An overall idea of what could be involved helps making An overall idea of what could be involved helps making the right design choices the right design choices

slide-7
SLIDE 7

03/26/07 7

The visualisation loop

The state of a VR simulation need to be displayed (on a The state of a VR simulation need to be displayed (on a monitor, HMD, CAVE, etc)‏ monitor, HMD, CAVE, etc)‏

~ 60 Hz

Update frequency = monitor refresh Update frequency = monitor refresh rate is all we need, anything more rate is all we need, anything more would be wasted would be wasted

State(t)‏

slide-8
SLIDE 8

03/26/07 8

The Visualisation loop

Real Real-

  • time computer graphics: the mother of all the VR

time computer graphics: the mother of all the VR tasks! tasks!

  • VR applications and systems are very often built about the

VR applications and systems are very often built about the rendering framework. rendering framework.

  • Beware:

Beware: this can be very limiting in the long run! this can be very limiting in the long run!

Sutherland, Ivan E., 1968 "A Head-Mounted Three Dimensional Display"

slide-9
SLIDE 9

03/26/07 9

The collision detection loop

Checking if moving objects collide with each other Checking if moving objects collide with each other

Depends on

  • bjects speed

If collision checking rate is not “fast If collision checking rate is not “fast enough”, some collision could occur enough”, some collision could occur undetected undetected

State(t)‏

slide-10
SLIDE 10

03/26/07 10

Collision detection

It used to be a “big thing” in VR. It used to be a “big thing” in VR.

  • Algorithms are almost optimal

Algorithms are almost optimal – – very very mature research field mature research field

  • There is little point in collision detection

There is little point in collision detection without physic simulation without physic simulation

  • Revived a bit lately: GPU

Revived a bit lately: GPU-

  • based collision

based collision detection detection Same names: Same names:

  • RAPID

RAPID

  • I

I-

  • Collide

Collide

  • V

V-

  • Collide

Collide

  • OPCODE

OPCODE

  • QuickCD

QuickCD

slide-11
SLIDE 11

03/26/07 11

The physical simulation loop

Objects responds to physical laws and interact Objects responds to physical laws and interact

>= 100 Hz

Update frequency need to be at Update frequency need to be at least the same as display rate, but least the same as display rate, but stability issues often require much stability issues often require much higher speeds higher speeds

State(t)‏

slide-12
SLIDE 12

03/26/07 12

Real-time physics

Simulating the effects of objects interaction Simulating the effects of objects interaction

  • A proper VR world needs

A proper VR world needs physical laws physical laws

  • Objects should react to stimulus

Objects should react to stimulus (gravity, external forces, (gravity, external forces, collisions)‏ collisions)‏

  • • Improved realism

Improved realism

  • Using scripted behaviour

Using scripted behaviour becomes a daunting task when becomes a daunting task when scenario gets complex scenario gets complex

slide-13
SLIDE 13

03/26/07 13

Real-time physics in practice (I)‏

  • A world is a collection of bodies
  • Bodies from different worlds never interact
  • Each rigid body has:
  • a mass (and moment of inertia)‏

needed for motion calculation

  • btainable by composing elementary solids
  • a shape or “geometry”

needed for collision detection

  • btainable by composing elementary solids

Note: Note: we are considering rigid we are considering rigid-

  • bodies physics

bodies physics

slide-14
SLIDE 14

03/26/07 14

Real-time physics in practice (II)‏

  • Physics materials are used to describe surface properties
  • f objects

var material = sim.getMaterial(idx); material.restitution = 0.1; material.staticFriction = 0.8; material.dynamicFriction = 0.5; material.apply();

slide-15
SLIDE 15

03/26/07 15

Real-time physics in practice (III)‏

  • • Simple objects are connected

Simple objects are connected using a collection of physical using a collection of physical joints joints

  • Many types of joints are

Many types of joints are available available

  • Sometimes joints can be

Sometimes joints can be broken broken

slide-16
SLIDE 16

03/26/07 16

Real-time physics in practice (IV)‏

The physics loop: The physics loop: 1) 1) Apply all the external forces to the objects Apply all the external forces to the objects 2) 2) Ask the Physics engine to compute the evolution of Ask the Physics engine to compute the evolution of the scene during a certain time interval the scene during a certain time interval 3) 3) Get the results back Get the results back

  • Update the scene

Update the scene-

  • graph

graph

  • Control some external device

Control some external device

1 2 3

Warning: Warning: This must be frequent to avoid instability (>=60Hz)‏ This must be frequent to avoid instability (>=60Hz)‏

slide-17
SLIDE 17

03/26/07 17

Haptics

Making the user touch the virtual world Making the user touch the virtual world

slide-18
SLIDE 18

03/26/07 18

The haptic interaction loop

Haptic interaction: the user interact with the environment Haptic interaction: the user interact with the environment and experience force feedback and experience force feedback

>500 Hz

Haptic refresh rate is much higher Haptic refresh rate is much higher that graphics refresh rate! that graphics refresh rate!

State(t)‏

slide-19
SLIDE 19

03/26/07 19

Haptics

Very simple development paradigm: Very simple development paradigm:

1 2 3

The problem is doing this at >=500 Hz! The problem is doing this at >=500 Hz! 1) 1) Read the haptic current position Read the haptic current position 2) 2) Depending on the position compute a force Depending on the position compute a force 3) 3) Ask the haptic to generate that force Ask the haptic to generate that force Position Position (x,y,z)‏(x,y,z)‏ Force Force (fx,fy,fz)‏(fx,fy,fz)‏

slide-20
SLIDE 20

03/26/07 20

The network communication loop

“ “No man is an island”: communication between remote No man is an island”: communication between remote VR nodes can be very important VR nodes can be very important Update frequency depends on the Update frequency depends on the type of communication: graphical type of communication: graphical

  • nly, interaction, with haptics or not,
  • nly, interaction, with haptics or not,

etc… etc…

State(t)‏

Depends on the task

slide-21
SLIDE 21

03/26/07 21

Conclusions: loops are everywhere! ~ 60 Hz 100-200 Hz >1kHz ~10Hz ~30Hz

slide-22
SLIDE 22

03/26/07 22

Events: not everything is a loop ~30Hz

VR_EVENT_1 VR_EVENT_1 VR_EVENT_3 VR_EVENT_3 VR_EVENT_2 VR_EVENT_2 VR_EVENT_4 VR_EVENT_4

slide-23
SLIDE 23

03/26/07 23

A better general overview

~ 60 Hz 100-200 Hz >1kHz ~10Hz ~30Hz ~ 60 Hz 100-200 Hz >1kHz ~10Hz ~30Hz ~ 60 Hz 100-200 Hz >1kHz ~10Hz ~30Hz

slide-24
SLIDE 24

03/26/07 24

So, let’s recap…

  • VR applications are a collection of interconnected, time

VR applications are a collection of interconnected, time-

  • critical and high performance task

critical and high performance task

  • Both loops and events are important!

Both loops and events are important!

  • Integration can be difficult because of shared data

Integration can be difficult because of shared data

  • A global overview of the problem helps developing (or

A global overview of the problem helps developing (or choosing) the right framework choosing) the right framework

slide-25
SLIDE 25

03/26/07

XVR

slide-26
SLIDE 26

03/26/07 26

XVR: our IDE for VR applications

slide-27
SLIDE 27

03/26/07 27

What is XVR

A fully integrated development environment A fully integrated development environment

  • Based on a dedicated programming language

Based on a dedicated programming language

  • Using precompiled byte code (like JAVA)‏

Using precompiled byte code (like JAVA)‏

  • • No need for compilers, linkers, profilers, etc… (unless

No need for compilers, linkers, profilers, etc… (unless you want to expand the framework)‏ you want to expand the framework)‏ Developed as an ActiveX component, so: Developed as an ActiveX component, so:

  • Applications can be embedded inside web pages

Applications can be embedded inside web pages

  • Data exchange with JavaScript, VBScript, Flash etc

Data exchange with JavaScript, VBScript, Flash etc

slide-28
SLIDE 28

03/26/07 28

A WEB-enabled technology…

slide-29
SLIDE 29

03/26/07 29

…controlling VR installations

slide-30
SLIDE 30

03/26/07 30

What does XVR provides

  • A complete and very fast 3D Scene Graph Manager

A complete and very fast 3D Scene Graph Manager

  • Low level OpenGL wrapping for added flexibility

Low level OpenGL wrapping for added flexibility

  • Vertex and pixel

Vertex and pixel-

  • shaders (OpenGL2.0 GLSL)‏

shaders (OpenGL2.0 GLSL)‏

  • • Basic GDI and 2D GUI functions (menus, text)‏

Basic GDI and 2D GUI functions (menus, text)‏

  • • Sound management: MIDI, MP3, 3D Positional Sound

Sound management: MIDI, MP3, 3D Positional Sound

  • Collision detection & Real

Collision detection & Real-

  • time Physics

time Physics

  • Haptic devices control

Haptic devices control

  • Network data management

Network data management

  • Basic streaming support

Basic streaming support

  • Support for advanced devices: Trackers, Stereo

Support for advanced devices: Trackers, Stereo projection, HMDs, Haptic Interfaces, CAVE projection, HMDs, Haptic Interfaces, CAVE

slide-31
SLIDE 31

03/26/07 31

Why is XVR useful in VR development

  • It’s a complete programming environment

It’s a complete programming environment

  • A good implementation of what we need in our daily work

A good implementation of what we need in our daily work

  • One single programming language (and it’s VR

One single programming language (and it’s VR-

  • oriented)
  • riented)
  • Automatic handling of the infrastructure stuff

Automatic handling of the infrastructure stuff

  • Plenty of built

Plenty of built-

  • in advanced function (Including GLSL

in advanced function (Including GLSL support) and low support) and low-

  • level OpenGL support for Graphics

level OpenGL support for Graphics Hackers Hackers

  • It’s extendable: If you have special need, you can easily

It’s extendable: If you have special need, you can easily load and use external DLLs load and use external DLLs

slide-32
SLIDE 32

03/26/07 32

XVR Workflow

Compiler

Interpreter (Virtual Machine)‏ Dedicated scripting language Output Binary ByteCode

slide-33
SLIDE 33

03/26/07 33

Why a scripting language for VR?

  • Because C++ is not always needed. C++ is very powerful

Because C++ is not always needed. C++ is very powerful and flexible, but also very generic and flexible, but also very generic

  • C++ IDEs are hard to install and maintain properly

C++ IDEs are hard to install and maintain properly

  • Sharing code is hard (includes/dependencies/paths)‏

Sharing code is hard (includes/dependencies/paths)‏

  • • Linking external libraries can easily become a nightmare

Linking external libraries can easily become a nightmare

slide-34
SLIDE 34

03/26/07 34

Please note: there are good alternatives

  • VirTools (Dassault Systems)

VirTools (Dassault Systems)

  • Quest 3D (Act

Quest 3D (Act – – 3D)‏3D)‏

slide-35
SLIDE 35

03/26/07 35

  • Eon Reality (EON)

Eon Reality (EON)

  • Vizard (World Viz)‏

Vizard (World Viz)‏

  • Please note: there are good alternatives
slide-36
SLIDE 36

03/26/07 36

XVR Architecture

Virtual Machine Bytecode execution (Multi-Threaded)‏ Virtual Machine Bytecode execution (Multi-Threaded)‏ HI- Performance Real-Time Scene-Graph Audio – Video Library VR Device Handling Real-Time Physics Network Renderer Network Manager

slide-37
SLIDE 37

03/26/07 37

Just like a real one it includes:

  • A bytecode buffer
  • Instruction pointer register
  • Base Stack register
  • Three virtual registers
  • Dynamic stack
  • Global variables table
  • Constants table
  • etc,etc, etc

Virtual Machine Virtual Machine

IP

bytecode bytecode

OP1 OP2 OP3 BS STACK

Function Class Lib Class decl Const Function

GLOBAL VAR

SP

The XVR virtual processor

slide-38
SLIDE 38

03/26/07 38

The XVR scripting language (.S3D)‏

  • •It’s the fundamental glue that

It’s the fundamental glue that keeps everything together keeps everything together

  • A mix of C++ and BASIC

A mix of C++ and BASIC

  • Typeless

Typeless

  • Object oriented

Object oriented

slide-39
SLIDE 39

03/26/07 39

The S3D compilation pipeline

LEXER PARSER Semantic Analyzer ASM Generator Code Generator Optimizer S Y M B O L T A B L E SOURCE File .bin

  • The S3D compilation pipeline

The S3D compilation pipeline

  • A Symbol Table keeps all the information about

A Symbol Table keeps all the information about variables, functions and so on variables, functions and so on

  • Parser and a semantic analyser interpret the code and

Parser and a semantic analyser interpret the code and check its consistency check its consistency

  • A virtual processor ASM code is generated

A virtual processor ASM code is generated

  • An optimiser try to get the best performances from

An optimiser try to get the best performances from loops and recurrent constructs loops and recurrent constructs

  • The ASM code is transformed in bytecode

The ASM code is transformed in bytecode (compressed)‏(compressed)‏

  • • The result of the compilation process is the .bin file

The result of the compilation process is the .bin file

slide-40
SLIDE 40

03/26/07 40

A compilation example: Fibonacci sequence

function Fibonacci( n )‏ { if( n < 0) return 0; if( n ==1) return 1; return Fibonacci( n - 1) + Fibonacci( n - 2 ); } function Main()‏ { return Fibonacci(10); }

slide-41
SLIDE 41

03/26/07 41 Function Main Function Fibonacci 0: PUSHN 1: RET 2: PUSHN 2 3: JGEQ BP(-1) Quad:5 4: RET 5: JNEQ BP(-1) 1 Quad:7 6: RET 1 7: SUB BP(-1) 1 BP(1)‏ 8: PUSH BP(1) 9: CALL Quad:2 (func FIBONACCI)‏ 10: POP BP(1)‏ 11: POPN 1 12: SUB BP(-1) 2 BP(2)‏ 13: PUSH BP(2) 14: CALL Quad:2 (func FIBONACCI)‏ 15: POP BP(2)‏ 16: POPN 1 17: ADD BP(2) BP(1)‏ 18: RET BP(1) 19: PUSHN 1 20: PUSH 10 21: CALL Quad:2 (func FIBONACCI) 22: POP BP(1)‏ 23: POPN 1 24: RET BP(1)‏ Reserve 2 Stack Slots for BS(1) e BS(2)‏ Temporary VAR Fibonacci(n-1)‏

25 intruction

slide-42
SLIDE 42

03/26/07 42

1 L__ RET 160 1 I__ POPN 154 1 L__ POP 150 8 I__ CALL 144 10 I__ PUSH 138 1 I__ PUSHN 132 1 L__ RET 128 1 2 L_L ADD 122 1 I__ POPN 116 2 L__ POP 112 8 I__ CALL 106 2 L__ PUSH 102 2 2

  • 1

LIL SUB 88 1 I__ POPN 82 1 L__ POP 78 8 I__ CALL 72 1 L__ PUSH 68 1 1

  • 1

LIL SUB 54 1 I__ RET 48 54 1

  • 1

LII JNEQ 34 I__ RET 28 34

  • 1

LII JGEQ 14 2 I__ PUSHN 8 ___ RET 6 I__ PUSHN

164

Total byte

slide-43
SLIDE 43

03/26/07 43

Does it have an impact on performances?

No scripting language is as fast as native C or C++ No scripting language is as fast as native C or C++

  • XVR uses bytecode generation/execution

XVR uses bytecode generation/execution – –speed speed similar to JAVA similar to JAVA

  • A script

A script-

  • only function (es Quicksort) is about 20 times
  • nly function (es Quicksort) is about 20 times

slower than a C++ equivalent slower than a C++ equivalent But: But:

  • Most of CPU/GPU workload outside the scripting

Most of CPU/GPU workload outside the scripting language anyway language anyway

  • In practical application we experimented very small to

In practical application we experimented very small to no impact no impact

slide-44
SLIDE 44

03/26/07 44

Some numbers

Legend:

  • S3D is the native XVR code
  • PY is the PYXVR
  • S3D Wine is XVR running under linux using Wine
  • PY Wine is PYXVR running under linux using Wine (with the Windows Python DLL)
  • JS is the JSXVR a new experimental module for writing XVR application in JavaScript
  • AVM is the Adobe Virtual Machine (typed variables and JIT compiling)‏

17fps 3fps 4fps 5fps 5fps 6fps 40000 35fps 6fps 8fps 11fps 10fps 12fps 20000 40fps 12fps 15fps 20fps 19fps 23fps 10000 53fps

  • 5000

AVM JS JS PY Wine S3D Wine PY S3D Number of Particles 17fps 3fps 4fps 5fps 5fps 6fps 40000 35fps 6fps 8fps 11fps 10fps 12fps 20000 40fps 12fps 15fps 20fps 19fps 23fps 10000 53fps

  • 5000

AVM JS JS PY Wine S3D Wine PY S3D Number of Particles

slide-45
SLIDE 45

03/26/07 45

But there are advantages

  • Simplified syntax: script constructs tailored on VR needs

Simplified syntax: script constructs tailored on VR needs

  • Light, self sufficient development environment

Light, self sufficient development environment -

  • > easy to

> easy to set set-

  • up

up

  • Not much framework jargon: straight to the business

Not much framework jargon: straight to the business

  • VERY fast compilation time (almost 0)‏

VERY fast compilation time (almost 0)‏

  • • Compact bytecode, web

Compact bytecode, web -

  • enabled

enabled

  • Commercial technologies are doing the same: see VirTools

Commercial technologies are doing the same: see VirTools

slide-46
SLIDE 46

03/26/07 46

S3D Statements

IF..ELSE WHILE DO..WHILE FOR BREAK CONTINUE SWITCH..CASE SET

SCENE_FOV Field of view SCENE_NEAR Near clipping plane distance SCENE_FAR Far clipping plane distance AUDIO_MODE 3d Audio Setup mode

slide-47
SLIDE 47

03/26/07 47

S3D Variables

VAR i; VAR i; VAR j,k; VAR j,k; VAR x = 2; VAR x = 2; VAR y = 3.1; VAR y = 3.1; VAR s = “Don’t panic !!!” VAR s = “Don’t panic !!!” k = 4.3; k = 4.3; i = 8; i = 8; i = 9.2; i = 9.2; VAR v = [0.0, 1.0, 0.0]; VAR v = [0.0, 1.0, 0.0];

static var a = 10; … a = 7; … reset a; // a = 10

  • Variable type is not explicitly declared

Variable type is not explicitly declared

  • The same variable can assume different types as the

The same variable can assume different types as the program evolve program evolve

  • The construct “reset” can be useful!

The construct “reset” can be useful!

slide-48
SLIDE 48

03/26/07 48

Functions

  • Same as usual

Same as usual

  • Parameter type is not specified

Parameter type is not specified

  • Type of the return value is not specified

Type of the return value is not specified

slide-49
SLIDE 49

03/26/07 49

Class declaration example

class COutput { print(p1); println(p1); }; class Engine: COutput { var m_fuel; var m_power; Init( f, p); Info(); ShowPower(); }; function Engine::Engine( f, p )‏ { Init(f,p); } function Engine::~Engine( f, p )‏ { m_fuel = m_power = void; } function Engine::Init( f, p )‏ { m_fuel = f; m_power = p; }

Classes use a C++-like sintax Simple declaration Declaration with inheritance

  • Variable
  • Method

Constructor (Optional) Destructor (Optional) Method implementation

slide-50
SLIDE 50

03/26/07 50

Multiple inheritance is supported

Class Veicle: Engine, Bodywork { var m_Desc; var m_NumWeels; var m_MaxVel; Info(); }; function Veicle::Veicle( Desc, Weels, MaxVel, EngineFuel, EngineHP, BodyColor, BodyStuff )‏ { m_Desc = Desc; m_NumWeels = Weels; m_MaxVel = MaxVel; Engine::this.Init( EngineFuel, EngineHP ); Bodywork::this.Init( BodyColor, BodyStuff ); }

Multiple inheritance, comma separated Calling a base class method

slide-51
SLIDE 51

03/26/07 51

Operators

slide-52
SLIDE 52

03/26/07 52

Swizzles

Swizzles allow to access the single components of a vector or to generate a new vector with the components exchanged. <VECTOR NAME>.<SWIZZLE> x : first component y : second component z : third component w : fourth component _ or 0 : ignore component v1 = [ 1, 100, -10, -100]; v1.zwx corresponds to [ -10, -100, 1] v1.xxxy corresponds to [ 1, 1, 1, 100 ] v1.x_z or v1.x0z correspond to [ 1, 0, -10 ] v2 = [ -2, 20, 200, -20 ]

  • ne component change:

v2.x = 5 --> v2 = [ 5, 20, 200, -20 ] multiple components change: v2.wy = [ 3,4 ] --> v2 = [ -2, 4, 200, 3 ] multiple components change with no changes on some of them: v2.x_z = [ 3,4,5 ] --> v2 = [ 3, 20, 5, -20 ]

slide-53
SLIDE 53

03/26/07 53

Macros

slide-54
SLIDE 54

03/26/07 54

Preprocessor commands

#DEFINE #IFDEF #ENDIF #ELSE #INCLUDE #PRAGMA Preprocessor directives, such as #define and #ifdef, are typically used tomake source programs easy to change and easy to compile in different execution environments. Directives in the source file tell the preprocessor to perform specific actions. For example, the preprocessor can replace tokens in the text, insert the contents of other files into the source file, or suppress compilation of part of the file by removing sections of text. Preprocessor lines are recognized and carried out before macro expansion.

slide-55
SLIDE 55

03/26/07 55

Handling Large Projects (I)‏

  • It’s possible to use

multiple source files

  • Each file gets

compiled separately

slide-56
SLIDE 56

03/26/07 56

Handling Large Projects (II)‏

  • Main script file
  • The main file

includes the others

  • Secondary script file
  • Secondary script file
  • Please note the

“#define”s

slide-57
SLIDE 57

03/26/07 57

Handling Large Projects (III)‏

  • Secondary script file
  • #define used to avoid

multiple compilations

slide-58
SLIDE 58

03/26/07 58

Structure of an XVR program

slide-59
SLIDE 59

03/26/07 59

How is an application organised in XVR?

  • Any application is based on 6

Any application is based on 6 fundamental function (built in in fundamental function (built in in all the scripts)‏ all the scripts)‏

  • • Currently there are 2 threads

Currently there are 2 threads calling these functions. There calling these functions. There could be more in the future. could be more in the future.

  • Atomicity of the operations is

Atomicity of the operations is

  • guaranteed. Global variables are
  • guaranteed. Global variables are

properly shared between properly shared between threads threads

slide-60
SLIDE 60

03/26/07 60

OnDownload()‏

  • • Every time an XVR script is

Every time an XVR script is executed it creates a temporary executed it creates a temporary working directory (inside the user working directory (inside the user temp)‏ temp)‏

  • • OnDownload is used to move files

OnDownload is used to move files from their original location to the from their original location to the working directory working directory

  • Zip Files are automatically exploded

Zip Files are automatically exploded

  • Generic code can be executed

Generic code can be executed inside OnDownload inside OnDownload

slide-61
SLIDE 61

03/26/07 61

OnInit()‏

  • • Once the download is complete, this

Once the download is complete, this is the right place for initialization code is the right place for initialization code

  • Please note that OnInit accept a

Please note that OnInit accept a “params” value. This is the “params” value. This is the “UserParam” string reported in the “UserParam” string reported in the HTML code HTML code

  • There is an implicit OpenGL

There is an implicit OpenGL “SwapBuffer” when OnInit ends “SwapBuffer” when OnInit ends

slide-62
SLIDE 62

03/26/07 62

OnFrame()‏

  • • Function dedicated to rendering. By

Function dedicated to rendering. By default it gets called after each screen default it gets called after each screen refresh (60 Hz). refresh (60 Hz).

  • Desired framerate can be changed

Desired framerate can be changed using SetFramerate(Value)‏ using SetFramerate(Value)‏

  • •It’s the ONLY function that has

It’s the ONLY function that has access to the OpenGL frame buffer access to the OpenGL frame buffer

  • All the rendering code must be inside

All the rendering code must be inside this function (or inside functions called this function (or inside functions called by OnFrame)‏ by OnFrame)‏

  • •The maximum Frame Rate allowed is

The maximum Frame Rate allowed is 100 Hz 100 Hz

slide-63
SLIDE 63

03/26/07 63

OnTimer()‏

  • • Function normally dedicated to

Function normally dedicated to mange an high speed loop. By default mange an high speed loop. By default it gets called at 100Hz it gets called at 100Hz

  • Desired time

Desired time-

  • step can be changed

step can be changed using SetTimestep(Value)‏ using SetTimestep(Value)‏

  • •Minimum time

Minimum time-

  • step = 1ms

step = 1ms

  • Independent from framerate (unless

Independent from framerate (unless the system is overloaded)‏ the system is overloaded)‏

  • •Excellent place for updating objects

Excellent place for updating objects positions, sound, real time physics, positions, sound, real time physics, haptic interfaces and network haptic interfaces and network programming. programming.

  • It has no access to the framebuffer

It has no access to the framebuffer

slide-64
SLIDE 64

03/26/07 64

OnEvent()‏

  • • Function under construction, coming soon

Function under construction, coming soon

  • Used for Event

Used for Event-

  • driven programming

driven programming

  • It gets called when an EVENT arrives

It gets called when an EVENT arrives

  • EVENTS can be generated inside XVR

EVENTS can be generated inside XVR (GenerateEvent(val, param)) or outside XVR (The (GenerateEvent(val, param)) or outside XVR (The Win32 Events will be intercepted)‏ Win32 Events will be intercepted)‏

  • •Extremely useful in state machines programming

Extremely useful in state machines programming

slide-65
SLIDE 65

03/26/07 65

The typical rendering code

  • Handling Mouse (or keyboard) input
  • SceneBegin(), SceneEnd(), a very

common XVR graphical construct useful for multipass rendering, picture in picture, stereo rendering

  • Mixing low-level calls to scene graph

rendering

slide-66
SLIDE 66

03/26/07 66

The XVR scene graph

slide-67
SLIDE 67

03/26/07 67

Scene Scene Scene

Obj Obj Obj

Mesh Mesh Mesh

Obj Obj Obj

Billboard Billboard Billboard

Obj Obj Obj Obj Obj Obj Obj Obj Obj

Mesh Mesh Mesh

Obj Obj Obj

Callback Callback Callback

XVR Scene Graph: Obj

CVmObj

  • It’s the main component of the XVR Scene Graph
  • A CVmObj node can be linked to other nodes (including other CVmObj nodes) to create a hierarchy
  • It represents a geometrical transformation (traslation/rotation/scaling) and/or the grouping of children
  • bjects
  • The trasformations applied to a CVmObj node are transmitted to the whole hierarchy below
slide-68
SLIDE 68

03/26/07 68

Scene Scene Scene

XVR Scene Graph: OBJ – Mesh paradigm

Obj Obj Obj

Mesh Mesh Mesh Material Material Material Texture Texture Texture Subset Subset Subset Subset Subset Subset Subset Subset Subset

Material Material Material

Material Material Material Texture Texture Texture

CVmMesh/NewMesh

Polygonal meshes loaded from VRML/AAM files. Bounding box Material list Subset list Vertex animation

Shader Shader Shader

slide-69
SLIDE 69

03/26/07 69

Importing 3D models

Obj Obj Obj Obj Obj Obj … …

3D Modeling Tools 3D Modeling Tools Exporters

AAM data AAM data VRML data VRML data IDASF data IDASF data

Scene Scene

slide-70
SLIDE 70

03/26/07 70

The AAM file format

XVR native format for the description of triangular meshes:

Originally created to overcome VRML limitations S

imple sintax, easy to parse

Pixel and Vertex shaders can be embedded

S upport to:

  • Multilayer texturing
  • Animations
  • S

moothing Groups

  • S

kinning Exporters: Max, GMax, Maya and Blender

slide-71
SLIDE 71

03/26/07 71

The AAM exporter plugin

Fully featured version

for 3DS tudioMax

Also available (with

limitations) for:

Maya Blender GMax

slide-72
SLIDE 72

03/26/07 72

XVR Scene Graph: Some Obj methods

SetPosition()‏ SetRotation()‏ SetScale()‏ Translate()‏ Rotate() / RotateABS()‏ SetRotationMatrix()‏ SetPivotPoint()‏

( int flags, int x, int y );

Draw

Obj Obj Obj Obj Obj Obj Obj Obj Obj

Mesh Mesh Mesh

AddChild

( CVmObj child, float posx, float posy, float posz );

LinkToXXX

( CVmNewMesh mesh ) ( CVmBillboard bboard )‏ ( CVmHtmlPage hpage )‏ ( CVmText bboard )‏ ( string callback )‏

slide-73
SLIDE 73

03/26/07 73

XVR Scene Graph: Mesh methods

Hide() / HideAll()‏ UnHide() / UnHideAll()‏ GetSubsetIndex() GetSubsetDescription()‏ GetSubBoundingSphere()‏ Get__()‏

( int flags, int x, int y );

VR_FRAMENUMBER for vertex animation

Draw

Translate()‏ Scale()‏ Normalize()‏ CenterBoundingBox()‏ Mirror()‏ GetBoundingBox()‏ ForceMaterial()‏ ModulateMaterials()‏ ModulateSubsetMaterial() ChangeTextureParams()‏ CheckTransparency() Add/RemoveShader() …