How does a scenario fit into the SPRING framework?

helpflightInternet and Web Development

Nov 10, 2013 (3 years and 8 months ago)

99 views

How does a scenario fit into the SPRING framework?

10
-
August
-
2006


SPRING
initializes
lots of things, including its display environment. In addition, a user
may create an
object
instance of a scenario class, which is then used in the main
processing loop
of SPRING.


SPRING’s core processing is based on the GLUT main loop which:

1.

Calls Display() when needed for drawing objects to the screen

a.

Draws one or two stereo views

b.

Draws 2
-
D view information over the 3
-
D area.

c.

Calls the Draw2D() and Draw3D() functions f
or the current scenario

2.

Calls Keyboard(), Special(), and mouse functions to handle keyboard and mouse
I/O events

3.

Calls Idle() when other events are not being processed


The bulk of SPRING’s processing is done in the Idle() function:

a.

handle voice commands,
if enabled

b.

Update sensor inputs to get 2
-
D, 3
-
D, etc input values

c.

Handle all object “behaviors”, including tool’s effects on tissues
(see below)

d.

If simulation is in the “running” state, perform the simulation operations:

a.

Update all objects in the universe
(see below for more details)

b.

Detect and resolve collisions among objects

c.

Call the Update function for the active scenario


Objects are representations of tissues, tools, and other 3
-
D objects in the SPRING
simulation space. A call to an object’s
Update
()
routine does the following:

1.

Update the position of the object, considering updated transformation data, and
activation information from the input device (e.g., graspers closed.)

2.

Handle the dynamics of the object, including recomputing forces and positions
of
the object’s pieces,

Types are Rigid, Rest, Deformable, Articulate, and Button.


An object’s behaviors are performed in its HandleBehavior() function. This performs
these actions
in HandleInteractiveBehavior()
:

a.

Do special
-
purpose actions depending on
the current behavior of the object.

b.

If attached to a sensor, send information back to the sensor as appropriate,
including haptic feedback.


Objects also may have spontaneous actions,
which
are defin
ed in
HandleSpontaneousBehavior(). These include
beatin
g
and
fluid
motions that are
performed without specific user inputs.



So how does a scenario or game fit into this structure?




A scenario
XYZ
is a subcla
ss of the gameBase class, which provides basic
connections into the SPRING Display and Idle() functio
ns.



The main SPRING program creates an instance of class XYZ, setting it to be the
activeGame object. This object is then referenced in SPRING’s processing.



The
scenario
XYZ
defines an initial set of tissues, tools, and static objects. These
may be creat
ed either in a .DESC file, or progra
mmatically by an initialization
from the XYZ constructor or Initialize() function
.



Initialize() may also define simulation parameters such as collision detection
status, the method used to find collisions,
the visibility
of items, and other
characteristics of the processing to be applied in SPRING’s main loop.



The XYZ instance provides a getName() function, which lets SPRING show a
text string of what scenario is operating.



XYZ’s Initialization may also install user inter
face components such as menu
pulldown lists, items in a menu, a specialized dialog, or other GUI elements.



All 3
-
D objects that the scenario defines are drawn in the normal processing of the
Display() function. Specialized drawing functions may be created
by deriving
from the Object class with an overloaded Draw() class.



XYZ may define a Draw3D() function that create specialized 3
-
D elements that
are to be presented in addition to the standard 3
-
D object drawing.



XYZ may define a Draw2D() function that p
resents specialized information over
the view after all 3
-
D drawing is complete.



The XYZ class may define a handleKeyboard() function which intercepts
keyboard events. The function returns true if the event has been handled by XYZ
class. Otherwise false
is returned.



XYZ may implement Update(), used to perform sce
nario
-
specific processing
based on the objects, collisions, and other information available in the main Idle()
loop. These may include detecting that certain objects have been touched,
grasped, o
r moved. The Update() routine may be set up to maintain a finite state
machine (FSM) that updates its state as in
dividual items change their situations.


For example, the
scenario
may call for grasping and moving 3 spherical objects

from one location to
another. By determining if an object is currently being
grabb
e
d
, the scenario can check something about the state of the scenario.


The scenario can recognize as each object is
touched by a tool, grasped, and
released. The scenario can give feedback abou
t the student’s movements, number
of tries, timing, etc.



Metrics and feedback:

The scenario may implement metrics for each user’s session. A timer is available for
clocki
ng the duration of actions.