My Project
Public Member Functions | List of all members
ParaEngine::CEnvSimClient Class Reference

this is the environment simulator of a standard game world server. More...

#include <EnvSimClient.h>

Inheritance diagram for ParaEngine::CEnvSimClient:
ParaEngine::IEnvironmentSim ParaEngine::ICharacterTrackerContainer

Public Member Functions

virtual SIMULATOR_TYPE GetSimulatorType ()
 return the current type of simulator. More...
 
virtual void Animate (double dTimeDelta)
 called each frame to simulate the game world. More...
 
virtual void CheckLoadPhysics (const D3DXVECTOR3 &vCenter, float fRadius)
 when this function is called, it ensures that the physics object around an object is properly loaded. More...
 
virtual void Release ()
 delete this object. More...
 
virtual CNetTimeGetNetTime ()
 get the net time object More...
 
bool SendNormalUpdate (const string &id, NPL::CBitStream *s)
 send normal update information to a given client. More...
 
void OnReceiveNormalUpdate (const string &id, NPL::CBitStream *s)
 called when received normal update messages from a given client. More...
 
bool SendCharacterUpdate (CBipedObject *pChar, CCharacterTracker *pCharTracker, NPL::CBitStream *s, const char *sIdentifier=NULL)
 send a block for just a single character. More...
 
IGameObjectReceiveCharacterUpdate (NPL::CBitStream *s, const char *sIdentifier=NULL)
 receive a block of a single character. More...
 
bool NetworkMoveCharacter (CBipedObject *pBiped, const D3DXVECTOR3 &vDest, float fFacing, float fSpeed, float fVerticalSpeed, bool bForceRun, bool bForceWalk)
 move a character. More...
 
void HideTimeoutOPC ()
 search all OPC in the sentient object list and hide them if any of them's LastUpdateTime is smaller than a internally defined value, such as 5 seconds
 
- Public Member Functions inherited from ParaEngine::IEnvironmentSim
virtual void CheckLoadPhysics (CShapeSphere *points, int nPointCount=1)=0
 when this function is called, it ensures that the physics object around one or more points are properly loaded. More...
 
void CheckLoadPhysics (const Vector3 &vCenter, float fRadius)
 

Additional Inherited Members

- Public Types inherited from ParaEngine::IEnvironmentSim
enum  SIMULATOR_TYPE { SIM_TYPE_STANDALONE = 0, SIM_TYPE_SERVER = 1, SIM_TYPE_CLIENT = 2 }
 
- Static Public Member Functions inherited from ParaEngine::IEnvironmentSim
static void EnableLog (bool bWriteLog)
 
static bool IsLogEnabled ()
 

Detailed Description

this is the environment simulator of a standard game world server.

Member Function Documentation

§ Animate()

void CEnvSimClient::Animate ( double  dTimeDelta)
virtual

called each frame to simulate the game world.

Parameters
dTimeDeltain seconds.

time lag more than MAX_SIM_LAG(1) second will be detected by the environment simulator

advance the game time

Check load physics around the current player and the camera position this is very game specific. It only ensures that physics object around the current player and camera is loaded.

frame move each unexploded missile objects.

Implements ParaEngine::IEnvironmentSim.

§ CheckLoadPhysics()

void CEnvSimClient::CheckLoadPhysics ( const D3DXVECTOR3 &  vCenter,
float  fRadius 
)
virtual

when this function is called, it ensures that the physics object around an object is properly loaded.

It increases the hit count of these physics objects by 1. The garbage collector in the physics world may use the hit count to move out unused static physics object from the physics scene. This function might be called for the current player, each active mobile object in the scene and the camera eye position.

Parameters
vCenterthe center of the object in world coordinates
fRadiusthe radius of the object within which all physics object must be active.

breadth first transversing the scene(the root tile is ignored) pTile is now the root tile. object attached to it are never rendered directly

add other tiles

