An Event Driven Approach to Modelling Object Behaviour

Virtual Reality (vrprj@department-computer-studies.napier.ac.uk)
Thu, 28 Jul 94 11:58:54 BST


An Event Driven Approach to Modelling Object Behaviour

Peter Johnson
First Draft
July 1994

Department of Computer Studies
Napier University, Edinburgh
Craiglockhart Campus
219 Colinton Road
Edinburgh
EH14 1DJ
E-mail: vrprj@uk.ac.napier.dcs

Introduction

This document is a proposed extension to "A File Format
for the Interchange of Virtual Worlds" by Bernie Roehl
and Kerry Bonin, May 1994. It attempts to provide an
interchangeable description of the behaviour of objects.
That is, the actions a user can perform on an object and
the outcome of that action; the semantics of object
interaction.

The basic syntactic form, data types, and conventions
used here are adopted from Roehl and Bonin, thus
providing a seamless level of integration with the
existing language.

Event

An event is some action the user makes with regard to an
object in a virtual world. An event may be associated
with an object through the use of the "Associated_with"
tag.

The "Event_list" is synonymous to a switch (case)
statement with an action being performed on receipt of a
particular event from the user. Each case is optional.
These are:

Selected
The user selected the object.

Unselected
The user unselected the object.

Grabbed
The user grabbed (picked up) the object.

Dropped
The user dropped the object.

Collided
The user walked into the object.

Obj_obj_collision
The object collided with another object.

Default
This takes place if none of the specified
events match the actual event.

A distinction is made between selecting an object and
grabbing an object. For example, consider a light switch.
When the light switch is switched on the "Selected" event
will be posted, but when the user picks up the light
switch the "Grabbed" event will be posted.

The Event has the following format:

Event
{
Name { STRING }
Application_handle { HANDLE }
Associated_with { ID }
Event_list
{
Selected
{
Action { ... }
}
Unselected
{
Action { ... }
}
Grabbed
{
Action { ... }
}
Dropped
{
Action { ... }
}
Collided
{
Action { ... }
}
Obj_obj_collision
{
Action { ... }
}
Default
{
Action { ... }
}
}
}

An Action has the following format:

Action
{
Identifier { ID }
<C like procedure>
}

The identifier is optional and allows us to associate
other entities with the action, e.g. to play a sound when
a object is collided with.

The C like procedure is a subset of the C language
supporting the following:

num <id-name>;
real <id-name>;
boolean <id-name>:
while (<expression>) { ... }
if (<expression>) { ... } else { ... }
<expression>
comment { STRING }
<manipulation-command>

The "else" part of the "if" statement is optional.
The <expression> clause is of the usual C form, e.g.

x == 3.5
x = 3.14 * (0.123 / 180);
y++;
x && y || z

It may be desirable to add a "for" loop construct to this
as well as supporting C like comments. The "comment {
STRING}" construct is provided to maintain consistency
with the rest of the language. The same reasoning may be
applied to the use of "num" and "real" instead of "int"
and "float". It may be necessary to make variables local
to a particular action as well as global to the whole
Event definition. The addition of an array data type may
also be desirable.

The <manipulation-command> statement is used to modify
the object. It may be any of the following:

Translate(REAL REAL REAL )
Use to translate the object by X, Y, Z.

Scale(REAL REAL REAL)
Use to scale the object by X, Y, Z.

Rotate(axis, ANGLE)
Use to rotate the object along the specified
axis, either X, Y, or Z, for the given angle.

Shear(REAL REAL)
Use to shear the object by X, Y.

Color(COLOR)
Change overall color of the object.

Representation { ID }
Specify a new Shape for this object.

The "representation" tag allows us change the shape of
the object by pointing to a new shape description.

Additional manipulation commands may be provided which
allow the individual characteristics of an object to be
modified, such as the texture of a particular facet.

================================================================================

Virtual World Design Project
_/ _/ _/ _/ _/_/_/_/ Napier University
_/ _/ _/ _/ _/ _/ Department of Computer Science
_/ _/ _/ _/ _/ _/ 219 Colinton Road
_/ _/ _/ _/ _/ _/ _/ Edinburgh
_ _/ _/ _/ _/ _/ _/
__/ _/ _/ _/_/_/_/ SCOTLAND

Email: vrprj@uk.ac.napier.dcs

"If you give an infinite number of monkeys an infinite number of graphic design
tools, they will produce something infinitely ugly" (Ben Elton 1993)

================================================================================