VR-Lab PS-ERT Primer - psert_util
written by pilardi 12/01
last updated by pilardi 12/01
Back to overview
The psert_util is a home grown utility written to make it easier
to develop PS-ERT applications in the VRLab. It is located in the
repository under vrlab/src/libraries/util. ***
It consists of two classes: PSERT and CharWrapper.
PSERT
is used to initialize the PS-ERT library and is meant as a replacement
for the psScenario pointer. CharWrapper is a wrapper
for the psScenarioCharacter class and inherits all methods from
that class.
PSERT class
This class is used to initialize and control the PS-ERT environment.
It is meant to used in place of psScenario pointer. You
can call all psScenario methods from an object of this type (see
sp()
below). See the scenario part of the
primer for a description of the psScenario class.
Constructors
-
PSERT(pfChannel*,pfScene*);
Initializes the scenario and links PS-ERT to Performer. It calls
all the functions listed in "Initialize
PS-ERT" on the overview page.
-
PSERT(pfChannel*,pfScene*,const char* scenario_file);
The same as the other constructor, but loads the given scenario file
as well.
Character related methods
-
CharWrapper*get_char(int character_index);
Returns a pointer to the character with the given index. This
is equivalent to psScenario::get_character_at_index(...) but returns
a (CharWrapper*) instead.
-
CharWrapper*get_char(const char*character_name);
CharWrapper*get_char(const string&character_name);
Returns a pointer to the character with the given name. Analygous
to psScenario::find_character(...).
-
void list_characters();
Prints out the indices, names, and types of the characters loaded into
the scenario.
Other methods
-
psScenario*sp();
Returns the psScenario pointer. You can use this to call psScenario
methods. For example, if psert was the name of your object:
psert.sp()->load("file.pss");
would load file.pss into the scenario.
-
void update(float t);
This method updates the 3dsound position associated with each of the
characters (see CharWrapper below), and calls psScenario::update().
This method should be called once per frame.
CharWrapper class
The CharWrapper class inherits all methods from the psScenarioCharacter
class plus defines the ones listed below. This class should only
be used through a pointer. Use PSERT::get_char(...) to get
a pointer to a character.
See the character part of the primer for
a description of the psScenarioCharacter class.
Movement
-
void move(float x,float y,float z);
Moves the character relative to current position.
-
void turn(float degrees);
Changes characters heading relative to current position.
-
void get_xyz(float xyz[3]);
Gets current position. Similar to get_position, but
fills in an array.
Speech and Sound
An objnum is the index by which the 3dsound utility refers to
objects. Each object has an associated postition. For characters
with associated objnum, the 3dsound positions are set automatically
by the call to PSERT::update(...).
Each 3dsound object (index by objnum) can have multiple associated
sounds (index by sndnum). To associate an objnum
with a character, use set_sound_objnum(...) below, to associate
sounds with an objnum use s3d_obj_init(...) defined in
3dsound.h. See the code
example on the overview page for example usage.
For more on 3dsound see 3dsound.h in the repository under vrlab/src/libraries/utils.
-
void set_sound_objnum(int objnum);
This associates a 3dsound object number (objnum) with the character.
This method must be called for each character that you would like to make
sound. This method must be called before the follow two methods.
-
void play_sound(int sndnum);
Triggers given 3dsound number associated with that character's objnum.
-
void say(const char*phnfile,int sndnum);
Triggers mouth movement (through psScenarioCharacter::say(...))
plus triggers 3dsound.
Combination
-
void setup(float x,float y,float z,float heading,int objnum);
This is a shortcut for calling set_position(...) and
set_sound_objnum(...).