290 likes | 413 Views
David J. Zielinski djzielin@duke.edu Friday Visualization Forum October 1 st ,2004. Creating Virtual Reality Applications Using FreeVR. Overview. What is Virtual Reality? What are my choices? Why use FreeVR? FreeVR program outline Application demos. 1) What is Virtual Reality?.
E N D
David J. Zielinski djzielin@duke.edu Friday Visualization Forum October 1st,2004 Creating Virtual Reality Applications Using FreeVR
Overview • What is Virtual Reality? • What are my choices? • Why use FreeVR? • FreeVR program outline • Application demos
What is Virtual Reality? • Physically immersive (generate input to user's sensory systems) • Interactive (user can change the experience) Examples: reading a book (not interactive or immersive) video game (interactive but not immersive) 3-d movie (immersive but not interactive)
What can we use for physically immersive? • 3-d vision • projection systems: [anaglyphic (red/blue), polarized, active stereo] • head mounted displays.
What can we use for physically immersive? • 3-d sound • multichannel speaker setups • Headphone simulation
What can we use for physically immersive? • Other: • Touch/force feedback • Taste • Smell • Environmental conditions (temperature) • Accelerations/motion • Direct connection to human nervous system
What can we use for interactive? • location tracking systems: magnetic, video, ultra-sonic
What can we use for interactive? • joysticks: wands, game controllers • other: gloves, eye tracking, biological indicators (heart-rate, breathing), props (steering wheels, fishing poles)
2) What are my choices for developing an application/experience? • Write from scratch • Low-level library • Medium-level library (scenegraph) • High-level graphical program • Use domain-specific, off the shelf program
Write from scratch • Pro: • complete control • maximum performance/speed possible • Con: • Long, difficult development • Often device dependent
Low-level library(CAVELib, FreeVR, DIVERSE) • Pro: • lots of control (C/C++,OpenGL programming) • device independent • Con: • difficult for non-programmers, • more control/freedom than most applications require
Medium-level library (OpenSceneGraph, Performer) • Pro: • built in algorithms to cull (eliminate) non-viewable objects • built in algorithms for collision detection • Con: • Still lots of programming • learning curve to use scenegraph format • usually still low-level library dependent
High-level graphical program (Virtools) • Pro: • Easy visual design of worlds • Visual, flow design for object behaviors • Con: • Expensive • speed/performance? • Still have to learn to “program”
Use domain-specific, off the shelf program (Amira, VMD) • Pro: • Very easy, especially if group is already using non-VR version of program • Con: • Individual configuration • not applicable to making custom applications
3) Why use FreeVR? • device independence (input and output) • free/opensource (CAVELib is not) • actively developed (cluster support soon) • I know how to configure it
How does it become device independent? • configuration file (.freevrrc) maps buttons, sensors, and screen locations to FreeVR internals. Different physical configurations require different .rc settings. • on startup FreeVR opens all necessary windows, and handles projection matrices, so correct view is on correct screen.
abstraction of buttons: int pressed=vrGet2switchValue(which_button); if(pressed) printf(“user pressed the button!”);
abstraction of location sensors: vrPointGetRWFrom6sensor(&wand_locpnt, WAND_SENSOR); float x,y,z; x=wand_locpnt.v[0]; y=wand_locpnt.v[1]; z=wand_locpnt.v[2]; if((x<...) AND (y<...) AND (z<...)) /* we are touching an object, do something */
abstraction of display space: we provide single function, that is called for each frame, for each render window. void draw_world() { clear_screen glTranslatef(0,5,-5); /* real world coordinates draw_object }
4) FreeVR program Outline pt.1 Main(){ initialization calls setup callback of world render function setup callback of gfx initialization while(!terminate){ vrFrame(); update(); /* next slide */ } }
FreeVR program Outline pt.2 Update(){ check buttons check sensor positions do logic } draw_world(){ look at world settings (modified in update) make openGL calls to render world }
FreeVR programming Subtleties • Rendering and updates occur in separate processes, so shared memory is needed. FreeVR includes vrShmemAlloc0 which is comparable to malloc. Typically a world data structure is created, modified, and passed around. • because of the separate processes we need to lock the world data when we are writing and reading it. FreeVR includes vrLock. We can call vrLockReadSet(the_lock); vrLockReadRelease(the_lock);
FreeVR Download http://www.freevr.org/ David J. Zielinski djzielin@duke.edu