CObjectModule Class Reference

The module that holds object and scene data of the simulation. It is also responsible for synching it across the server and the client. More...

#include <ObjectModule.h>

Inheritance diagram for CObjectModule:

CModule_Conn CModule CSingleton

List of all members.

Public Member Functions

void Init ()
 Initializes the module.
void Open (Ogre::SceneManager *mgr, const char *bspfile)
void Close ()
 Closes the module for simulation.
void Iterate ()
 Call this at regular intervals for proper functioning.
bool IsServer ()
 Returns whether this module resides in a server application of client application.
void TransmitToAllClients (CPacket *packet)
 Transmits a packet to all clients. Only valid for the server.
void TransmitToServer (CPacket *packet)
 Transmits a packet to the server. Only valid for a client.
string MyName ()
 Returns the network id of this module.
CObjectCreateObject ()
 Creates an object in the simulation and returns it.
CPlayerCreatePlayer ()
 Creates a player in the simulation and returns it.
void Delete (CCommon *obj)
 Deletes an object or a player in the simulation.
CCommonGetById (int id)
CCommonGetByName (string name)
CPlayerGetByUser (string usr)
CPlayerGetMyPlayer ()
 Returns the CPlayer instance controlled by the user of this computer.
CWorldGetWorld ()
 Returns the CWorld instance used by this module.
Ogre::SceneManager * GetSceneManager ()
 Returns the scene manager used that this module is bounded to.
void PlayWav (string filename)
void Play3DWav (string filename, Vector3 position, float attdist)
void MsgToServer (const char *msg)
void MsgToClient (const char *clt, const char *msg)
void MsgToAllClients (const char *msg)
void MsgSetCB (const char *cb)
string MsgGetCB ()
 Gets the name of the lua callback function.
void ResetNext ()
 Resets the enumeration of all of the CCommons in the module. Call this before enumerating the CCommons via Next.
CCommonNext ()
void ResetPlayerUsers ()
 Sets the User property of all of the player to "".
CCommonClone (CCommon *com)
 Clones a CCommon and returns it.
void Stick (CCommon *x, CCommon *y)
void ForceSynch (CCommon *c)
 Synhronizes a CCommon between the server and the client.
bool GetOvermapParameters (Vector3 *pos, float *sizeX, float *sizeY, float *camHeight, float *surfaceDist)
bool HasOvermap ()
 Returns true if there is an overmap for the current map, false if there isn't.
float GetOvermapZ ()
 Returns the Z component of the overmap position.
float GetGravity ()
 Returns the gravitational acceleration in the simulation.
void SetGravity (float grav)
 Sets the gravitational acceleration in the simulation.
void SetSelected (CCommon *obj)
 Selects a CCommon so it is displayed with a bounding box.
CCommonGetSelected ()
 Returns the selected CCommon.
void SelectThroughRay (Ray ray)
 Attempts selection of a CCommon with a ray query considering the overmap.
void SelectThroughRay3D (Ray ray)
 Attempts selection of a CCommon with a ray query considering the scene.
void SetSelectedCB (string cb)
 Sets the name of the lua callback function for selection. See OPSIMUS Scenario Scripting Guide for details.
string GetSelectedCB ()
 Gets the name of the lua callback function for selection. See OPSIMUS Scenario Scripting Guide for details.
void CommandThroughRay (Ray ray)
 Commands with a ray query.
void SetCommandCB (string cb)
 Sets the name of the lua callback function for commands. See OPSIMUS Scenario Scripting Guide for details.
string GetCommandCB ()
 Gets the name of the lua callback function for commands. See OPSIMUS Scenario Scripting Guide for details.
void SetAmbientColor (float r, float g, float b)
 Sets the ambient light. Parameters are red,green,blue respectively. The parameters should be between 0 and 1 inclusively.
void SetLightDirection (int ltno, Vector3 v)
void SetLightColor (int ltno, float r, float g, float b)
void SetLightEnabled (int ltno, bool tf)
void SerializeLight (CPacket *p)
 Serializes the currnet light state in to a packet.
void DeserializeLight (CPacket *p)
 Deserializes the currnet light state from a packet.
void ReceivePacket (CPacket *packet)
 Derived from CModule_Conn::ReceivePacket. Handles packet receiving tasks.
 CObjectModule ()
 Constructor.
void Destroy ()
 Destroys the module.

Static Public Member Functions