rough culling algorithm using the quad tree terrain tiles test against a sphere round the eye

go down the quad tree terrain tile to render objects

even we know that the tile is empty, we still need to see if there is anything in the queueNode for rendering so when both queue are empty, we can exit the main rendering transversing loop

For each mesh physics object in the tile, load its physics.

§ GetNetTime()

virtual CNetTime* ParaEngine::CEnvSimClient::GetNetTime ( )
inlinevirtual

get the net time object

Returns

Reimplemented from ParaEngine::IEnvironmentSim.

§ GetSimulatorType()

virtual SIMULATOR_TYPE ParaEngine::CEnvSimClient::GetSimulatorType ( )
inlinevirtual

return the current type of simulator.

0 means standalone simulator, 1 means server, 2 means client.

Implements ParaEngine::IEnvironmentSim.

§ NetworkMoveCharacter()

bool CEnvSimClient::NetworkMoveCharacter ( CBipedObject pBiped,
const D3DXVECTOR3 &  vDest,
float  fFacing,
float  fSpeed,
float  fVerticalSpeed,
bool  bForceRun,
bool  bForceWalk 
)

move a character.

Parameters
vDestthe absolute solution from the last network.
bForceRunforce using running animation.
bForceWalkforce using walking animation.

§ OnReceiveNormalUpdate()

void CEnvSimClient::OnReceiveNormalUpdate ( const string &  id,
NPL::CBitStream *  s 
)

called when received normal update messages from a given client.

Parameters
idthe id of the player, from which the package is received.
s[in|out] the bit stream from which the data are read.

§ ReceiveCharacterUpdate()

IGameObject * CEnvSimClient::ReceiveCharacterUpdate ( NPL::CBitStream *  s,
const char *  sIdentifier = NULL 
)

receive a block of a single character.

Parameters
s
sIdentifierif this is not NULL, the player ID read from s will be replaced by this one. so it will be this specified character that get updated.
Returns

Group1 if any:

  • If player is not main player, update player in the scene
  • If player is main player, server validation may be included
  • If player is main player, update the main character¡¯s character tracker

set perceptive radius for the character

Group2 if any:

  • If player is not main player, update player in the scene
  • If player is main player, server validation may be included
  • If player is main player, update the main character¡¯s character tracker

in case character model has never been set before

§ Release()

void CEnvSimClient::Release ( )
virtual

delete this object.

Such as Delete this;

Implements ParaEngine::IEnvironmentSim.

§ SendCharacterUpdate()

bool CEnvSimClient::SendCharacterUpdate ( CBipedObject pChar,
CCharacterTracker pCharTracker,
NPL::CBitStream *  s,
const char *  sIdentifier = NULL 
)

send a block for just a single character.

Parameters
pChar
s
sIdentifierif this is not NULL, the player ID of pChar will be replaced by this one.
Returns
true if the successfully sent; false if not send such as the character is not valid.

Header or group0: send if any of the following is true:

  • either group 1 or group2 is changed.
  • The last send time of group0 is older than CLIENT_GROUP0_INTERVAL

Group1: send if any of the following is true:

  • The current player has different group 1 info than the one in the tracker.
  • The last send time of group1 is older than CLIENT_GROUP1_INTERVAL Update send time of the tracker for group1

Group2: send if any of the following is true:

  • The current player has different group 2 info than the one in the tracker.
  • The last send time of group2 is older than CLIENT_GROUP2_INTERVAL Update send time of the tracker for group2

§ SendNormalUpdate()

bool CEnvSimClient::SendNormalUpdate ( const string &  id,
NPL::CBitStream *  s 
)

send normal update information to a given client.

a normal update usually contains the positions of all characters in the given character's perceptive radius. when a client receives such as package, it will use the information to update its local networked characters, as well as itself.

Parameters
idthe id of the player, to which the package is sent.
s[in|out] the bit stream to which the data are written.
Returns
: true if succeed.

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