]> git.mxchange.org Git - flightgear.git/blobdiff - src/MultiPlayer/mpplayer.hxx
Frederic: MSVC doesn't have stdint.h. I just copied the code found in net_gui.hxx...
[flightgear.git] / src / MultiPlayer / mpplayer.hxx
index 37a9d6eb77f4645ea04e899b29d9c63a233238af..04c5b648ff34920a3265fbdce86e2f733c6ed79f 100644 (file)
 /****************************************************************
 * @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>
@@ -47,9 +52,10 @@ SG_USING_STD(string);
 // 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:
@@ -60,6 +66,12 @@ 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
@@ -71,20 +83,18 @@ public:
     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
@@ -97,9 +107,6 @@ public:
     */
     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
@@ -115,11 +122,17 @@ public:
 
 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;
@@ -130,14 +143,14 @@ private:
     /** 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;