/****************************************************************
* @version $Id$
*
-* Description:
+* Description: This class holds information about a player in a
+* multiplayer game. The model for a remote player is loaded and
+* added onto the aircraft branch of the scene on calling Open.
+* The model is unloaded from the scene when Close is called
+* or the object is deleted. The model's positioning transform is
+* updated by calling SetPosition. The updated position transform
+* is applied to the model on the scene by calling Draw.
*
******************************************************************/
#include "mpmessages.hxx"
-#include <plib/ssg.h>
#include <plib/sg.h>
#include <plib/netSocket.h>
#include <simgear/io/sg_socket_udp.hxx>
// Number of seconds before a player is consider to be lost
#define TIME_TO_LIVE 10
-#define PLAYER_DATA_NOT_AVAILABLE 0
-#define PLAYER_DATA_AVAILABLE 1
-#define PLAYER_DATA_EXPIRED 2
+
+class ssgEntity;
+class ssgPlacementTransform;
+
class MPPlayer {
public:
/** Destructor. */
~MPPlayer();
+ /** Enumeration of the states for the player's data */
+ enum PlayerDataState {PLAYER_DATA_NOT_AVAILABLE = 0, PLAYER_DATA_AVAILABLE, PLAYER_DATA_EXPIRED};
+
+ /** Player data state */
+ typedef enum PlayerDataState TPlayerDataState;
+
/** Initialises the class.
* @param sIP IP address or host name for sending data to the player
* @param sPort Port number for sending data to the player
bool Open(const string &sIP, const int &iPort, const string &sCallsign,
const string &sModelName, const bool bLocalPlayer);
- /** Initialises the player count for all instances of this object to zero. */
- static void ResetPlayerCnt(void);
-
/** Closes the player connection */
void Close(void);
/** Sets the positioning matrix held for this player
* @param PlayerPosMat4 Matrix for positioning player's aircraft
*/
- void SetPosition(const sgMat4 PlayerPosMat4);
+ void SetPosition(const sgQuat PlayerOrientation,
+ const sgdVec3 PlayerPosition);
/** Transform and place model for player
*/
- int Draw(void);
+ TPlayerDataState Draw(void);
/** Returns the callsign for the player
* @return Aircraft's callsign
*/
bool CompareCallsign(const char *sCallsign) const;
- /** Loads the model of the aircraft */
- void LoadModel(void);
-
/** Populates a position message for the player
* @param MsgHdr Header to be populated
* @param PosMsg Position message to be populated
private:
+ /** Loads the model of the aircraft */
+ void LoadModel(void);
+
/** True if object is initialised */
bool m_bInitialised;
- /** Position matrix for the player's aircraft */
- sgMat4 m_ModelPos;
+ /** Position of the player's aircraft wrt the earth fixed global system */
+ sgdVec3 m_ModelPosition;
+
+ /** Orientation the player's aircraft wrt the earth fixed global system */
+ sgQuat m_ModelOrientation;
/** Used to remove player if no activity */
time_t m_LastUpdate;
/** Player's callsign */
string m_sCallsign;
- /** Aircraft model for player */
+ /** Aircraft model name for player */
string m_sModelName;
- /** Simgear model selection */
- ssgSelector *m_ModelSel;
+ /** The player's loaded model */
+ ssgEntity *m_Model;
- /** Simgear model transform */
- ssgTransform *m_ModelTrans;
+ /** Model transform */
+ ssgPlacementTransform *m_ModelTrans;
/** True if this player is the local player */
bool m_bLocalPlayer;