Upload
lita
View
44
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Department of Computer Science. VR PROGRAMMING. VR Toolkits. System architecture. VR Programming Toolkits Are extensible libraries of object-oriented functions designed to help the VR developer; Support various common i/o devices used in VR (so drivers need not be written by the developer); - PowerPoint PPT Presentation
Citation preview
Department of Computer Science
VR PROGRAMMING
System architecture
VR ToolkitsVR Toolkits
VR Programming ToolkitsVR Programming Toolkits Are extensible libraries of object-oriented functions designed to help the VR developer; Support various common i/o devices used in VR (so drivers need not be written by the developer); Allow import of CAD models (saves time), editing of shapes, specifying object hierarchies, collision detection and multi-level of detail, shading and texturing, run-time management; Have built-in networking functions for multi-user interactions, etc.
VR Toolkits can be classified by:VR Toolkits can be classified by: Whether text-based or graphical-programming; The type of language used and the library size; The type of i/o devices supported; The type of rendering supported; Whether general-purpose or application specific; Whether proprietary (more functionality, better documented) or public domain (free, but less documentation and functionality)
VR Toolkits in Early ‘90sVR Toolkits in Early ‘90s RenderWare (Cannon), VRT3/Superscape (Dimension Ltd.), Cyberspace Developer Kit (Autodesk), Cosmo Authoring Tool (SGI/Platinum/CA), Rend386 and others; They allowed either text-based programming (RenderWare, CDK and Rend386), or graphical programming (Superscape and Cosmo); They were platform-independent and generally did not require graphics acceleration hardware; As a result they tended to use “low-end” i/o devices (mouse) and to support flat shading to maintain fast rendering.
Rend386 sceneRend386 scene
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapter
Name Appl Prgm mode
Proprietary
Language
Java3D
(Sun Micro)
General Purpose
text no Implemented in C
Programming in Java
Vizard Toolkit
and PeoplePak WorldViz
General Purpose
Text/
graph
yes OpenGL-based Python
scripting language
GHOST (SensAble Technologies)
Haptics for Phantom
text yes C++C++
H3D Haptics/
Graphics
text no C++C++
PeopleShop
(Boston Dynamics)
Military/
civilian
graph yes C/C++C/C++
Unity 3D Game engine
Text/
graph
yes JavaScript, C#,
and Python
The scene graph:The scene graph: Is a hierarchical organization of objects (visible or not) in the virtual world (or “universe”) together with the view to that world; Scene graphs are represented by a tree structure, with nodes connected by branches. Visible objects are represented by external nodes, which are called leafs (they have no children). Example nodes F, G, H, I Internal nodes represent transformations (which apply to all their children)
A
B C
ED J
F G H I
Root nodeRoot node
Internal nodeInternal node
External nodeExternal node
palmpalm
SceneScene
BallBall
Scene graph shows that the ball is a child of “scene”
Scene graphs are not static
palmpalm
SceneScene
BallBall
Scene graph has been modified, such that the ball is now a child of the palm
VC 6.1 on book CD
palmpalm
SceneScene
Knob 1Knob 1 Knob 2Knob 2 Knob 3Knob 3 Knob 4Knob 4
ButtonButton PanelPanel
ThumbThumb
PinkiePinkie
RingRing
MiddleMiddle
IndexIndex
palmpalm
SceneScene
Knob 1Knob 1
Knob 2Knob 2 Knob 3Knob 3 Knob 4Knob 4
ButtonButton PanelPanel
ThumbThumb
PinkiePinkie
RingRing
MiddleMiddle
IndexIndex
Authoring Authoring (Modeling) (Modeling) StagesStages
Model GeometryModel Geometry
Define and link Define and link sensorssensors
Define action Define action functionsfunctions
Define scene graphDefine scene graph
Define networkingDefine networking
Run-time loopRun-time loop
Start SimulationStart Simulation
Update ObjectsUpdate Objects(from sensors and (from sensors and intelligent actionsintelligent actions
Render sceneRender scene(graphics, audio, (graphics, audio,
haptics)haptics)
Read Sensor DataRead Sensor Data
Exit SimulationExit Simulation
Rep
eats
eve
ry f
ram
eR
epea
ts e
very
fra
me
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapter
Name Appl Prgm mode
Proprietary
Language
Java3D Java3D
(Sun Micro)(Sun Micro)
General General PurposePurpose
texttext nono Implemented in CImplemented in C
Programming in JavaProgramming in Java
Vizard Toolkit
and PeoplePak WorldViz
General Purpose
Text/
graph
yes OpenGL-based Python
scripting language
GHOST (SensAble Technologies)
Haptics for Phantom
text yes C++C++
H3D Haptics/
Graphics
text no C++C++
PeopleShop
(Boston Dynamics)
Military/
civilian
graph yes C/C++C/C++
Unity 3D Game engine
Text/
graph
yes JavaScript, C#,
and Python
Java and Java 3DJava and Java 3D Java
object oriented programming language developed for network applications platform independent slower than C/C++
Java 3D Java hierarchy of classes that serves as an interface to 3D graphics rendering and sound rendering systems Perfectly integrated with Java Strong object oriented architecture Powerful 3D graphics API
Java 3D Java 3D InitiationInitiation
Model GeometryModel Geometry
Setup sensorsSetup sensors
Define behaviorsDefine behaviors
Define scene graphDefine scene graph
NetworkingNetworking
Java 3D Java 3D InitiationInitiation
Model GeometryModel Geometry
Setup sensorsSetup sensors
Define behaviorsDefine behaviors
Define scene graphDefine scene graph
NetworkingNetworking
Java 3D geometry:Java 3D geometry: Geometry can be imported from various file formats (e.g. 3DS, DXF, LWS, NFF, OBJ, VRT, VTK, WRL) Can be created as a primitive geometry (e.g. sphere, cone, cylinder, …) Custom geometry created by specifying the vertices, edges, normals, texture coordinates using specially defined classes
Imported geometryImported geometryloader.load(“Hand.wrl")loader.load(“Hand.wrl")
Geometry primitive:Geometry primitive:new Sphere(radius)new Sphere(radius)
Custom geometry:Custom geometry:new GeometryArray(…)new GeometryArray(…)new LineArray(…)new LineArray(…)new QuadArray(…)new QuadArray(…)new TriangleArray(…)new TriangleArray(…)
Java 3D object Java 3D object appearance:appearance: The appearance of a geometry is specified using an appearance object An appearance-class object stores information about the material (diffuse, specular, shininess, opacity, …) and texture
Mat = new Material();Mat.setDiffuseColor(r, g, b);Mat.setAmbientColor(r, g, b);Mat.setSpecularColor(r, g, b);
TexLd = new TextureLoader(“checkered.jpg”, ...);Tex = TexLd.getTexture();
Appr = new Appearance();Appr.setMaterial(Mat);Appr.setTexture(Text);
Geom.setAppearance(Appr)
Java 3D Java 3D InitiationInitiation
Model GeometryModel Geometry
Setup sensorsSetup sensors
Define behaviorsDefine behaviors
Define scene graphDefine scene graph
NetworkingNetworking
Java3D node types:Java3D node types:
Node
Group
Leaf
BranchGroup
TransformGroup
Switch
Background
Behavior
Fog
Light
Shape3D
Compilable sub-graph
Transform + child nodes
Select which of the children are visible (useful for LOD)
Universe background. Can be a color or an image
Actions to be performed by the simulation
Fog node
Light node. Special derived classes: AmbientLight, PointLight, DirectionalLight
Geometry + Appearance + BoundingBox
Java3D scene graphJava3D scene graph
Node
Loading objects from filesLoading objects from files
Java3D offers by default support for Lightwave and Wavefront model files Loaders for other file formats can be downloaded for free from the web http://www.j3d.org/utilities/loaders.html Loaders add the content of the read file to the scene graph as a single object. However, they provide functions to access the subparts individually
Universe Universe RootRoot
CubeCube SphereSphere HandHand
ThumbThumb IndexIndex MiddleMiddle RingRing SmallSmall
Scene Sc = loader.load(“Hand.wrl”);BranchGroup Bg = Sc.getSceneGroup();RootNode.addChild(Bg);
Java3D model loadingJava3D model loading
Scene Sc = loader.load(“Hand.wrl”);BranchGroup Bg = Sc.getSceneGroup();Thumb = Bg.getChild(0);Index = Bg.getChild(1);Middle = Bg.getChild(2);Ring = Bg.getChild(3);Small = Bg.getChild(4);
Adding the model to the scene graph
Accessing subparts of the loaded model
Palm = loader.load("Palm.wrl").getSceneGroup();ThumbProximal = loader.load("ThumbProximal.wrl").getSceneGroup();ThumbDistal = loader.load("ThumbDistal.wrl").getSceneGroup();IndexProximal = loader.load("IndexProximal.wrl").getSceneGroup();IndexMiddle = loader.load("IndexMiddle.wrl").getSceneGroup();IndexDistal = loader.load("IndexDistal.wrl").getSceneGroup();MiddleProximal = loader.load("MiddleProximal.wrl").getSceneGroup();MiddleMiddle = loader.load("MiddleMiddle.wrl").getSceneGroup();MiddleDistal = loader.load("MiddleDistal.wrl").getSceneGroup();RingProximal = loader.load("RingProximal.wrl").getSceneGroup();RingMiddle = loader.load("RingMiddle.wrl").getSceneGroup();RingDistal = loader.load("RingDistal.wrl").getSceneGroup();SmallProximal = loader.load("SmallProximal.wrl").getSceneGroup();SmallMiddle = loader.load("SmallMiddle.wrl").getSceneGroup();SmallDistal = loader.load("SmallDistal.wrl").getSceneGroup();
Java3D virtual hand loading:Java3D virtual hand loading:
Java3D virtual hand hierarchy:Java3D virtual hand hierarchy:
Palm.addchild(ThumbProximal );Palm.addchild(ThumbProximal );ThumbProximal .addchild(ThumbDistal );ThumbProximal .addchild(ThumbDistal );
Palm.addchild(IndexProximal );Palm.addchild(IndexProximal );IndexProximal .addchild(IndexMiddle );IndexProximal .addchild(IndexMiddle );IndexMiddle .addchild(IndexDistal );IndexMiddle .addchild(IndexDistal );
Palm.addchild(MiddleProximal );Palm.addchild(MiddleProximal );MiddleProximal .addchild(MiddleMiddle );MiddleProximal .addchild(MiddleMiddle );MiddleMiddle .addchild(MiddleDistal );MiddleMiddle .addchild(MiddleDistal );
Palm.addchild(RingProximal );Palm.addchild(RingProximal );RingProximal .addchild(RingMiddle );RingProximal .addchild(RingMiddle );RingMiddle .addchild(RingDistal );RingMiddle .addchild(RingDistal );
Palm.addchild(SmallProximal );Palm.addchild(SmallProximal );SmallProximal .addchild(SmallMiddle );SmallProximal .addchild(SmallMiddle );SmallMiddle .addchild(SmallDistal );SmallMiddle .addchild(SmallDistal );
Java3D Java3D InitiationInitiation
Model GeometryModel Geometry
Setup sensorsSetup sensors
Define behaviorsDefine behaviors
Define scene graphDefine scene graph
NetworkingNetworking
Input devices in Java3DInput devices in Java3D
The only input devices supported by Java3D are the mouse and the keyboard The integration of the input devices currently used in VR applications (position sensors, track balls, joysticks, sensing gloves…) relies entirely on the developer Usually the drivers are written in C/C++. One needs either to re-write the driver using Java or use JNI (Java Native Interface) to call the C/C++ version of the driver. The latter solution is more desirable. Java3D provides a nice general purpose input device interface that can be used to integrate sensors. However, many times developers prefer custom made approaches
Java3D General purpose sensor interfaceJava3D General purpose sensor interfaceclass PhysicalEnvironment - stores information about all the input devices and sensors involved in the simulation
class InputDevice - interface for an input device driver
class Sensor - class for objects that provide real time data
PhysicalEnvironment
InputDevices Sensors
One input device can provide one or more sensorsOne input device can provide one or more sensors
A sensors object needs not be in relation with an input device (VRML style sensors)A sensors object needs not be in relation with an input device (VRML style sensors)
Java3D Java3D InitiationInitiation
Model GeometryModel Geometry
Setup sensorsSetup sensors
Animating the sceneAnimating the scene
Define scene graphDefine scene graph
NetworkingNetworking
Java3D - Animating the simulationJava3D - Animating the simulation
Java3D offers Behavior objects for controlling the simulation A Behavior object contains a set of actions performed when the object receives a stimulus A stimulus is sent by a WakeupCondition object Some wakeup classes:
WakeupOnCollisionEntryWakeupOnCollisionExitWakeupOnCollisionMovementWakeupOnElapsedFramesWakeupOnElapsedTimeWakeupOnSensorEntryWakeupOnSensorExitWakeupOnViewPlatformEntryWakeupOnViewPlatformExit
Java3D - Behavior usageJava3D - Behavior usage
WakeupOnElapsedFrames Wup = new WakeupOnElapsedFrames(0);WakeupOnElapsedFrames Wup = new WakeupOnElapsedFrames(0);
Bhv.wakeupOn(Wup);Bhv.wakeupOn(Wup);
Universe Universe RootRoot
• We define a behavior We define a behavior Bhv Bhv that rotates the that rotates the sphere by 1 degreesphere by 1 degree
• We want this behavior to be called each We want this behavior to be called each frame so that the sphere will be spinningframe so that the sphere will be spinning
VC 6.3 on book CD VC 6.4 on book CD
The Java 3D View object describes the graphics display used in the simulation, as well as the user’s position versus that display (given by the tracker);
The View model provides a separation between the virtual world provided by the ViewPlatform node and the real I/O devices used in the interaction; This separation helps portability.
Several users that are tracked can be mapped to the same location in the virtual world. This corresponds to several Views and a single ViewPlatform;
Conversely, a single user can control several ViewPlatforms;
This corresponds to several Views since each ViewPlatform has its own View; Thus a single user can have several Views to a virtual world, and can “teleport” between them. Thus a single user can have several Views to a virtual world, and can “teleport” between them.
View platform 1View platform 1View platform 2View platform 2
Java3D Java3D InitiationInitiation
Model GeometryModel Geometry
Setup sensorsSetup sensors
Define behaviorsDefine behaviors
Define scene graphDefine scene graph
NetworkingNetworking
Java3D Java3D simulationsimulation
Java Java ApplicationApplication
Java3D Java3D simulationsimulation
Java Java AppletApplet
Java3D Java3D simulationsimulation
Java Java ApplicationApplication
Java3D - NetworkingJava3D - Networking Java3D does not provide a built-in solution for networked virtual environments However, it’s perfect integration in the Java language allows the developer to use the powerful network features offered by Java Java3D applications can run as stand alone applications or as applets in a web browser
Java3D Java3D simulationsimulation
Java Java AppletApplet
Server
Java3D and VRMLJava3D and VRML
VRML provides possibilities for defining the objects and animating the objects in a virtual world Graphics APIs such as Java3D load from a VRML file only the static information, ignoring the sensors, routes, scripts, etc. Java3D structure is general enough to make the import of sensors and routes possible but currently we are not aware of any loader that does it One of the most popular library of Java3D loaders is the NCSA Portfolio (http://cs.gmu.edu/~eclab/projects/mason/ncsaportfolio/)
NCSA PortfolioNCSA Portfolio
Offers loaders for several model files
3D Studio (3DS) TrueSpace COB loader (COB) Java 3D Digital Elevation Map (DEM) AutoCAD (DXF ) Imagine (IOB) Lightwave (LWS)Wavefront (OBJ) Protein Data Bank (PDB) Visualization Toolkit (VTK) VRML97
Loades the following parts of VRML97 files
Appearance Box Coordinate Collision (for grouping only) Group IndexedFaceSet IndexedLineSet Material Normal Shape Sphere Transform
Java3D on-line resources
http://java.sun.com/products/java-media/3D/index.html http://www.j3d.orghttp://cs.gmu.edu/~eclab/projects/mason/ncsaportfolio/
Comparison between Java3D and WTKComparison between Java3D and WTK
A comparative study was done at Rutgers between Java3d (Version 1.3beta 1) and WTK (Release 9); The simulation ran on a dual Pentium III 933 MHz PC (Dell) with 512 Mbytes RAM, with an Wildcat 4110 graphics accelerator which had 64 Mbytes RAM; The I/o interfaces were a Polhemus Insidetrack or the Rutgers Master II force feedback glove; The scene consisted of several 420-polygon spheres and a virtual hand with 2,270 polygons; The spheres rotated constantly around an arbitrary axis, while the hand was either rotating, or driven by the user.
Java3D –WTK ComparisonGraphics scene used in experimentsGraphics scene used in experiments
Comparison between Java3D and WTKComparison between Java3D and WTK
The simulation variables used to judged performance were: graphic mode (monoscopic, stereoscopic), rendering mode (wireframe, Gouraud, textured); scene complexity (number of polygons 5,000 – 50,000); lighting (number of light sources 1, 5, 10); interactivity (no interaction, hand input, force feedback)
Java3D –WTK Comparison
Java3d is faster on average than WTK, but has higher variability
Java3D –WTK Comparison
Java3d Release 3.1 Beta 1 has less system latencies than WTK Release 9
But Java3d has more variability in the scene rendering time
WTK does not have spikes in the scene rendering time
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapter
Name Appl Prgm mode
Proprietary
Language
Java3D
(Sun Micro)
General Purpose
text no Implemented in C
Programming in Java
Vizard Toolkit
and PeoplePak WorldViz
General Purpose
Text/
graph
yes OpenGL-based Python
scripting language
GHOST (SensAble Technologies)
Haptics for Phantom
text yes C++C++
H3D Haptics/
Graphics
text no C++C++
PeopleShop
(Boston Dynamics)
Military/
civilian
graph yes C/C++C/C++
Unity 3D Game engine
Text/
graph
yes JavaScript, C#,
and Python
Vizard characteristics:Vizard characteristics: Uses Python which is a scalable and cross-platform; It is object-oriented and simple to integrate with C/C++ It runs on Unix, Windows, Mac and other platforms; Uses a 4-window “workbench” which allows programmers to write and execute code, inspect 3D models, drag-and-drop objects, and issue commands while the scene is being rendered.
Stack of scripts – errors are highlighted as you type
Interactive window – input commands
Resource window – Text list of word assets
3D window – Explore individualobjects
Workbench use:Workbench use:Icon menu
Scene exploration with the mouse
Importing objects
import vizimport handviz.go()#Identify the 5DT glove's port.PORT_5DT_USB = 0
#Add the 5DT sensorsensor = viz.add('5dt.dls')
#Create a hand object from the data gloveglove = hand.add(sensor,hand.GLOVE_5DT)
#Place the hand in front of the userglove.translate(0,1,5)glove.rotate(180,-90,180) # now when you run the script the glove should be moving
Vizard virtual hand:Vizard virtual hand:
import vizviz.go()
logo = viz.add('logo.wrl') #add vizard logo and place it in front of userlogo.translate(0,2,4)
tex1 = viz.add('gb_noise.jpg') #add two textures that will then be applied to the logo#tex2 = viz.add('brick.jpg')logo.texture(tex1) #applies the first texturelogo.texture(tex2,'',1) #applies the second texture to the logoblend = viz.add('multitexblend.fp') #indicate how to blend the two textureslogo.apply(blend)
Vizard multi-texturing:Vizard multi-texturing:
Vizard Simulation Servers:Vizard Simulation Servers: More than one user can inhabit the same environment. Each user needs to run Vizard. After the world is set up, each user has to set up two “mail boxes”. One receives information from the other user after it was given network name. Messages come in sequence [0] who sent it, [1] what is sent, [2] and larger the actual data
User 2User 2User 1User 1
Position is the propertyPosition is the property
Ball is the objectBall is the object
action
information
Vizard networking example:Vizard networking example:Import vizViz.go()Ball=viz.add(‘ball.wrl’) #create a Ball object that is controlled by the other user #add the world that will be displayed on your computer #Use a prompt to ask the other user the network name of his computer.target_machine = viz.input('Enter the name of the other machine'). upper()
#Add a mailbox from which to send messages to the other user. This is your outbox.target_mailbox = viz.add(viz.NETWORK, target_machine) #Add an id for the timer.BROADCAST = 1
#Add the timer.def mytimer(num): if num == BROADCAST: #Retrieve your current position. position = viz.get(viz.HEAD_POS) #Send the data to the target mailbox. All the recipient will get your yaw, x and z coordinates. target_mailbox.send(position[0], position[1], position[2])
Vizard networking example:Vizard networking example:
##This function will deal with incoming messages.def mynetwork(message): #message[0] is who sent the message, message[1] is a description of what he #sent and message[2] and greater are the messages themselves. x = message[2] y = message[3] z = message[4] ball.translate(x,y,z)
# Callback the network function to await incoming messages.viz.callback(viz.NETWORK_EVENT, mynetwork)# Callback the timer. viz.callback(viz.TIMER_EVENT, mytimer)# Start the timer.viz.starttimer(BROADCAST, 0.01, -1)
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapter
Name Appl Prgm mode
Proprietary
Language
Java3D
(Sun Micro)
General Purpose
text no Implemented in C
Programming in Java
Vizard Toolkit
and PeoplePak WorldViz
General Purpose
Text/
graph
yes OpenGL-based Python
scripting language
GHOST (SensAble GHOST (SensAble Technologies) Technologies)
Haptics for Haptics for PhantomPhantom
texttext yesyes C++C++
H3D Haptics/
Graphics
text no C++C++
PeopleShop
(Boston Dynamics)
Military/
civilian
graph yes C/C++C/C++
Unity 3D Game engine
Text/
graph
yes JavaScript, C#,
and Python
GHOST Toolkit for the PHANToMGHOST Toolkit for the PHANToM Provides realistic haptic interaction
Provides and intuitive interfaces to haptics
Provides a haptic scene graph aligned with 3D graphics APIs
Provides an extensible environment for extending haptic interaction technologies
Point haptic interaction with PHANTOM
geometry based on user defined force models
Geometry moves dynamically in response to forces
x
y
z(0,0,0)
PHANToM Desktop modelPHANToM Desktop model
GHOST – Application interactionGHOST – Application interaction
x
y
z (0,0,0)
adapted from Ghost SDK Programmer’s Guide (version 3.1)
Application ProcessApplication Process Haptic ProcessHaptic Process
Scene CreationScene Creation
Collision detectionCollision detectionCollision responseCollision response
Haptic State Haptic State UpdateUpdate
Clean-upClean-up
HapticHapticRenderingRendering
HapticHapticServo loopServo loop
30 f
ps
30 f
ps Scene RenderingScene Rendering
1000 Hz1000 Hz
100 Hz100 Hz
The GHOST haptics scene graphThe GHOST haptics scene graph
x
y
z (0,0,0)
adapted from Ghost SDK Programmer’s Guide (version 3.1)
Application ProcessApplication Process Haptic ProcessHaptic Process
Scene CreationScene Creation
Collision detectionCollision detectionCollision responseCollision response
Haptic State Haptic State UpdateUpdate
Clean-upClean-up
HapticHapticRenderingRendering
HapticHapticServo loopServo loop
30 f
ps
30 f
ps Scene RenderingScene Rendering
1000 Hz1000 Hz
Haptic scene graphHaptic scene graph Provides a structured way to construct a haptic scene, including geometry and dynamics;
is traversed only from top to bottom (unlike WTK);
each node reachable by only one (unique) traversal from the root (a child node has only one parent node)
Each node has its own transform (no separate transform nodes);
cannot use pointers to repeat instances of the same object, since similar objects have different haptic interactions;
Separator nodes to create a hierarchy – Transforms on the Separator affect its sub-tree;
GHOST node classesGHOST node classes
3D supportStatic NodesDynamic NodesUtility Classes
gstBoundedHapticObjgstNode gstTransform gstShape
gstCube
gstSphere
gstCone
gstCylinder
gstTorus
gstTriPolyMeshHaptic
gstPHANToM_SCP
gstBoundary
gstBoundaryCube
gstSeparator gstDynamic gstDial
gstButton
gstSlider
gstPHANToM
gstPHANToMDynamic
gstPHANToMTranslation
gstPHANToMRotation
gstRigidBody
gstForceField
gstConstantForceField
gstPoint gstVector
gstTransformMatrix
gstEffect gstInertiaEffect
gstBuzzEffect
gstConstraint
gstManipulator gstTranslateManip
gstRotateManip
gstScaleManip
gstSpatialObject
gstSpatialPartition
gstPlane
gstTriPolyMeshBase
gstTriPolyBase
gstTriPoly
gstBinTree
gstTriPolyMesh
GHOST nine node classesGHOST nine node classes
GHOST nine node classes (continued)GHOST nine node classes (continued)
GHOST nine node classes (continued)GHOST nine node classes (continued)
Scene graph exampleScene graph example
y
xz
Head
y
xz
Left Shoulder
y
xz
Right Shouldery
xz
Right Elbow
y x
zLeft Elbow
y
xz
Torso
y
xz
Body
Static scene graph – only separators and geometry nodes as leavesStatic scene graph – only separators and geometry nodes as leaves
GHOST code example:GHOST code example: #include <stdlib.h>#include <stdlib.h>#include <gstBasic.h>#include <gstBasic.h>#include <gstSphere.h>#include <gstSphere.h>#include <gstPHANToM.h>#include <gstPHANToM.h>#include <gstSeparator.h>#include <gstSeparator.h>#include <gstScene.h>#include <gstScene.h>
Main()Main()gstScene *scene = new gstScene;gstScene *scene = new gstScene;gstSeparator *root = new gstSeparator;gstSeparator *root = new gstSeparator;gstSphere *sphere = new gstSphere;gstSphere *sphere = new gstSphere;
Sptere -> setRadius(20);Sptere -> setRadius(20);gstPHANToM *phantom = new gstPHANToM (``PHANToM name``);gstPHANToM *phantom = new gstPHANToM (``PHANToM name``);Root -> addChild(phantom);Root -> addChild(phantom);Root-> addChild(sphere);Root-> addChild(sphere);Scene-> setRoot(root);Scene-> setRoot(root);Scene -> startServoLoop();Scene -> startServoLoop();
While(!scene -> getDoneServoLoop()) While(!scene -> getDoneServoLoop()) // end application by calling scene -> stopServoLoop ();// end application by calling scene -> stopServoLoop ();
Force calculation and dynamicsForce calculation and dynamics
x
y
z (0,0,0)
adapted from Ghost SDK Programmer’s Guide (version 3.1)
Application ProcessApplication Process Haptic ProcessHaptic Process
Scene CreationScene Creation
Collision detectionCollision detectionCollision responseCollision response
Haptic State Haptic State UpdateUpdate
Clean-upClean-up
HapticHapticRenderingRendering
HapticHapticServo loopServo loop
30 f
ps
30 f
ps Scene RenderingScene Rendering
1000 Hz1000 Hz
Collision detection and responseCollision detection and response
The scene graph contains at least one representation of the haptic interface through gstPHANToM node. There can be up to four such nodes (four haptic interfaces in one haptic scene)
Collisions are detected between this node and the geometry nodes through the gstShape node that goes from “untouched” to “touched”;
When collision exists, the gstPHANToM_SCP (surface contact point) is added to the scene graph. This node should be added to the scene graph under the same parent as gstPHANToM node.
Collision detection and responseCollision detection and response
Normal ForceNormal Force (depends on spring(depends on springand damper coefficients)and damper coefficients)
Friction ForceFriction Force (depends on static and dynamic (depends on static and dynamic friction coefficients)friction coefficients)
Forces are calculated following collision;
Collision response through dynamic effects (movable nodes, solid body dynamics);
Application informed if needed (user defined).
Dynamic nodesDynamic nodes
The gstDynamic node adds movement ability to the geometry nodes beneath it. A subtree under a gstDynamic node represents one physically dynamic object.
Forces generated by gstPHANToM node colliding with one of the geometries of such object are added to the state of the gstDynamic node
Transformations (rotations, translations) are always applied to the gstDynamic node, not its children;
It has four derived classes gstDial, gstButton, gstSlider and gstRigidBody.
Dynamic nodes (continued)Dynamic nodes (continued) When a gstDynamic node changes state, an event is generated which calls a user-defined callback function.
Example – the application may quit if a gstButton changes state from pressed to released.
gstButton gstButton behavioral examplebehavioral example
Updating the applicationUpdating the application
x
y
z (0,0,0)
adapted from Ghost SDK Programmer’s Guide (version 3.1)
Application ProcessApplication Process Haptic ProcessHaptic Process
Scene CreationScene Creation
Collision detectionCollision detectionCollision responseCollision response
Haptic State Haptic State UpdateUpdate
Clean-upClean-up
HapticHapticRenderingRendering
HapticHapticServo loopServo loop
30 f
ps
30 f
ps Scene RenderingScene Rendering
1000 Hz1000 Hz
Graphics and event callbacksGraphics and event callbacks The user selects which nodes have call-back functions, and what information needs to be sent back to the application;
This way the application calls updateGraphics to have graphics information updated. Nodes that have a graphics call-back defined, and have a new state since the last call to updateGraphics will copy their current state to a defined data structure
Call-backs pass new state information of the haptic scene nodes from GHOST haptics process to the application process;
For example, the user can create a callback for the graphics representation of the position of the gstPHANToM node. This should change to callback of gstPHANToM_SCP after collision, so the user can see the location of the contact point on the object.
Mapping the user to the haptic scene Mapping the user to the haptic scene
Phantom workspacePhantom workspace
User workspaceUser workspace
Camera mapping to PHANToM workspaceCamera mapping to PHANToM workspace
Camera
Phantom workspace
z-axis
Phantom
workspac
e
Camera
Phantom
workspac
e
phantomSepphantomSepTransform M Transform M rotationrotation
phantomSepphantomSepTransform M Transform M cameracamera
phantomSepphantomSepTransform M Transform M zaxisOffsetzaxisOffset
from Ghost SDK Programmer’s Guide (version 3.1)
Scaling camera and PHANToM workspacesScaling camera and PHANToM workspaces
Camera workspaceCamera workspacetoo largetoo large
Camera workspaceCamera workspacetoo smalltoo small
Camera workspace Camera workspace appropriateappropriate
Camera
Phantom workspace
Camera
Phantom workspace
Camera
Phantom workspace
Scaling camera and PHANToM workspacesScaling camera and PHANToM workspaces
Camera
Dxmax Dphantomxmax
The scale factor depends on the distance Dxmax from the focal point to the frustum
The distance Dphantomxmax from the non-scaled PHANTOM workspace center to the side limit must also be determined
The scale factor is then Sfrustum=Dxmax/Dphantomxmax
Scaling camera and PHANToM workspacesScaling camera and PHANToM workspaces
To maintain haptic fidelity, the gstShape node physical properties (compliance and damping) need to be scaled too;
SurfaceKspringnew = SurfaceKspringcurrent/Sfrustum
SurfaceKdampingnew = SurfaceKdampingcurrent/Sfrustum
where SurfaceKspring and SurfaceKdamping are gstShape compliance and damping coefficients.
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapterName Appl Prgm
modeProprietary
Language
Java3D
(Sun Micro)
General Purpose
text no Implemented in C
Programming in Java
Vizard Toolkit
and PeoplePak WorldViz
General Purpose
Text/
graph
yes OpenGL-based Python
scripting language
GHOST (SensAble Technologies)
Haptics for Phantom
text yes C++C++
H3DH3D Haptics/Haptics/
GraphicsGraphics
texttext nono C++C++
PeopleShop
(Boston Dynamics)
Military/
civilian
graph yes C/C++C/C++
Unity 3D Game engine
Text/
graph
yes JavaScript, C#,
and Python
SenseGraphics
Founded in 2004 in Stockholm SenseGraphics represents over twenty years of
experience in the haptics and graphics industry. SenseGraphics provides a high performance
application development platform which enables integration of haptics and 3D stereo visualization into multimodal software applications
What is H3D API?What is H3D API?
Product of SenseGraphics Software development platform for multi-
sensory applications Uses the open standards X3D, OpenGL and
SenseGraphics haptics in a unified scenegraph taking care of both the haptic and graphic rendering
What it doesWhat it does
Combines graphics and haptics into one platform. Adds haptics to existing 3D models. Enables rapid programming of haptic applications
using X3D and Python. Easily extended with custom graphics-haptics
features using C++.
Continued
Supports SensAble, Novint and MOOG FCS haptic devices.
Supports most 3D stereo display systems.
Runs on Windows, Linux and Mac.
H3DAPI ArchitectureH3DAPI Architecture
Some H3D nodesSome H3D nodes
Example CodeExample Code
Results of codeResults of code
ApplicationsApplications
Computer Assisted Radiology & Surgery Switzerland (CARCAS)
Application Cont’d University of Virginia
http://www.youtube.com/watch?v=mrMsb71ZJ1I
Other Applications and Projects
Why H3DAPI over Ghost?Why H3DAPI over Ghost?
H3D is compatible with many scene-graph and 3D environment generating platforms. (VRML, X3D, Java3D, OpenGL)
Uses C++ and Python scripting language. You get support haptics devices from several
manufacturers. H3D provides graphic renderings while ghost needs
another program. (Cortona 3D)
References
http://www.sensegraphics.com/index.php http://www.h3dapi.org/ http://www.devmaster.net/forums/showthread.php?
t=2236 http://www.carcas.ch/ http://www.vrac.iastate.edu/~charding/Research/
Haptics.html http://www.sys.virginia.edu/ggerling/facilities.htm
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapter
Name Appl Prgm mode
Proprietary
Language
Java3D
(Sun Micro)
General Purpose
text no Implemented in C
Programming in Java
Vizard Toolkit
and PeoplePak WorldViz
General Purpose
Text/
graph
yes OpenGL-based Python
scripting language
GHOST (SensAble Technologies)
Haptics for Phantom
text yes C++C++
H3D Haptics/
Graphics
text no C++C++
PeopleShopPeopleShop
(Boston Dynamics)(Boston Dynamics)
Military/Military/
civiliancivilian
graphgraph yesyes C/C++C/C++
Unity 3D Game engine
Text/
graph
yes JavaScript, C#,
and Python
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapterName Application Proprietary Library size language
Java3D
(Sun Microsystems)
General Purpose no Implemented in CImplemented in C
Programming in JavaProgramming in Java
19 packages, 275 classes19 packages, 275 classes
Vizard and
PeoplePak (WorldViz)
General Purpose
avatar extension
yes OpenGL-based
Python scripting language
GHOST (SensAble Technologies)
Haptics for Phantom
yes C++C++
PeopleShop
(Boston Dynamics)
Military/civilian yes C/C++C/C++
3DGame Studio Game engine yes C++C++
BDI PeopleShop/DI-Guy characteristicsBDI PeopleShop/DI-Guy characteristics Provides a realistic way to simulate human characters in real-time scenes without using tracking suits;
Is a task-level programming environment combined with a menu-based GUI;
Tasks are mapped to pre-defined (stored) joint motions which are interpolated in real time;
Well-suited for Distributed Interactive Simulations (DIS) due to low bandwidth requirements and live reckoning;
Initially designed for the military, now extended to civilian applications, such as accident reenactment, architectural walk-through, driving simulators, police training, etc.
BDI PeopleShop/DI-Guy characteristics - continuedBDI PeopleShop/DI-Guy characteristics - continued
Linkable object library that runs on SGI, Intel PCs, as well as other platforms;
The library has modules for run-time motion engines, graphics display, motion data, 3D graphics models, textures, and network interfaces for DIS;
Runs under OpenGL, Direct3D, Mak Stealth and other packages;
Recommended hardware is Intel > 200MHz, 64 MB Ram, and graphics accelerator (for Open GL, OpenGVS or Direct3D).
PeopleShop PeopleShop InitiationInitiation
Scene GeometryScene Geometry
Define Define sensorssensors
Define Define behaviorbehavior
Define character Define character pathpath
Define networkingDefine networking
PeopleShop PeopleShop InitiationInitiation
Scene GeometryScene Geometry
Define Define sensorssensors
Define Define behaviorbehavior
Define character Define character pathpath
Define networkingDefine networking
PeopleShop Characters PeopleShop Characters
Are articulated polygonal structures with 54 DOF and 11 links;
Vehicles are also treated as characters;
Different types of characters have different acceptable actions;
Each type of character has different user-selectable appearances (ex. Character vehicle can be a tank or a police car, etc.);
Characters are textured to increase realism and reduce polygonal count
Character selectionCharacter selection
Character type determines acceptable actions (menu selectable)
Appearance selectionAppearance selection
Bob_shorts Bob_shorts Joe_blue Joe_blue Bridget_skirt Bridget_skirt Diane_teen Diane_teen
Character appearance (menu selectable)
BDI ToolkitsBDI Toolkits
Character level-of-detail segmentation based on distance to virtual camera improves real-time performance (up to about 100 characters can be in a scene)
38 polygons38 polygons
2500 polygons2500 polygons
Supplemental bdi.DI-Guy-LOD.mpg
PeopleShop PeopleShop InitiationInitiation
Scene GeometryScene Geometry
Define Define sensorssensors
Define Define BehaviorBehavior
Define character Define character pathpath
Define networkingDefine networking
PeopleShop path specificationPeopleShop path specification
PathPath
WaypointWaypoint
SlopeSlopeAdjuster Adjuster
Initial pathInitial path Extended pathExtended path Added waypointAdded waypoint
BDI ToolkitsBDI Toolkits
Action Action beadbead
End End bead bead
Stacked action Stacked action beadsbeads
Last action bead Last action bead
Editing actionsEditing actions
VC 6.6
on book CD
VC 6.5
on book CD
PeopleShop PeopleShop InitiationInitiation
Scene GeometryScene Geometry
DefineDefinesensorssensors
Define Define behaviorbehavior
Define character Define character pathpath
Define networkingDefine networking
BDI ToolkitsBDI ToolkitsSensor boundarySensor boundary
When soldier A enters the sensor volume, the system is notified – this triggers soldier B’s shooting of A
Soldier ASoldier A
Soldier Soldier BB
PeopleShop sensorsPeopleShop sensors
Sensors are user-defined volumes in space that detect when a character enters them
(PeopleShop User’s Manual)
Sensor boundarySensor boundary
Supplemental
bdi.farmhouse.mpg
PeopleShop PeopleShop InitiationInitiation
Scene GeometryScene Geometry
Define Define sensorssensors
Define Define behaviorbehavior
Define character Define character pathpath
Define networkingDefine networking
PeopleShop BehaviorsPeopleShop Behaviors Behaviors can be reflex (based on signals received from sensors); Behaviors can also be specified with decision beads; Decision beads can be placed on the character’s path (colored red); The two parameters characterizing a decision bead are distance and length; Distance specifies how far from the start of the path the decision Bead is placed; Length indicates the distance from the beginning of the decision region that the decision bead is active; Decisions can be converted to script:
BDI ToolkitsBDI ToolkitsDecision clauses (IF/THEN/ELSE)
PeopleShop PeopleShop Run-timeRun-time
PeolpeShop PeolpeShop InitiationInitiation
Interactive TrainingInteractive Training Immersive TrainingImmersive TrainingScenario VisualizationScenario Visualization
User(s)User(s) User(s)User(s)User(s)User(s)
PeopleShop Run-timePeopleShop Run-time
PeolpeShop PeolpeShop InitiationInitiation
Interactive TrainingInteractive Training Immersive TrainingImmersive TrainingScenario VisualizationScenario Visualization
User(s)User(s) User(s)User(s)User(s)User(s)
BDI PeopleShop ToolkitBDI PeopleShop Toolkit
User is interacting in real time with the simulation using a joystick or mouseand menu. Limited control and immersion. Natural speeds should not be
exceeded.(from Koechling et al., 1997)
VC 6.7
PeopleShop PeopleShop Run-timeRun-time
PeolpeShop PeolpeShop InitiationInitiation
Interactive TrainingInteractive Training Immersive TrainingImmersive TrainingScenario VisualizationScenario Visualization
User(s)User(s) User(s)User(s)User(s)User(s)
BDI PeopleShop – Run time modesBDI PeopleShop – Run time modes
User is interacting in real time with the simulation using a trackers and sensors.Control is at the joint level and immersion is increased.
Omni-directional treadmillOmni-directional treadmill
Sensorized weaponSensorized weapon
(BDI, 1997)
PeopleShop PeopleShop InitiationInitiation
Scene GeometryScene Geometry
Define Define sensorssensors
Define Define behaviorbehavior
Define character Define character pathpath
Define networkingDefine networking
PeopleShop Networking PeopleShop Networking
Updating human figures in DIS is much more bandwidth expensive than vehicles;
Vehicles have few degrees of freedom, while a human figures with 40 joints updated at 20 Hz require 800 packets/sec.;
Instead of updating every joint, PeopleShop only updates at the task level (action, position, velocity). It requires about two packets/sec to produce a smooth simulation;
Works well for large number of participants such as in dismounted infantry training.
Uses “live reckoning” vs. dead reckoning used previously for vehicles
BDI ToolkitsBDI ToolkitsClassical DIS using dead reckoningClassical DIS using dead reckoning
(from Koechling et al., 1997)
BDI ToolkitsBDI Toolkits DIS using live reckoning and human-in-the-loopDIS using live reckoning and human-in-the-loop
DI-Guy modelDI-Guy model DI-Guy modelDI-Guy model
Task-level change Task-level change (action, orientation, velocity)(action, orientation, velocity)
(from Koechling et al., 1997)
PeopleShop “Top Gun” PeopleShop “Top Gun” (courtesy Boston Dynamics Inc.)(courtesy Boston Dynamics Inc.)
VR Toolkits discussed in this chapterVR Toolkits discussed in this chapter
Name Appl Prgm mode
Proprietary
Language
Java3D
(Sun Micro)
General Purpose
text no Implemented in C
Programming in Java
Vizard Toolkit
and PeoplePak WorldViz
General Purpose
Text/
graph
yes OpenGL-based Python
scripting language
GHOST (SensAble Technologies)
Haptics for Phantom
text yes C++C++
H3D Haptics/
Graphics
text no C++C++
PeopleShop
(Boston Dynamics)
Military/
civilian
graph yes C/C++C/C++
Unity 3DUnity 3D Game Game engineengine
Text/Text/
graphgraph
yesyes JavaScript, C#, JavaScript, C#,
and Python and Python
Game Engine ComparisonGame Engine ComparisonUnity UDK/Unreal DX Studio Java3D jMonkeyEngine
Price Free / $1500 Free / $$$Free /
$800Free Free
Graphical Editing Yes Yes Yes No Minimal
Plugin required? Web only No Yes JVM JVM
Language SupportMono (C#)JavaScript
Boo (Python)UnrealScript JavaScript Java Java
External Library Support Yes Yes Yes Yes Yes
Home Computer DeploymentPCMac
PC PCPCMacLinux
PCMacLinux
Web Deployment Yes No Yes WebStart WebStart
Game Console Deployment(Licenses Required)
XBox360+ArcadeWii+WiiWare
PS3
XBox360+Arcade
PS3Sony NGP
No No No
Mobile Deployment iOS / Android iOS / Android Android No No
Why not Java3D?Why not Java3D? Advantages Open source cross-platform development. Low-level control of scene graph and objects. Can be used with other Java and native libraries.
Disatvantages Scene manipulation done strictly through source, leads to
slow turnaround. Higher level control is up to the programmer. 3D sound very buggy. Community support only, no longer any commercial
support.
Why Unity?Why Unity?
Unity
Price Free / $1500
Graphical Editing Yes
Plugin required? Web only
Language SupportMono (C#)JavaScript
Boo (Python)
External Library Support Yes
Home Computer DeploymentPCMac
Web Deployment Yes
Game Console Deployment(Licenses Required)
XBox360+Arcade
Wii+WiiWarePS3
Mobile Deployment iOS / Android
•Free edition offers robust development environment and educational licenses available.
•Supports multiple programming languages to design and manipulate the scene.
•External library and .Net support allows seamless communication with additional hardware devices.
•Easy-to-use graphical interface allows live scene editing for efficient development and testing.
•Quick turnaround times.
•Works on almost all available platforms.
Unity - Physics EngineUnity - Physics Engine Unity uses NVIDIA’s PhysX Engine. Streamlined physics modeling for rigid bodies, cars,
character ragdolls, soft bodies, joints, and cloths. By simply attaching a rigid body to a game object and
adding forces, realistic physical interactions can be created.
Objects with rigid bodies attached will interact with each other.
Colliders are used to control these object interactions and trigger collision events.
Unity GalleryUnity Gallery
Unity - GUIUnity - GUIInspectorInspector
Project PanelProject Panel
Scene HierarchyScene Hierarchy
Unity – Project PanelUnity – Project Panel This panel shows all of the available game assets in the
current project directory. Game assets can include scripts, prefabs, 3D models,
texture images, sound files, fonts, etc… New assets can be added by simply dragging them into
the project panel or placing them into the project directory.
These files can be edited and saved using external programs and the scene will be updated automatically.
Unity supports a number of 3D model formats and converts to the Autodesk FBX format when added to the project.
Unity - Scene HierarchyUnity - Scene Hierarchy Provides a means of adding new game objects and
managing existing ones. Game objects can contain a combination of transforms,
graphics objects, physics colliders, materials, sounds, lights, and scripts.
Each game object in the hierarchal tree represents a node in the scene graph.
Similarly to VRML and Java3D, the scene graph represents the relative spatial relationship of objects. Example: A finger connected to a hand will translate accordingly when the hand is moved.
Unity - Simple Hierarchy ExampleUnity - Simple Hierarchy Example
Unity - InspectorUnity - Inspector Shows the components attached to currently selected
game object and their properties. Manual control over an object’s transform allows precise
placement of objects. Variables exposed by scripts attached to the object can be
viewed and set through this panel, allowing parameters to be changed without the need to edit source.
These changes can be done while the project is live and the scene will update immediately.
Defines spatial properties (Transformation matrix)
Script to destroy object after N collisions or after elapsed
time. Contains particle emitter for explosion effect.
Sound associated with this object.
Controls physics and physical interactions.
Graphics mesh, this is what you will actually see.
Unity - Simple Game ObjectUnity - Simple Game Object
Unity - GUIUnity - GUI
ConsoleConsole
Game PreviewGame PreviewScene EditorScene Editor
Unity - Scene EditorUnity - Scene Editor
Allows graphical monitoring and manipulation of scene objects.
Switch between various orthogonal and perspective views.
Objects can be translated, rotated, and scaled graphically with the mouse.
When live, the editor works like a sandbox in which you can play around with objects without actually modifying the scene.
Shows “Gizmos” for invisible scene objects, such as light sources, colliders, cameras, and sound effects.
Unity - Simple JavaScript ExampleUnity - Simple JavaScript Example Public variables are exposed to the editor, allowing monitoring and editing of
the live scene. This also allows for communication between objects. The Update() method is called at every frame. In this example, every time the left-mouse button is clicked (1) a copy of the
input object is created and added to the scene in front of the camera (2), the cube counter is increased (3), a randomly colored material is used (4), and a force is applied (5). This gives the appearance that the object is being launched away from you.
(2)
(4)(5)
(1)
(3)
Unity - Complex SceneUnity - Complex Scene
Unity - Asset StoreUnity - Asset Store A marketplace to buy
and sell assets used within Unity.
This includes 3D models, textures, scripts, etc…
Can be used to drastically reduce development time, or sell assets you have created.
Unity - Union MarketplaceUnity - Union Marketplace Similar to Apple’s App Store, this is a
marketplace in which games can be sold for various platforms.
Allows developers to reach out to markets that would be otherwise inaccessible.
70% of profits go to the developer while 30% goes to Union.
Unity - VR ApplicationsUnity - VR Applications
Unity is able to use .Net libraries and external shared libraries.
This enables the use of nearly any hardware device within Unity applications.
Cameras can be used to create augmented reality.
Unity - AR on IPhoneUnity - AR on IPhone
Unity on iPhoneUnity on iPhone