VR Juggler 1.0 Application Programming - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

VR Juggler 1.0 Application Programming

Description:

VR Juggler 1.0 Application Programming – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 38
Provided by: patrickh8
Category:

less

Transcript and Presenter's Notes

Title: VR Juggler 1.0 Application Programming


1
VR Juggler 1.0Application Programming
  • Patrick Hartling
  • Virtual Reality Applications Center
  • IEEE VR 2002

2
Objectives
  • Learn VR Juggler programming basics
  • Be able to write VR Juggler applications
  • Please Ask questions!!!

3
Overview
  • Application objects
  • VR Juggler utility classes
  • Simple VR Juggler application
  • Advanced OGL application

4
Online Documentation
  • www.vrjuggler.org
  • Projects
  • VR Juggler
  • Documentation
  • Guides and references

5
Application Objects
  • All VR Juggler applications are objects
  • Override methods of a pre-defined interface
  • Derived class for each graphics API
  • No main() Dont call me, Ill call you
  • Kernel controls application by calling methods

6
Application Objects
  • Application object is derived from graphics API
    specific base class
  • User application methods must fill-in-the-blank

7
VR Juggler main()
include ltsimpleApp.hgt int main (int argc, char
argv) // Get kernel vjKernel kernel
vjKernelinstance() simpleApp app new
simpleApp() // Create app obj
kernel-gtloadConfigFile() // Configure kernel
kernel-gtstart() // Start kernel
thread kernel-gtsetApplication(app) // Give app
to kernel while ( ! exit ) // sleep
  • How VR Juggler starts-up

8
VR Juggler main()
include ltsimpleApp.hgt int main (int argc, char
argv) // Get kernel vjKernel kernel
vjKernelinstance() simpleApp app new
simpleApp() // Create app obj
kernel-gtloadConfigFile() // Configure kernel
kernel-gtstart() // Start kernel
thread kernel-gtsetApplication(app) // Give app
to kernel while ( ! exit ) // sleep
  • Get handle to kernel

9
VR Juggler main()
include ltsimpleApp.hgt int main (int argc, char
argv) // Get kernel vjKernel kernel
vjKernelinstance() simpleApp app new
simpleApp() // Create app obj
kernel-gtloadConfigFile() // Configure kernel
kernel-gtstart() // Start kernel
thread kernel-gtsetApplication(app) // Give app
to kernel while ( ! exit ) // sleep
  • Create the application
  • Instance of users application object

10
VR Juggler main()
include ltsimpleApp.hgt int main (int argc, char
argv) // Get kernel vjKernel kernel
vjKernelinstance() simpleApp app new
simpleApp() // Create app obj
kernel-gtloadConfigFile() // Configure kernel
kernel-gtstart() // Start kernel
thread kernel-gtsetApplication(app) // Give app
to kernel while ( ! exit ) // sleep
  • Give the kernel initial configuration files
  • Start the kernel thread
  • VR Juggler is now fully running

11
VR Juggler main()
include ltsimpleApp.hgt int main (int argc, char
argv) // Get kernel vjKernel kernel
vjKernelinstance() simpleApp app new
simpleApp() // Create app obj
kernel-gtloadConfigFile() // Configure kernel
kernel-gtstart() // Start kernel
thread kernel-gtsetApplication(app) // Give app
to kernel while ( ! exit ) // sleep
  • Give the kernel an application to run
  • Kernel now starts calling the application
    objects methods

12
Application Object Methods
  • Initialization
  • init() Application initialization
  • Ex Loading data files, lookup tables
  • apiInit() Graphics API specific initialization
  • Ex scene graph loading
  • Frame functions
  • preFrame() Called at start of frame
  • Ex Updating data in response to device input
  • intraFrame() Called while rendering
  • Ex Time consuming computation for next frame
  • postFrame() Called after frame is done
  • Ex Clean up, sync with external net or compute

13
Application Interface
  • Other
  • Reconfiguration
  • Reset
  • Exit
  • Focus change

14
Call Timing
include ltsimpleApp.hgt int main (int argc, char
argv) // Get kernel vjKernel kernel
vjKernelinstance() simpleApp app new
simpleApp() // Create app obj
kernel-gtloadConfigFile() // Configure kernel
kernel-gtstart() // Start kernel
thread kernel-gtsetApplication(app) // Give app
to kernel while ( ! exit ) // sleep
  • setApplication() starts the kernel calling the
    applications member functions

15
  • Call timing Init members
  • init()
  • Called after kernel gets app
  • apiInit()
  • Called after graphics API is running

16
  • Call timing Frame members
  • preFrame()
  • Called after input update
  • intraFrame()
  • Called while rendering of environment is
    happening
  • postFrame()
  • Called after frame but before tracker updates

17
vjGlApp OpenGL Application Interface
  • Derived from vjApp
  • OpenGL specific extensions
  • draw()
  • Draw the scene in OpenGL
  • Called for each OpenGL context
  • Stereo ? Called once per eye
  • contextInit(), contextPreDraw(), contextClose()
  • Discussed later