static CObjectModuleGetInstance ()
 sub classes should implement this for easy access to self (which is a singleton)

Friends

class CCommon
class CPlayer
class CObject


Detailed Description

The module that holds object and scene data of the simulation. It is also responsible for synching it across the server and the client.

Member Function Documentation

void CObjectModule::Open ( Ogre::SceneManager *  mgr,
const char *  bspfile 
)

Opens the module for simulation.

Parameters:
mgr The scene manager that this module will be bounded to. The scene manager must be loaded with the map.
bspfile The path to the bsp file used by the scene manager.

CCommon* CObjectModule::GetById ( int  id  ) 

Returns the CCommon identified by a specific id.

Parameters:
id The identifier of the CCommon.
Returns:
The CCommon whose GetId() is equal to id.

CCommon* CObjectModule::GetByName ( string  name  ) 

Returns the CCommon whose name is a specific name.

Parameters:
name The name of the CCommon.
Returns:
The CCommon whose GetName() is equal to name.

CPlayer* CObjectModule::GetByUser ( string  usr  ) 

Returns the CPlayer whose user is a specific user.

Parameters:
usr The user of the player.
Returns:
The CPlayer whose GetUser() is equal to usr.

void CObjectModule::PlayWav ( string  filename  ) 

Plays a wav synchronously in both the server and the clients.

Parameters:
filename The name of the wave file.

void CObjectModule::Play3DWav ( string  filename,
Vector3  position,
float  attdist 
)

Plays a wav synchronously in both the server and the clients, but in the 3D environment.

Parameters:
filename The name of the wave file.
position The position to play the wav.
attdist The distance that the wave sound is completely attenuated out in the 3D environment.

void CObjectModule::MsgToServer ( const char *  msg  ) 

Sends a text message to the server. Only valid for client.

Parameters:
msg The text message to send.

void CObjectModule::MsgToClient ( const char *  clt,
const char *  msg 
)

Sends a text message to a client. Only valid for the server.

Parameters:
clt The network id of the client that will receive the message.
msg The text message to send.

void CObjectModule::MsgToAllClients ( const char *  msg  ) 

Sends a text message to all clients. Only valid for the server.

Parameters:
msg The text message to send.

void CObjectModule::MsgSetCB ( const char *  cb  ) 

Sets the name of the lua callback function when a text message is received.

Parameters:
cb The name of the lua callback function. See OPSIMUS Scenario Scripting Guide for details.

CCommon* CObjectModule::Next (  ) 

Returns the next CCommon in the module.

Returns:
The next CCommon in the module. If no more CCommons left, the the return value is NULL.

void CObjectModule::Stick ( CCommon x,
CCommon y 
)

Sticks a CCommon to another preserving their relative orientation and position in space.

Parameters:
x The CCommon whose stick property changes.
y The CCommon who becomes the stick value.

bool CObjectModule::GetOvermapParameters ( Vector3 *  pos,
float *  sizeX,
float *  sizeY,
float *  camHeight,
float *  surfaceDist 
)

Returns the Overmap parameters of the bsp map. See OPSIMUS Scenario Scripting Guide for details.

Parameters:
pos The pointer to the vector that the overmap position will be placed.
sizeX The pointer to the float that will receive the size in X.
sizeY The pointer to the float that will receive the size in Y.
camHeight The pointer to the float that will receive the camera height.
surfaceDist The pointer to the float that will receive the surface distance.
Returns:
Returns true if there is an overmap false if there isn't.

void CObjectModule::SetLightDirection ( int  ltno,
Vector3  v 
)

Sets the direction of one of the directional lights.

Parameters:
ltno The directional light number.
v The direction.

void CObjectModule::SetLightColor ( int  ltno,
float  r,
float  g,
float  b 
)

Sets the colour of one of the directional lights.

Parameters:
ltno The directional light number.
r The red component of the colour. Should be between 0 and 1 inclusively.
g The green component of the colour. Should be between 0 and 1 inclusively.
b The blue component of the colour. Should be between 0 and 1 inclusively.

void CObjectModule::SetLightEnabled ( int  ltno,
bool  tf 
)

Enables or disables one of the directional lights.

Parameters:
ltno The directional light number.
tf Pass true to enable, false to disable the light.


The documentation for this class was generated from the following file:

Generated on Fri Jun 13 19:46:39 2008 for OPSIMUS by  doxygen 1.5.5