vr juggler 1.0 application programming patrick hartling virtual reality applications center ieee vr...

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

Post on 26-Mar-2015

215 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Slide 1

VR Juggler 1.0 Application Programming Patrick Hartling Virtual Reality Applications Center IEEE VR 2002 Slide 2 VR Juggler www.vrjuggler.org Objectives Learn VR Juggler programming basicsLearn VR Juggler programming basics Be able to write VR Juggler applicationsBe able to write VR Juggler applications Please: Ask questions!!!Please: Ask questions!!! Slide 3 VR Juggler www.vrjuggler.org Overview Application objectsApplication objects VR Juggler utility classesVR Juggler utility classes Simple VR Juggler applicationSimple VR Juggler application Advanced OGL applicationAdvanced OGL application Slide 4 VR Juggler www.vrjuggler.org Online Documentation www.vrjuggler.orgwww.vrjuggler.orgwww.vrjuggler.org ProjectsProjects VR Juggler Documentation Guides and referencesGuides and references Slide 5 VR Juggler www.vrjuggler.org 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 Slide 6 VR Juggler www.vrjuggler.org Application Objects Application object is derived from graphics API specific base classApplication object is derived from graphics API specific base class User application methods must fill-in-the-blankUser application methods must fill-in-the-blank Slide 7 VR Juggler www.vrjuggler.org #include int main (int argc, char* argv[]) { // Get kernel vjKernel* kernel = vjKernel::instance(); simpleApp* app = new simpleApp(); // Create app obj kernel->loadConfigFile(); // Configure kernel kernel->start(); // Start kernel thread kernel->setApplication(app); // Give app to kernel while ( ! exit ) { // sleep } } VR Juggler main() How VR Juggler starts-upHow VR Juggler starts-up Slide 8 VR Juggler www.vrjuggler.org #include int main (int argc, char* argv[]) { // Get kernel vjKernel* kernel = vjKernel::instance(); simpleApp* app = new simpleApp(); // Create app obj kernel->loadConfigFile(); // Configure kernel kernel->start(); // Start kernel thread kernel->setApplication(app); // Give app to kernel while ( ! exit ) { // sleep } } VR Juggler main() Get handle to kernelGet handle to kernel Slide 9 VR Juggler www.vrjuggler.org #include int main (int argc, char* argv[]) { // Get kernel vjKernel* kernel = vjKernel::instance(); simpleApp* app = new simpleApp(); // Create app obj kernel->loadConfigFile(); // Configure kernel kernel->start(); // Start kernel thread kernel->setApplication(app); // Give app to kernel while ( ! exit ) { // sleep } } VR Juggler main() Create the applicationCreate the application Instance of users application object Slide 10 VR Juggler www.vrjuggler.org #include int main (int argc, char* argv[]) { // Get kernel vjKernel* kernel = vjKernel::instance(); simpleApp* app = new simpleApp(); // Create app obj kernel->loadConfigFile(); // Configure kernel kernel->start(); // Start kernel thread kernel->setApplication(app); // Give app to kernel while ( ! exit ) { // sleep } } VR Juggler main() Give the kernel initial configuration filesGive the kernel initial configuration files Start the kernel threadStart the kernel thread VR Juggler is now fully running Slide 11 VR Juggler www.vrjuggler.org #include int main (int argc, char* argv[]) { // Get kernel vjKernel* kernel = vjKernel::instance(); simpleApp* app = new simpleApp(); // Create app obj kernel->loadConfigFile(); // Configure kernel kernel->start(); // Start kernel thread kernel->setApplication(app); // Give app to kernel while ( ! exit ) { // sleep } } VR Juggler main() Give the kernel an application to runGive the kernel an application to run Kernel now starts calling the application objects methodsKernel now starts calling the application objects methods Slide 12 VR Juggler www.vrjuggler.org Application Object Methods Initialization init() : Application initializationinit() : Application initialization Ex: Loading data files, lookup tables apiInit() : Graphics API specific initializationapiInit() : Graphics API specific initialization Ex: scene graph loading Frame functions preFrame() : Called at start of framepreFrame() : Called at start of frame Ex: Updating data in response to device input intraFrame() : Called while renderingintraFrame() : Called while rendering Ex: Time consuming computation for next frame postFrame() : Called after frame is donepostFrame() : Called after frame is done Ex: Clean up, sync with external net or compute Slide 13 VR Juggler www.vrjuggler.org Application Interface OtherOther Reconfiguration Reset Exit Focus change Slide 14 VR Juggler www.vrjuggler.org #include int main (int argc, char* argv[]) { // Get kernel vjKernel* kernel = vjKernel::instance(); simpleApp* app = new simpleApp(); // Create app obj kernel->loadConfigFile(); // Configure kernel kernel->start(); // Start kernel thread kernel->setApplication(app); // Give app to kernel while ( ! exit ) { // sleep } } Call Timing setApplication() starts the kernel calling the applications member functionssetApplication() starts the kernel calling the applications member functions Slide 15 VR Juggler www.vrjuggler.org Call timing: Init members init()init() Called after kernel gets app apiInit()apiInit() Called after graphics API is running Slide 16 VR Juggler www.vrjuggler.org Call timing: Frame members preFrame()preFrame() Called after input update intraFrame()intraFrame() Called while rendering of environment is happening postFrame()postFrame() Called after frame but before tracker updates Slide 17 VR Juggler www.vrjuggler.org vjGlApp : OpenGL Application Interface Derived from vjAppDerived from vjApp OpenGL specific extensionsOpenGL specific extensions draw() Draw the scene in OpenGL Called for each OpenGL context Stereo Called once per eye contextInit(), contextPreDraw(), contextClose() Discussed later Slide 18 VR Juggler www.vrjuggler.org vjPfApp : Performer Application Interface Derived from vjAppDerived from vjApp Performer specific extensionsPerformer specific extensions initScene() Create the scene graph getScene() Return the root of the scene graph Slide 19 VR Juggler www.vrjuggler.org Common Classes Helper classes needed for app development Mathematics: matrix, vector, pointMathematics: matrix, vector, point Input devicesInput devices Slide 20 VR Juggler www.vrjuggler.org Common Classes: vjMatrix 4x4 matrix OpenGL orderingOpenGL orderingMethods Rotation: makeXYZEuler(), makeRot()Rotation: makeXYZEuler(), makeRot() Translation: makeTrans(), setTrans()Translation: makeTrans(), setTrans() Multiplication: mult(), preMult(), postMult()Multiplication: mult(), preMult(), postMult() Many others (see Programmers Guide)Many others (see Programmers Guide) Slide 21 VR Juggler www.vrjuggler.org Common Classes: vjVec3 & vjVec4 Class for float vectorClass for float vector Used for points and raysUsed for points and rays MethodsMethods +,-,= dot(), normalize(), cross() Many others (see Programmers Guide) Slide 22 VR Juggler www.vrjuggler.org Common Classes: vjProxy Proxies are used to access all input dataProxies are used to access all input data wand_pos = mWandProxy->getData(); Proxies cache and transform input dataProxies cache and transform input data Slide 23 VR Juggler www.vrjuggler.org 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); Slide 24 VR Juggler www.vrjuggler.org Common Classes: vjPosInterface vjPosInterface Used to get positional information.Used to get positional information. Ex. trackers, wand position, head position Derived from vjDeviceInterfaceDerived from vjDeviceInterface Dereferences to vjPosProxyDereferences to vjPosProxy operator*(), operator->() Get proxy data with: getData() vjMatrix* wand_pos; wand_pos = mWand->getData(); Slide 25 VR Juggler www.vrjuggler.org Common Classes: vjDigitalInterface vjDigitalInterface Used to get digital information (ie. 0 or 1)Used to get digital information (ie. 0 or 1) Ex: wand buttons getData() returns integergetData() returns integer States (return value): OFF ON TOGGLE_ON: Just switched to on state TOGGLE_OFF: Just switched to off state Slide 26 VR Juggler www.vrjuggler.org Sample Application 1: Simple OpenGL Application simpleApp Slide 27 VR Juggler www.vrjuggler.org Sample Application 1: simpleApp Simple OpenGL drawing app Member functionMember function vjApp::init() vjGlApp::draw() FilesFiles simpleApp/simpleApp.h, simpleApp/simpleApp.cpp Slide 28 VR Juggler www.vrjuggler.org class simpleApp: public vjGlApp { public: simpleApp(); virtual void init(); virtual void draw(); public: vjPosInterface mWand; vjPosInterface mHead; vjDigitalInterface mButton0; vjDigitalInterface mButton1; }; simpleApp: Data Members mWand, mHead :mWand, mHead : Position interface to positional proxy Get position vjMatrix wand_pos; wand_pos = *(mWand->getData()); mButton0, mButton1mButton0, mButton1 Digital interface to digital proxy if(mButton0->getData()) cout () vjGlContextData myDispList; (* myDispList) = glGenList(1); glCallList(*myDispList); Slide 34 VR Juggler www.vrjuggler.org Class contextApp: public vjGlApp { public: contextApp(); virtual void init(); virtual void contextInit(); virtual void draw(); public: // Identifier for the cube display list vjGlContextData mCubeDlId; }; Context App: Data Members Context-specific data for a display list that draws a cubeContext-specific data for a display list that draws a cube Slide 35 VR Juggler www.vrjuggler.org Context App: contextInit() Create display listCreate display list Context-specific version is usedContext-specific version is used void simpleApp::contextInit() { // Allocate context specific data (*mCubeDlId) = glGenLists(1); glNewList((*mCubeDlId), GL_COMPILE); glScalef(0.50f, 0.50f, 0.50f); drawCube(); glEndList();... } Slide 36 VR Ju

Recommended

View more >