18
vjPfApp PerformerApplication Interface
  • Derived from vjApp
  • Performer specific extensions
  • initScene()
  • Create the scene graph
  • getScene()
  • Return the root of the scene graph

19
Common Classes
  • Helper classes needed for app development
  • Mathematics matrix, vector, point
  • Input devices

20
Common Classes vjMatrix
  • 4x4 matrix
  • OpenGL ordering
  • Methods
  • Rotation makeXYZEuler(), makeRot()
  • Translation makeTrans(), setTrans()
  • Multiplication mult(), preMult(), postMult()
  • Many others (see Programmers Guide)

21
Common Classes vjVec3 vjVec4
  • Class for float vector
  • Used for points and rays
  • Methods
  • ,-,
  • dot(), normalize(), cross()
  • Many others (see Programmers Guide)

22
Common Classes vjProxy
  • Proxies are used to access all input data
  • wand_pos mWandProxy-gtgetData()
  • Proxies cache and transform input data

23
Common Classes vjDeviceInterface
  • Used to get access to devices through proxies
  • Smart pointer to a device proxy
  • Makes proxies easier to use
  • init()
  • mWand.init(VJWand)

24
Common Classes vjPosInterface
  • vjPosInterface
  • Used to get positional information.
  • Ex. trackers, wand position, head position
  • Derived from vjDeviceInterface
  • Dereferences to vjPosProxy
  • operator(), operator-gt()
  • Get proxy data with getData()
  • vjMatrix wand_pos
  • wand_pos mWand-gtgetData()

25
Common Classes vjDigitalInterface
  • vjDigitalInterface
  • Used to get digital information (ie. 0 or 1)
  • Ex wand buttons
  • getData() returns integer
  • States (return value)
  • OFF
  • ON
  • TOGGLE_ON Just switched to on state
  • TOGGLE_OFF Just switched to off state

26
Sample Application 1Simple OpenGL Application
simpleApp
27
Sample Application 1 simpleApp
  • Simple OpenGL drawing app
  • Member function
  • vjAppinit()
  • vjGlAppdraw()
  • Files
  • simpleApp/simpleApp.h, simpleApp/simpleApp.cpp

28
simpleApp Data Members
class simpleApp public vjGlApp public
simpleApp() virtual void init() virtual
void draw() public vjPosInterface mWand
vjPosInterface mHead vjDigitalInterface
mButton0 vjDigitalInterface mButton1
  • mWand, mHead
  • Position interface to positional proxy
  • Get position
  • vjMatrix wand_pos
  • wand_pos (mWand-gtgetData())
  • mButton0, mButton1
  • Digital interface to digital proxy
  • if(mButton0-gtgetData())
  • cout ltlt Button Pressed

29
simpleApp init()
  • Initialize device interface
  • Device name
  • From configuration file
  • Name of device alias or proxy

void simpleAppinit() // Initialize
devices mWand.init(VJWand)
mHead.init(VJHead) mButton0.init(VJButton0
) mButton1.init(VJButton1)
30
simpleApp draw()
void simpleAppdraw() ... // Create box
offset matrix vjMatrix box_offset
box_offset.makeXYZEuler(-90,0,0)
box_offset.setTrans(0.0,1.0f,0.0f) ...
glPushMatrix() // Push on offset
glMultMatrixf(box_offset.getFloatPtr())
... drawCube() glPopMatrix() ...
  • Create an offset matrix
  • Draw cube

31
Sample Application 2OpenGL Application with
Context-Specific Data
contextApp
32
Context-Specific Data
  • What is a Context?
  • OpenGL Window ? Context for OGL state machine
  • What is context-specific data?
  • Display lists, texture objects, etc.
  • Why do you need it?
  • VR Juggler uses a single memory pool for all
    threads
  • All threads have access to the same variables
  • Ex Multi-wall system

33
Context-Specific Data
  • How does it work
  • Template-based smart pointer class
  • Dereference like normal pointer
  • ie. operator(), operator-gt()
  • vjGlContextDataltGLuintgt myDispList
  • ( myDispList) glGenList(1)
  • glCallList(myDispList)

34
Context App Data Members
Class contextApp public vjGlApp public
contextApp() virtual void init() virtual
void contextInit() virtual void draw()
public // Identifier for the cube display
list vjGlContextDataltGluintgt mCubeDlId
  • Context-specific data for a display list that
    draws a cube

35
Context App contextInit()
  • Create display list
  • Context-specific version is used

void simpleAppcontextInit() // Allocate
context specific data (mCubeDlId)
glGenLists(1) glNewList((mCubeDlId),
GL_COMPILE) glScalef(0.50f, 0.50f,
0.50f) drawCube() glEndList() ...
36
Context App draw()
void simpleAppdraw() // Get Wand matrix
vjMatrix wand_matrix wand_mat
(mWand-gtgetData()) ... glPushMatrix()
glPushMatrix() glMultMatrixf(wand_mat
.getFloatPtr()) glCallList(mCubeDlId)
glPopMatrix() ... glPopMatrix()
  • Render display list
  • De-reference context-specific display list ID

37
Conclusion
  • Questions?
Write a Comment
User Comments (0)
About PowerShow.com