Changeset 423

Show
Ignore:
Timestamp:
11/18/11 09:44:14 (6 months ago)
Author:
Carsten
Message:

Model code:
Replaced obsolete class ModelProxyT in the game code with new model class CafuModelT:

  • in the EntCompanyBotT class,
  • in the EntCorpseT class,
  • in the EntHumanPlayerT class,
  • in the CarriedWeaopnT classes.
Location:
cafu/trunk
Files:
56 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/Ca3DE/Both/Ca3DEWorld.cpp

    r419 r423  
    2727#include "ClipSys/TraceSolid.hpp" 
    2828#include "MaterialSystem/Material.hpp" 
     29#include "Models/ModelManager.hpp" 
    2930#include "../../Common/WorldMan.hpp" 
    3031#include "SceneGraph/BspTreeNode.hpp" 
     
    5051      GameEntities(World->GameEntities), 
    5152      ClipWorld(new cf::ClipSys::ClipWorldT(World->CollModel)), 
    52       EntityManager(new EntityManagerT(*this)) 
     53      EntityManager(new EntityManagerT(*this)), 
     54      m_ModelMan(ModelMan) 
    5355{ 
    5456} 
     
    167169    EntityManager->RemoveEntity(EntityID); 
    168170} 
     171 
     172 
     173const CafuModelT* Ca3DEWorldT::GetModel(const std::string& FileName) const 
     174{ 
     175    return m_ModelMan.GetModel(FileName); 
     176} 
  • cafu/trunk/Ca3DE/Both/Ca3DEWorld.hpp

    r419 r423  
    6868    unsigned long                CreateNewEntity(const std::map<std::string, std::string>& Properties, unsigned long CreationFrameNr, const VectorT& Origin); 
    6969    void                         RemoveEntity(unsigned long EntityID); 
     70    const CafuModelT*            GetModel(const std::string& FileName) const; 
    7071 
    7172 
     
    7475    Ca3DEWorldT(const Ca3DEWorldT&);            ///< Use of the Copy Constructor    is not allowed. 
    7576    void operator = (const Ca3DEWorldT&);       ///< Use of the Assignment Operator is not allowed. 
     77 
     78    ModelManagerT& m_ModelMan; 
    7679}; 
    7780 
  • cafu/trunk/Ca3DE/MainCanvas.cpp

    r419 r423  
    409409 
    410410        cf::GameSys::Game->Initialize(true /*(Options_RunMode.GetValueInt() & CLIENT_RUNMODE)>0*/, 
    411                                       true /*(Options_RunMode.GetValueInt() & SERVER_RUNMODE)>0*/); 
     411                                      true /*(Options_RunMode.GetValueInt() & SERVER_RUNMODE)>0*/, 
     412                                      *m_ModelManager); 
    412413 
    413414 
  • cafu/trunk/CaBSP/LoadWorld.cpp

    r419 r423  
    453453                std::string          ErrorMsg; 
    454454                const MapFileModelT& Model=E.MFModels[ModelNr]; 
    455                 const CafuModelT*    CafuM=ModelMan.GetModel(GameDirectory+"/"+Model.Model, ErrorMsg); 
     455                const CafuModelT*    CafuM=ModelMan.GetModel(GameDirectory+"/"+Model.Model, &ErrorMsg); 
    456456 
    457457                if (ErrorMsg!="") Console->Warning(ErrorMsg); 
     
    582582                std::string          ErrorMsg; 
    583583                const MapFileModelT& Model=E.MFModels[ModelNr]; 
    584                 const CafuModelT*    CafuM=ModelMan.GetModel(GameDirectory+"/"+Model.Model, ErrorMsg); 
     584                const CafuModelT*    CafuM=ModelMan.GetModel(GameDirectory+"/"+Model.Model, &ErrorMsg); 
    585585 
    586586                if (ErrorMsg!="") Console->Warning(ErrorMsg); 
  • cafu/trunk/CaWE/GameConfig.cpp

    r415 r423  
    255255{ 
    256256    std::string       Msg; 
    257     const CafuModelT* Model=m_ModelMan.GetModel(std::string(ModDir + "/" + FileName), Msg); 
     257    const CafuModelT* Model=m_ModelMan.GetModel(std::string(ModDir + "/" + FileName), &Msg); 
    258258 
    259259    if (ErrorMsg) 
  • cafu/trunk/Games/DeathMatch/Code/CompanyBot.cpp

    r285 r423  
    3636#include "MaterialSystem/MaterialManager.hpp" 
    3737#include "MaterialSystem/Renderer.hpp" 
     38#include "Models/AnimPose.hpp" 
     39#include "Models/Model_cmdl.hpp" 
    3840 
    3941 
     
    7476                               0,       // ActiveWeaponSequNr 
    7577                               0.0)),   // ActiveWeaponFrameNr 
    76       CompanyBotModel("Games/DeathMatch/Models/Players/Trinity.mdl"), 
    77       TimeForLightSource(0.0f) 
     78      m_CompanyBotModel(Params.GameWorld->GetModel("Games/DeathMatch/Models/Players/Trinity.mdl")), 
     79      m_WeaponModel(Params.GameWorld->GetModel("Games/DeathMatch/Models/Weapons/DesertEagle_p.mdl")), 
     80      m_TimeForLightSource(0.0f) 
    7881{ 
    7982    // Wir könnten im Boden stecken oder darüber schweben - korrigiere entsprechend! 
     
    193196        Physics::MoveHuman(State, ClipModel, FrameTime, VectorT(), VectorT(), false, DummyOldWishJump, 0.0, GameWorld->GetClipWorld()); 
    194197 
    195         State.ModelFrameNr=CompanyBotModel.AdvanceFrameNr(State.ModelSequNr, State.ModelFrameNr, FrameTime, false); 
     198        AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     199        Pose->Advance(FrameTime); 
     200        State.ModelFrameNr=Pose->GetFrameNr(); 
    196201 
    197202        // As we're in "dead" state, the ClipModel is no longer registered with the clip world, 
     
    255260    double NewSpeed=length(XYVel); 
    256261 
    257     State.ModelFrameNr=CompanyBotModel.AdvanceFrameNr(State.ModelSequNr, State.ModelFrameNr, FrameTime, true); 
     262    AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     263    Pose->Advance(FrameTime, true); 
     264    State.ModelFrameNr=Pose->GetFrameNr(); 
    258265 
    259266    if (OldSpeed<1000 && NewSpeed>1000) { State.ModelSequNr=3; State.ModelFrameNr=0.0; } 
     
    303310    if (!HasLight.GetValueBool()) return false; 
    304311 
    305     if (TimeForLightSource<2.0f) 
    306     { 
    307         // 0.0 <= TimeForLightSource < 2.0 
    308         const float         Value=1.0f-0.5f*(1.0f+LookupTables::Angle16ToCos[(unsigned short)(TimeForLightSource/4.0f*65536.0f)]); 
     312    if (m_TimeForLightSource<2.0f) 
     313    { 
     314        // 0.0 <= m_TimeForLightSource < 2.0 
     315        const float         Value=1.0f-0.5f*(1.0f+LookupTables::Angle16ToCos[(unsigned short)(m_TimeForLightSource/4.0f*65536.0f)]); 
    309316        const unsigned long Red  =char(255.0f*Value); 
    310317        const unsigned long Green=char(255.0f*Value*0.9f); 
     
    315322    else 
    316323    { 
    317         // 2.0 <= TimeForLightSource < 6.0 
    318         const float         Value=0.5f*(1.0f+LookupTables::Angle16ToCos[(unsigned short)((TimeForLightSource-2.0f)/4.0f*65536.0f)]); 
     324        // 2.0 <= m_TimeForLightSource < 6.0 
     325        const float         Value=0.5f*(1.0f+LookupTables::Angle16ToCos[(unsigned short)((m_TimeForLightSource-2.0f)/4.0f*65536.0f)]); 
    319326        const unsigned long Green=char(255.0f*(Value*0.8f+0.1f)); 
    320327 
     
    323330    } 
    324331 
    325     const float   Value=LookupTables::Angle16ToCos[(unsigned short)((TimeForLightSource-2.0f)/4.0f*65536.0f)]; 
     332    const float   Value=LookupTables::Angle16ToCos[(unsigned short)((m_TimeForLightSource-2.0f)/4.0f*65536.0f)]; 
    326333    const VectorT RelX =scale(VectorT(LookupTables::Angle16ToCos[State.Heading], LookupTables::Angle16ToSin[State.Heading], 0.0), 80.0*Value); 
    327334    const VectorT RelY =scale(VectorT(LookupTables::Angle16ToSin[State.Heading], LookupTables::Angle16ToCos[State.Heading], 0.0), 500.0); 
     
    342349    MatSys::Renderer->Translate(MatSys::RendererI::MODEL_TO_WORLD, 0.0f, 0.0f, -32.0f); 
    343350 
    344     // Remember that ModelProxyTs are cheap and share resources. 
    345     static ModelProxyT Weapon357("Games/DeathMatch/Models/Weapons/DesertEagle_p.mdl"); 
    346  
    347     CompanyBotModel.Draw(State.ModelSequNr, State.ModelFrameNr, LodDist, &Weapon357); 
     351    AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     352    Pose->Draw(-1 /*default skin*/, LodDist); 
     353 
     354    AnimPoseT* WeaponPose=m_WeaponModel->GetSharedPose(0, 0.0f); 
     355    WeaponPose->SetSuperPose(Pose); 
     356    WeaponPose->Draw(-1 /*default skin*/, LodDist); 
     357    WeaponPose->SetSuperPose(NULL); 
    348358} 
    349359 
     
    352362{ 
    353363    // Implicit simple "mini-prediction". 
    354     State.ModelFrameNr=CompanyBotModel.AdvanceFrameNr(State.ModelSequNr, State.ModelFrameNr, FrameTime, State.ModelSequNr<18 || State.ModelSequNr>24); 
     364    AnimPoseT* Pose=m_CompanyBotModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     365    Pose->Advance(FrameTime, State.ModelSequNr<18 || State.ModelSequNr>24); 
     366    State.ModelFrameNr=Pose->GetFrameNr(); 
    355367 
    356368    // Advance the time for the light source. 
    357     TimeForLightSource+=FrameTime; 
    358     if (TimeForLightSource>6.0f) TimeForLightSource-=4.0f; 
     369    m_TimeForLightSource+=FrameTime; 
     370    if (m_TimeForLightSource>6.0f) m_TimeForLightSource-=4.0f; 
    359371} 
    360372 
  • cafu/trunk/Games/DeathMatch/Code/CompanyBot.hpp

    r285 r423  
    2424 
    2525#include "../../BaseEntity.hpp" 
    26 #include "Models/Model_proxy.hpp" 
    2726#include "btBulletDynamicsCommon.h" 
    2827 
    2928 
     29class CafuModelT; 
    3030class EntityCreateParamsT; 
    3131 
     
    5959    private: 
    6060 
    61     const ModelProxyT CompanyBotModel; 
    62     float             TimeForLightSource; 
     61    const CafuModelT* m_CompanyBotModel; 
     62    const CafuModelT* m_WeaponModel; 
     63    float             m_TimeForLightSource; 
    6364 
    6465    btCollisionShape* m_CollisionShape;     ///< The collision shape that is used to approximate and represent this player in the physics world. 
  • cafu/trunk/Games/DeathMatch/Code/Corpse.cpp

    r285 r423  
    2626#include "Corpse.hpp" 
    2727#include "EntityCreateParams.hpp" 
    28 #include "HumanPlayer.hpp" 
     28#include "GameImpl.hpp" 
    2929#include "TypeSys.hpp" 
    3030#include "MaterialSystem/Renderer.hpp" 
    31 #include "Models/Model_proxy.hpp" 
     31#include "Models/Model_cmdl.hpp" 
    3232 
    3333 
     
    8585    MatSys::Renderer->Translate(MatSys::RendererI::MODEL_TO_WORLD, 0.0f, 0.0f, -32.0f); 
    8686 
    87     EntHumanPlayerT::GetModelFromPlayerModelIndex(State.ModelIndex).Draw(State.ModelSequNr, State.ModelFrameNr, LodDist/*, (State.HaveWeapons & (1 << State.ActiveWeaponSlot)) ? &ModelManager::GetModelByIndex(GetModelIndexPlayerByWeaponSlot[State.ActiveWeaponSlot]) : NULL*/); 
     87    const CafuModelT* Model=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 
     88    AnimPoseT*        Pose =Model->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     89 
     90    Pose->Draw(-1 /*default skin*/, LodDist); 
     91 
     92    if (State.HaveWeapons & (1 << State.ActiveWeaponSlot)) 
     93    { 
     94        // const CafuModelT* WeaponModel=...; 
     95        // AnimPoseT*        WeaponPose =WeaponModel->GetSharedPose(0, 0.0f); 
     96 
     97        // WeaponPose->SetSuperPose(Pose); 
     98        // WeaponPose->Draw(-1 /*default skin*/, LodDist); 
     99        // WeaponPose->SetSuperPose(NULL); 
     100    } 
    88101} 
  • cafu/trunk/Games/DeathMatch/Code/GameImpl.cpp

    r285 r423  
    2323 
    2424#include "cw.hpp" 
     25#include "cw_357.hpp" 
     26#include "cw_9mmAR.hpp" 
     27#include "cw_BattleScythe.hpp" 
     28#include "cw_CrossBow.hpp" 
     29#include "cw_Egon.hpp" 
     30#include "cw_FaceHugger.hpp" 
     31#include "cw_Gauss.hpp" 
     32#include "cw_Grenade.hpp" 
     33#include "cw_Pistol.hpp" 
     34#include "cw_RPG.hpp" 
     35#include "cw_Shotgun.hpp" 
    2536#include "EntityCreateParams.hpp" 
    2637#include "HumanPlayer.hpp" 
     
    2839#include "ScriptState.hpp" 
    2940#include "TypeSys.hpp" 
     41#include "Models/ModelManager.hpp" 
    3042#include "SoundSystem/SoundSys.hpp" 
    3143#include "SoundSystem/SoundShaderManager.hpp" 
     
    7688 
    7789 
    78 void cf::GameSys::GameImplT::Initialize(bool AsClient, bool AsServer) 
    79 { 
     90void cf::GameSys::GameImplT::Initialize(bool AsClient, bool AsServer, ModelManagerT& ModelMan) 
     91{ 
     92    m_PlayerModels.PushBack(ModelMan.GetModel("Games/DeathMatch/Models/Players/Alien.mdl"   )); 
     93    m_PlayerModels.PushBack(ModelMan.GetModel("Games/DeathMatch/Models/Players/James.mdl"   )); 
     94    m_PlayerModels.PushBack(ModelMan.GetModel("Games/DeathMatch/Models/Players/Punisher.mdl")); 
     95    m_PlayerModels.PushBack(ModelMan.GetModel("Games/DeathMatch/Models/Players/Sentinel.mdl")); 
     96    m_PlayerModels.PushBack(ModelMan.GetModel("Games/DeathMatch/Models/Players/Skeleton.mdl")); 
     97    m_PlayerModels.PushBack(ModelMan.GetModel("Games/DeathMatch/Models/Players/T801.mdl"    )); 
     98    m_PlayerModels.PushBack(ModelMan.GetModel("Games/DeathMatch/Models/Players/Trinity.mdl" )); 
     99 
     100    m_CarriedWeapons.PushBack(new CarriedWeaponBattleScytheT(ModelMan)); 
     101    m_CarriedWeapons.PushBack(new CarriedWeapon357T(ModelMan));     // The .357 acts as "dummy" implementation. 
     102    m_CarriedWeapons.PushBack(new CarriedWeaponPistolT(ModelMan)); 
     103    m_CarriedWeapons.PushBack(new CarriedWeapon357T(ModelMan)); 
     104    m_CarriedWeapons.PushBack(new CarriedWeaponShotgunT(ModelMan)); 
     105    m_CarriedWeapons.PushBack(new CarriedWeapon9mmART(ModelMan)); 
     106    m_CarriedWeapons.PushBack(new CarriedWeaponCrossBowT(ModelMan)); 
     107    m_CarriedWeapons.PushBack(new CarriedWeaponRPGT(ModelMan)); 
     108    m_CarriedWeapons.PushBack(new CarriedWeaponGaussT(ModelMan)); 
     109    m_CarriedWeapons.PushBack(new CarriedWeaponEgonT(ModelMan)); 
     110    m_CarriedWeapons.PushBack(new CarriedWeaponGrenadeT(ModelMan)); 
     111    m_CarriedWeapons.PushBack(new CarriedWeapon357T(ModelMan));     // The .357 acts as "dummy" implementation. 
     112    m_CarriedWeapons.PushBack(new CarriedWeaponFaceHuggerT(ModelMan)); 
     113 
    80114    RunningAsClient=AsClient; 
    81115    RunningAsServer=AsServer; 
     
    103137        // but also to effectively load and initialize the models only at that later time, what might be very expensive, too! 
    104138        { 
    105             // Simply loop over all weapon slots for getting all possibly carried weapons, and touch their models. 
    106             for (char cwNr=0; cwNr<13; cwNr++) 
    107             { 
    108                 CarriedWeaponT::GetCarriedWeapon(cwNr)->GetViewWeaponModel(); 
    109                 CarriedWeaponT::GetCarriedWeapon(cwNr)->GetPlayerWeaponModel(); 
    110             } 
    111  
    112             // Simply loop over all possible player models (all valid State.ModelIndex values for EntHumanPlayerTs). 
    113             for (unsigned long pmNr=0; pmNr<7; pmNr++) 
    114                 EntHumanPlayerT::GetModelFromPlayerModelIndex(pmNr); 
    115  
    116139            // And the rest. Observe that static detail models are NOT mentioned (how could they?). 
    117140            static ModelProxyT M01("Games/DeathMatch/Models/Items/Ammo_DartGun.mdl"); 
     
    139162 
    140163        // Precache all sounds known to be used here. 
    141         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Item/PickUp"))); 
    142         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Item/Respawn"))); 
    143         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Ambient/Jungle"))); 
    144         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/DesertEagle_Shot1"))); 
    145         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_GLauncher"))); 
    146         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_Shot1"))); 
    147         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/BattleScythe"))); 
    148         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))); 
    149         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_sBarrel"))); 
    150         PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_dBarrel"))); 
     164        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Item/PickUp"))); 
     165        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Item/Respawn"))); 
     166        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Ambient/Jungle"))); 
     167        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/DesertEagle_Shot1"))); 
     168        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_GLauncher"))); 
     169        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_Shot1"))); 
     170        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/BattleScythe"))); 
     171        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))); 
     172        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_sBarrel"))); 
     173        m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_dBarrel"))); 
    151174    } 
    152175 
     
    167190 
    168191        // Remove reference to precached sounds here. 
    169         for (unsigned long i=0; i<PreCacheSounds.Size(); i++) 
    170             delete PreCacheSounds[i]; 
     192        for (unsigned long i=0; i<m_PreCacheSounds.Size(); i++) 
     193            delete m_PreCacheSounds[i]; 
    171194    } 
    172195 
     
    174197    { 
    175198    } 
     199 
     200    for (unsigned int cwNr=0; cwNr<m_CarriedWeapons.Size(); cwNr++) 
     201        delete m_CarriedWeapons[cwNr]; 
     202 
     203    // for (unsigned int ModelNr=0; ModelNr<m_PlayerModels.Size(); ModelNr++) 
     204    //     delete m_PlayerModels[ModelNr];  // No, don't delete them: they're from the ModelManager! 
    176205} 
    177206 
     
    363392    delete BaseEntity; 
    364393} 
     394 
     395 
     396const CafuModelT* cf::GameSys::GameImplT::GetPlayerModel(unsigned int ModelIndex) const 
     397{ 
     398    return m_PlayerModels[ModelIndex<m_PlayerModels.Size() ? ModelIndex : 0]; 
     399} 
     400 
     401 
     402const CarriedWeaponT* cf::GameSys::GameImplT::GetCarriedWeapon(unsigned int ActiveWeaponSlot) const 
     403{ 
     404    return m_CarriedWeapons[ActiveWeaponSlot<m_CarriedWeapons.Size() ? ActiveWeaponSlot : 3]; 
     405} 
  • cafu/trunk/Games/DeathMatch/Code/GameImpl.hpp

    r285 r423  
    2727 
    2828 
     29class CafuModelT; 
     30class CarriedWeaponT; 
    2931class PhysicsWorldT; 
    3032class SoundI; 
     
    4446 
    4547            // Implement the methods of the GameI interface. 
    46             void Initialize(bool AsClient, bool AsServer); 
     48            void Initialize(bool AsClient, bool AsServer, ModelManagerT& ModelMan); 
    4749            void Release(); 
    4850            void Sv_PrepareNewWorld(const char* WorldFileName, const cf::ClipSys::CollisionModelT* WorldCollMdl); 
     
    5759            void FreeBaseEntity(BaseEntityT* BaseEntity); 
    5860 
     61 
    5962            // Additional methods. 
     63 
     64            /// Maps a player model index to a player model instance. 
     65            /// Used to obtain a player model from a player entities State.ModelIndex member. 
     66            const CafuModelT* GetPlayerModel(unsigned int ModelIndex) const; 
     67 
     68            /// This function returns a pointer to the CarriedWeaponT instance for the desired ActiveWeaponSlot. 
     69            /// When no such class exists, it returns a pointer to an empty dummy implementation 
     70            /// (but for the convenience of the caller, it never returns NULL or an invalid pointer). 
     71            const CarriedWeaponT* GetCarriedWeapon(unsigned int ActiveWeaponSlot) const; 
     72 
    6073            bool IsSvThinking() const { return IsThinking; } 
    6174            ScriptStateT* GetScriptState() const { return ScriptState; } 
     
    7083            GameImplT(); 
    7184 
    72             bool            RunningAsClient; 
    73             bool            RunningAsServer; 
     85            bool                      RunningAsClient; 
     86            bool                      RunningAsServer; 
    7487 
    75             PhysicsWorldT*  Sv_PhysicsWorld; 
    76             PhysicsWorldT*  Cl_PhysicsWorld; 
     88            PhysicsWorldT*            Sv_PhysicsWorld; 
     89            PhysicsWorldT*            Cl_PhysicsWorld; 
    7790 
    78             ScriptStateT*   ScriptState;        ///< Inited on Server load, deleted on Server unload. 
    79             bool            IsThinking;         ///< True while the server is thinking, i.e. between the calls to Sv_BeginThinking() and Sv_EndThinking(). 
     91            ScriptStateT*             ScriptState;      ///< Inited on Server load, deleted on Server unload. 
     92            bool                      IsThinking;       ///< True while the server is thinking, i.e. between the calls to Sv_BeginThinking() and Sv_EndThinking(). 
    8093 
    81             ArrayT<SoundI*> PreCacheSounds;     ///< Array of all precached sounds. 
     94            ArrayT<const CafuModelT*> m_PlayerModels;   ///< The player models available in this game. 
     95            ArrayT<CarriedWeaponT*>   m_CarriedWeapons; ///< The set of carry-able weapons in this game. 
     96            ArrayT<SoundI*>           m_PreCacheSounds; ///< Array of all precached sounds. 
    8297        }; 
    8398    } 
  • cafu/trunk/Games/DeathMatch/Code/HumanPlayer.cpp

    r285 r423  
    3232#include "Constants_WeaponSlots.hpp" 
    3333#include "EntityCreateParams.hpp" 
     34#include "GameImpl.hpp" 
    3435#include "PhysicsWorld.hpp" 
    3536#include "Libs/LookupTables.hpp" 
    3637#include "Libs/Physics.hpp" 
     38 
    3739#include "SoundSystem/SoundSys.hpp" 
    3840#include "../../GameWorld.hpp" 
     
    4648#include "MaterialSystem/Material.hpp" 
    4749#include "MaterialSystem/MaterialManager.hpp" 
    48 #include "Models/Model_proxy.hpp" 
     50#include "Models/AnimPose.hpp" 
     51#include "Models/Model_cmdl.hpp" 
    4952#include "OpenGL/OpenGLWindow.hpp" 
    5053#include "ParticleEngine/ParticleEngineMS.hpp" 
     
    217220        State.Health-=Amount; 
    218221    } 
    219 } 
    220  
    221  
    222 // Maps a player model index to a player model proxy. 
    223 // Used to obtain a player model (ModelProxyT) from State.ModelIndex. 
    224 // Remember that ModelProxyTs are cheap and share resources. 
    225 // Unfortunately, we cannot have a simple global static array for this purpose, 
    226 // because that would initialize the models before the MatSys is initialized! 
    227 // (Otherwise, GetModelFromPlayerModelIndex_[] alone would suffice.) 
    228 ModelProxyT& EntHumanPlayerT::GetModelFromPlayerModelIndex(unsigned long ModelIndex) 
    229 { 
    230     static ModelProxyT GetModelFromPlayerModelIndex_[]= 
    231     { 
    232         ModelProxyT("Games/DeathMatch/Models/Players/Alien.mdl"   ), 
    233         ModelProxyT("Games/DeathMatch/Models/Players/James.mdl"   ), 
    234         ModelProxyT("Games/DeathMatch/Models/Players/Punisher.mdl"), 
    235         ModelProxyT("Games/DeathMatch/Models/Players/Sentinel.mdl"), 
    236         ModelProxyT("Games/DeathMatch/Models/Players/Skeleton.mdl"), 
    237         ModelProxyT("Games/DeathMatch/Models/Players/T801.mdl"    ), 
    238         ModelProxyT("Games/DeathMatch/Models/Players/Trinity.mdl" ) 
    239     }; 
    240  
    241     return GetModelFromPlayerModelIndex_[ModelIndex]; 
    242222} 
    243223 
     
    478458                if (State.HaveWeapons & (1 << State.ActiveWeaponSlot)) 
    479459                { 
    480                     const CarriedWeaponT* CarriedWeapon=CarriedWeaponT::GetCarriedWeapon(State.ActiveWeaponSlot); 
     460                    const CarriedWeaponT* CarriedWeapon=cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot); 
    481461 
    482462                    // Advance the frame time of the weapon. 
    483                     ModelProxyT& WeaponModelView=CarriedWeapon->GetViewWeaponModel(); 
    484  
    485                     const float NewFrameNr      =WeaponModelView.AdvanceFrameNr(State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr, PlayerCommands[PCNr].FrameTime, true); 
     463                    const CafuModelT* WeaponModel=CarriedWeapon->GetViewWeaponModel(); 
     464 
     465                    AnimPoseT* Pose=WeaponModel->GetSharedPose(State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr); 
     466                    Pose->Advance(PlayerCommands[PCNr].FrameTime, true); 
     467 
     468                    const float NewFrameNr=Pose->GetFrameNr(); 
    486469                    const bool  AnimSequenceWrap=NewFrameNr<State.ActiveWeaponFrameNr; 
    487470 
     
    711694 
    712695                // Advance frame time of model sequence. 
    713                 ModelProxyT& PlayerModel=GetModelFromPlayerModelIndex(State.ModelIndex); 
    714  
    715                 State.ModelFrameNr=PlayerModel.AdvanceFrameNr(State.ModelSequNr, State.ModelFrameNr, PlayerCommands[PCNr].FrameTime, true); 
     696                const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 
     697                AnimPoseT*        Pose       =PlayerModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     698 
     699                Pose->Advance(PlayerCommands[PCNr].FrameTime, true); 
     700                State.ModelFrameNr=Pose->GetFrameNr(); 
    716701                break; 
    717702            } 
     
    719704            case StateOfExistance_Dead: 
    720705            { 
    721                 ModelProxyT& PlayerModel     =GetModelFromPlayerModelIndex(State.ModelIndex); 
    722706                bool         DummyOldWishJump=false; 
    723707                const double OldOriginZ      =State.Origin.z; 
     
    747731 
    748732                // Advance frame time of model sequence. 
    749                 State.ModelFrameNr=PlayerModel.AdvanceFrameNr(State.ModelSequNr, State.ModelFrameNr, PlayerCommands[PCNr].FrameTime, false); 
     733                const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 
     734                AnimPoseT*        Pose       =PlayerModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     735 
     736                Pose->Advance(PlayerCommands[PCNr].FrameTime, false); 
     737                State.ModelFrameNr=Pose->GetFrameNr(); 
    750738 
    751739                // We entered this state after we died. 
     
    899887    switch (EventID) 
    900888    { 
    901         case EventID_PrimaryFire  : CarriedWeaponT::GetCarriedWeapon(State.ActiveWeaponSlot)->ClientSide_HandlePrimaryFireEvent  (this, LastSeenAmbientColor); break; 
    902         case EventID_SecondaryFire: CarriedWeaponT::GetCarriedWeapon(State.ActiveWeaponSlot)->ClientSide_HandleSecondaryFireEvent(this, LastSeenAmbientColor); break; 
     889        case EventID_PrimaryFire  : cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot)->ClientSide_HandlePrimaryFireEvent  (this, LastSeenAmbientColor); break; 
     890        case EventID_SecondaryFire: cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot)->ClientSide_HandleSecondaryFireEvent(this, LastSeenAmbientColor); break; 
    903891    } 
    904892} 
     
    977965 
    978966 
    979             ModelProxyT& WeaponModelView=CarriedWeaponT::GetCarriedWeapon(State.ActiveWeaponSlot)->GetViewWeaponModel(); 
    980  
    981             WeaponModelView.Draw(State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr, LodDist); 
     967            const CafuModelT* WeaponModel=cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot)->GetViewWeaponModel(); 
     968            AnimPoseT*        Pose       =WeaponModel->GetSharedPose(State.ActiveWeaponSequNr, State.ActiveWeaponFrameNr); 
     969 
     970            Pose->Draw(-1 /*default skin*/, LodDist); 
    982971        } 
    983972    } 
     
    993982 
    994983        // Draw the own player body model and the "_p" (player) model of the active weapon as sub-model of the body. 
    995         ModelProxyT& PlayerModel=GetModelFromPlayerModelIndex(State.ModelIndex); 
    996  
    997         PlayerModel.Draw(State.ModelSequNr, State.ModelFrameNr, LodDist, (State.HaveWeapons & (1 << State.ActiveWeaponSlot)) ? &CarriedWeaponT::GetCarriedWeapon(State.ActiveWeaponSlot)->GetPlayerWeaponModel() : NULL); 
     984        const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 
     985        AnimPoseT*        Pose       =PlayerModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
     986 
     987        Pose->Draw(-1 /*default skin*/, LodDist); 
     988 
     989        if (State.HaveWeapons & (1 << State.ActiveWeaponSlot)) 
     990        { 
     991            const CafuModelT* WeaponModel=cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot)->GetPlayerWeaponModel(); 
     992            AnimPoseT*        WeaponPose =WeaponModel->GetSharedPose(0, 0.0f); 
     993 
     994            WeaponPose->SetSuperPose(Pose); 
     995            WeaponPose->Draw(-1 /*default skin*/, LodDist); 
     996            WeaponPose->SetSuperPose(NULL); 
     997        } 
    998998    } 
    999999} 
     
    10041004    // Code for state driven effects. 
    10051005    if (State.HaveWeapons & (1 << State.ActiveWeaponSlot)) 
    1006         CarriedWeaponT::GetCarriedWeapon(State.ActiveWeaponSlot)->ClientSide_HandleStateDrivenEffects(this); 
     1006        cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot)->ClientSide_HandleStateDrivenEffects(this); 
    10071007 
    10081008 
     
    11641164    else 
    11651165    { 
    1166         ModelProxyT& PlayerModel=GetModelFromPlayerModelIndex(State.ModelIndex); 
     1166        const CafuModelT* PlayerModel=cf::GameSys::GameImplT::GetInstance().GetPlayerModel(State.ModelIndex); 
     1167        AnimPoseT*        Pose       =PlayerModel->GetSharedPose(State.ModelSequNr, State.ModelFrameNr); 
    11671168 
    11681169        // Implicit simple "mini-prediction". WARNING, this does not really work...! 
    1169         State.ModelFrameNr=PlayerModel.AdvanceFrameNr(State.ModelSequNr, State.ModelFrameNr, FrameTime, State.StateOfExistance!=StateOfExistance_Dead); 
     1170        Pose->Advance(FrameTime, State.StateOfExistance!=StateOfExistance_Dead); 
     1171        State.ModelFrameNr=Pose->GetFrameNr(); 
    11701172    } 
    11711173 
  • cafu/trunk/Games/DeathMatch/Code/HumanPlayer.hpp

    r285 r423  
    3030class EntityCreateParamsT; 
    3131class EntStaticDetailModelT; 
    32 class ModelProxyT; 
    3332namespace cf { namespace GuiSys { class GuiI; } } 
    3433 
     
    3837    public: 
    3938 
    40     static const char EventID_PrimaryFire;                                          // Publicly defined for access from the "carried weapons". 
    41     static const char EventID_SecondaryFire;                                        // Publicly defined for access from the "carried weapons". 
    42  
    43     static ModelProxyT& GetModelFromPlayerModelIndex(unsigned long ModelIndex);     // Publicly defined for access from e.g. the "corpse". 
     39    static const char EventID_PrimaryFire;      // Publicly defined for access from the "carried weapons". 
     40    static const char EventID_SecondaryFire;    // Publicly defined for access from the "carried weapons". 
    4441 
    4542 
  • cafu/trunk/Games/DeathMatch/Code/Weapon357.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_357)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_357)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/Weapon9mmAR.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_9MMAR)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_9MMAR)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponBattleScythe.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_BATTLESCYTHE)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_BATTLESCYTHE)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponCrossbow.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_CROSSBOW)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_CROSSBOW)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponEgon.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_EGON)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_EGON)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponFaceHugger.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_FACEHUGGER)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_FACEHUGGER)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponGauss.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_GAUSS)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_GAUSS)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponGrenade.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_GRENADE)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_GRENADE)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponHornetGun.cpp

    r285 r423  
    2828#include "Constants_WeaponSlots.hpp" 
    2929#include "EntityCreateParams.hpp" 
     30#include "GameImpl.hpp" 
    3031#include "HumanPlayer.hpp" 
    3132#include "TypeSys.hpp" 
  • cafu/trunk/Games/DeathMatch/Code/WeaponPistol.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_PISTOL)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_PISTOL)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponRPG.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_RPG)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_RPG)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponShotgun.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
     
    6465 
    6566    // Give this weapon to the entity. 
    66     if (!CarriedWeaponT::GetCarriedWeapon(WEAPON_SLOT_SHOTGUN)->ServerSide_PickedUpByEntity(Entity)) return; 
     67    if (!cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(WEAPON_SLOT_SHOTGUN)->ServerSide_PickedUpByEntity(Entity)) return; 
    6768 
    6869    // And finally retire for a while. 
  • cafu/trunk/Games/DeathMatch/Code/WeaponTripmine.cpp

    r285 r423  
    2929#include "Constants_WeaponSlots.hpp" 
    3030#include "EntityCreateParams.hpp" 
     31#include "GameImpl.hpp" 
    3132#include "HumanPlayer.hpp" 
    3233#include "TypeSys.hpp" 
  • cafu/trunk/Games/DeathMatch/Code/cw.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /**********************/ 
    23 /*** Carried Weapon ***/ 
    24 /**********************/ 
    25  
    2622#include "cw.hpp" 
    27 #include "cw_357.hpp" 
    28 #include "cw_9mmAR.hpp" 
    29 #include "cw_BattleScythe.hpp" 
    30 #include "cw_CrossBow.hpp" 
    31 #include "cw_Egon.hpp" 
    32 #include "cw_FaceHugger.hpp" 
    33 #include "cw_Gauss.hpp" 
    34 #include "cw_Grenade.hpp" 
    35 #include "cw_Pistol.hpp" 
    36 #include "cw_RPG.hpp" 
    37 #include "cw_Shotgun.hpp" 
    3823 
    3924 
    40 const CarriedWeaponT* CarriedWeaponT::GetCarriedWeapon(char ActiveWeaponSlot) 
     25CarriedWeaponT::CarriedWeaponT(const CafuModelT* ViewModel, const CafuModelT* PlayerModel) 
     26    : m_ViewModel(ViewModel), 
     27      m_PlayerModel(PlayerModel) 
    4128{ 
    42     static CarriedWeapon357T          CarriedWeapon_NONE_DUMMY; 
    43     static CarriedWeapon357T          CarriedWeapon357; 
    44     static CarriedWeapon9mmART        CarriedWeapon9mmAR; 
    45     static CarriedWeaponBattleScytheT CarriedWeaponBattleScythe; 
    46     static CarriedWeaponCrossBowT     CarriedWeaponCrossBow; 
    47     static CarriedWeaponEgonT         CarriedWeaponEgon; 
    48     static CarriedWeaponFaceHuggerT   CarriedWeaponFaceHugger; 
    49     static CarriedWeaponGaussT        CarriedWeaponGauss; 
    50     static CarriedWeaponGrenadeT      CarriedWeaponGrenade; 
    51     static CarriedWeaponPistolT       CarriedWeaponPistol; 
    52     static CarriedWeaponRPGT          CarriedWeaponRPG; 
    53     static CarriedWeaponShotgunT      CarriedWeaponShotgun; 
     29} 
    5430 
    55     static CarriedWeaponT* CarriedWeaponPtrs[13]={ &CarriedWeaponBattleScythe, 
    56                                                    &CarriedWeapon_NONE_DUMMY, 
    57                                                    &CarriedWeaponPistol, 
    58                                                    &CarriedWeapon357, 
    59                                                    &CarriedWeaponShotgun, 
    60                                                    &CarriedWeapon9mmAR, 
    61                                                    &CarriedWeaponCrossBow, 
    62                                                    &CarriedWeaponRPG, 
    63                                                    &CarriedWeaponGauss, 
    64                                                    &CarriedWeaponEgon, 
    65                                                    &CarriedWeaponGrenade, 
    66                                                    &CarriedWeapon_NONE_DUMMY, 
    67                                                    &CarriedWeaponFaceHugger }; 
    6831 
    69     return ActiveWeaponSlot<13 ? CarriedWeaponPtrs[ActiveWeaponSlot] : &CarriedWeapon_NONE_DUMMY; 
     32CarriedWeaponT::~CarriedWeaponT() 
     33{ 
    7034} 
    7135 
  • cafu/trunk/Games/DeathMatch/Code/cw.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /**********************/ 
    23 /*** Carried Weapon ***/ 
    24 /**********************/ 
    25  
    2622#ifndef _CARRIEDWEAPON_HPP_ 
    2723#define _CARRIEDWEAPON_HPP_ 
     
    3329class  EntHumanPlayerT; 
    3430struct PlayerCommandT; 
    35 class  ModelProxyT; 
     31class  CafuModelT; 
     32class  ModelManagerT; 
     33class  SoundI; 
    3634 
    3735 
    38 // The ONLY purpose of this interface is to localize (group) the code and data 
    39 // that is related to a picked-up weapon (carried by an entity). 
    40 // It is intended to simplify the other code (mostly of the human player entity). 
    41 // Don't confuse this with the weapon entities that represent weapons-to-be-picked-up, 
    42 // this code is NOT related to a specific entity! 
     36/// The purpose of this interface is to localize (group) the code and data 
     37/// that is related to a picked-up weapon (carried by an entity). 
     38/// It is intended to simplify the other code (mostly of the human player entity). 
     39/// Don't confuse this with the weapon entities that represent weapons-to-be-picked-up, 
     40/// whereas this code is \emph{not} related to a specific entity! 
    4341class CarriedWeaponT 
    4442{ 
    4543    public: 
    4644 
    47     // This function returns a pointer to the CarriedWeaponT class for the desired ActiveWeaponSlot. 
    48     // When no such class exists, it returns a pointer to an empty dummy implementation 
    49     // (but for the convenience of the caller, it never returns NULL or an invalid pointer). 
    50     static const CarriedWeaponT* GetCarriedWeapon(char ActiveWeaponSlot); 
     45    /// The constructor. 
     46    CarriedWeaponT(const CafuModelT* ViewModel, const CafuModelT* PlayerModel); 
    5147 
    52  
     48    /// The destructor. 
     49    virtual ~CarriedWeaponT(); 
    5350 
    5451    // This function indicates the ammo that this weapon consumes for primary fire. 
     
    6259    // virtual char GetAmmoSlotForSecondaryFire() const; 
    6360 
    64     // This functions returns the model of the VIEW weapon model (1st persons view) of this weapon. 
    65     virtual ModelProxyT& GetViewWeaponModel() const=0; 
     61    /// This functions returns the model of the VIEW weapon model (1st persons view) of this weapon. 
     62    const CafuModelT* GetViewWeaponModel() const { return m_ViewModel; } 
    6663 
    67     // This functions returns the model of the PLAYER weapon model (3rd persons view) of this weapon (as a submodel to the players body model). 
    68     virtual ModelProxyT& GetPlayerWeaponModel() const=0; 
     64    /// This functions returns the model of the PLAYER weapon model (3rd persons view) of this weapon (as a submodel to the players body model). 
     65    const CafuModelT* GetPlayerWeaponModel() const { return m_PlayerModel; } 
    6966 
    7067 
    71  
    72     // This function is to be called when the entity 'Entity' has just picked up this weapon. 
    73     // Returns true if the weapon was successfully given to (picked up by) the entity, false otherwise. 
    74     // Usually called by a weapon entity (that represents the weapon lying around) on detection of touch by a human player. 
     68    /// This function is to be called when the entity 'Entity' has just picked up this weapon. 
     69    /// Returns true if the weapon was successfully given to (picked up by) the entity, false otherwise. 
     70    /// Usually called by a weapon entity (that represents the weapon lying around) on detection of touch by a human player. 
    7571    virtual bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
    7672 
    77     // This functions handles the thinking for this carried weapon. 
    78     // Typically called from within EntHumanPlayerT::Think(). 
     73    /// This functions handles the thinking for this carried weapon. 
     74    /// Typically called from within EntHumanPlayerT::Think(). 
    7975    virtual void ServerSide_Think(EntHumanPlayerT* Player, const PlayerCommandT& PlayerCommand, bool ThinkingOnServerSide, unsigned long ServerFrameNr, bool AnimSequenceWrap) const; 
    8076 
    8177 
    82  
    83     // This function handles the occurance of a "primary fire" event that was received by Entity. 
     78    /// This function handles the occurance of a "primary fire" event that was received by Entity. 
    8479    virtual void ClientSide_HandlePrimaryFireEvent(const EntHumanPlayerT* Player, const VectorT& LastSeenAmbientColor) const; 
    8580 
    86     // This function handles the occurance of a "secondary fire" event that was received by Entity. 
     81    /// This function handles the occurance of a "secondary fire" event that was received by Entity. 
    8782    virtual void ClientSide_HandleSecondaryFireEvent(const EntHumanPlayerT* Player, const VectorT& LastSeenAmbientColor) const; 
    8883 
    89     // Function for handling state (vs. event) driven effects of the weapon of Player, 
    90     // e.g. drawing laser beams, keeping the sound on the weapon sound channel alive, and so on. 
     84    /// Function for handling state (vs. event) driven effects of the weapon of Player, 
     85    /// e.g. drawing laser beams, keeping the sound on the weapon sound channel alive, and so on. 
    9186    virtual void ClientSide_HandleStateDrivenEffects(const EntHumanPlayerT* Player) const; 
    9287 
     
    9590 
    9691 
     92    private: 
    9793 
    98     // The destructor. 
    99     virtual ~CarriedWeaponT() { } 
     94    const CafuModelT* m_ViewModel;      ///< The first-person "view" model of this weapon. 
     95    const CafuModelT* m_PlayerModel;    ///< The third-person "player" model of this weapon. 
    10096}; 
    10197 
  • cafu/trunk/Games/DeathMatch/Code/cw_357.cpp

    r285 r423  
    1919================================================================================= 
    2020*/ 
    21  
    22 /****************************/ 
    23 /*** Carried Weapon - 357 ***/ 
    24 /****************************/ 
    2521 
    2622#include "cw_357.hpp" 
     
    3228#include "Libs/LookupTables.hpp" 
    3329#include "../../GameWorld.hpp" 
    34 #include "Models/Model_proxy.hpp" 
     30#include "Models/ModelManager.hpp" 
    3531#include "ParticleEngine/ParticleEngineMS.hpp" 
    36  
    37  
    38 ModelProxyT& CarriedWeapon357T::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/DesertEagle_v.mdl"); return M; } 
    39 ModelProxyT& CarriedWeapon357T::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/DesertEagle_p.mdl"); return M; } 
     32#include "SoundSystem/SoundSys.hpp" 
     33#include "SoundSystem/SoundShaderManager.hpp" 
     34#include "SoundSystem/Sound.hpp" 
     35 
     36 
     37CarriedWeapon357T::CarriedWeapon357T(ModelManagerT& ModelMan) 
     38    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DesertEagle_v.mdl"), 
     39                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DesertEagle_p.mdl")), 
     40      FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/DesertEagle_Shot1"))) 
     41{ 
     42} 
     43 
     44 
     45CarriedWeapon357T::~CarriedWeapon357T() 
     46{ 
     47    // Release Sound. 
     48    SoundSystem->DeleteSound(FireSound); 
     49} 
    4050 
    4151 
  • cafu/trunk/Games/DeathMatch/Code/cw_357.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /****************************/ 
    23 /*** Carried Weapon - 357 ***/ 
    24 /****************************/ 
    25  
    2622#ifndef _CW_357_HPP_ 
    2723#define _CW_357_HPP_ 
    2824 
    2925#include "cw.hpp" 
    30 #include "SoundSystem/SoundSys.hpp" 
    31 #include "SoundSystem/SoundShaderManager.hpp" 
    32 #include "SoundSystem/Sound.hpp" 
    3326 
    3427 
    35 struct CarriedWeapon357T : public CarriedWeaponT 
     28class CarriedWeapon357T : public CarriedWeaponT 
    3629{ 
    37     CarriedWeapon357T() 
    38         : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/DesertEagle_Shot1"))) 
    39     { 
    40     }; 
     30    public: 
    4131 
    42     ~CarriedWeapon357T() 
    43     { 
    44         // Release Sound. 
    45         SoundSystem->DeleteSound(FireSound); 
    46     } 
    47  
    48     ModelProxyT& GetViewWeaponModel  () const; 
    49     ModelProxyT& GetPlayerWeaponModel() const; 
     32    CarriedWeapon357T(ModelManagerT& ModelMan); 
     33    ~CarriedWeapon357T(); 
    5034 
    5135    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_9mmAR.cpp

    r285 r423  
    1919================================================================================= 
    2020*/ 
    21  
    22 /******************************/ 
    23 /*** Carried Weapon - 9mmAR ***/ 
    24 /******************************/ 
    2521 
    2622#include "cw_9mmAR.hpp" 
     
    3228#include "Libs/LookupTables.hpp" 
    3329#include "../../GameWorld.hpp" 
    34 #include "Models/Model_proxy.hpp" 
     30#include "Models/ModelManager.hpp" 
    3531#include "ParticleEngine/ParticleEngineMS.hpp" 
    36  
    37  
    38 ModelProxyT& CarriedWeapon9mmART::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/9mmAR_v.mdl"); return M; } 
    39 ModelProxyT& CarriedWeapon9mmART::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/9mmAR_p.mdl"); return M; } 
     32#include "SoundSystem/SoundSys.hpp" 
     33#include "SoundSystem/SoundShaderManager.hpp" 
     34#include "SoundSystem/Sound.hpp" 
     35 
     36 
     37CarriedWeapon9mmART::CarriedWeapon9mmART(ModelManagerT& ModelMan) 
     38    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/9mmAR_v.mdl"), 
     39                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/9mmAR_p.mdl")), 
     40      FireSound   (SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_Shot1"))), 
     41      AltFireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_GLauncher"))) 
     42{ 
     43} 
     44 
     45 
     46CarriedWeapon9mmART::~CarriedWeapon9mmART() 
     47{ 
     48    // Release Sound. 
     49    SoundSystem->DeleteSound(FireSound); 
     50    SoundSystem->DeleteSound(AltFireSound); 
     51} 
    4052 
    4153 
  • cafu/trunk/Games/DeathMatch/Code/cw_9mmAR.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /******************************/ 
    23 /*** Carried Weapon - 9mmAR ***/ 
    24 /******************************/ 
    25  
    2622#ifndef _CW_9MMAR_HPP_ 
    2723#define _CW_9MMAR_HPP_ 
    2824 
    2925#include "cw.hpp" 
    30 #include "SoundSystem/SoundSys.hpp" 
    31 #include "SoundSystem/SoundShaderManager.hpp" 
    32 #include "SoundSystem/Sound.hpp" 
    3326 
    3427 
    35 struct CarriedWeapon9mmART : public CarriedWeaponT 
     28class CarriedWeapon9mmART : public CarriedWeaponT 
    3629{ 
    37     CarriedWeapon9mmART() 
    38         : FireSound   (SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_Shot1"))), 
    39           AltFireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_GLauncher"))) 
    40     { 
    41     }; 
     30    public: 
    4231 
    43     ~CarriedWeapon9mmART() 
    44     { 
    45         // Release Sound. 
    46         SoundSystem->DeleteSound(FireSound); 
    47         SoundSystem->DeleteSound(AltFireSound); 
    48     } 
    49  
    50     ModelProxyT& GetViewWeaponModel  () const; 
    51     ModelProxyT& GetPlayerWeaponModel() const; 
     32    CarriedWeapon9mmART(ModelManagerT& ModelMan); 
     33    ~CarriedWeapon9mmART(); 
    5234 
    5335    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_BattleScythe.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /*************************************/ 
    23 /*** Carried Weapon - BattleScythe ***/ 
    24 /*************************************/ 
    25  
    2622#include "cw_BattleScythe.hpp" 
    2723#include "HumanPlayer.hpp" 
    2824#include "Constants_WeaponSlots.hpp" 
    2925#include "Libs/LookupTables.hpp" 
    30 #include "Models/Model_proxy.hpp" 
     26#include "Models/ModelManager.hpp" 
     27#include "SoundSystem/SoundSys.hpp" 
     28#include "SoundSystem/SoundShaderManager.hpp" 
     29#include "SoundSystem/Sound.hpp" 
    3130 
    3231 
    33 ModelProxyT& CarriedWeaponBattleScytheT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/BattleScythe_v.mdl"); return M; } 
    34 ModelProxyT& CarriedWeaponBattleScytheT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/BattleScythe_p.mdl"); return M; } 
     32CarriedWeaponBattleScytheT::CarriedWeaponBattleScytheT(ModelManagerT& ModelMan) 
     33    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/BattleScythe_v.mdl"), 
     34                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/BattleScythe_p.mdl")), 
     35      FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/BattleScythe"))) 
     36{ 
     37} 
     38 
     39 
     40CarriedWeaponBattleScytheT::~CarriedWeaponBattleScytheT() 
     41{ 
     42    // Release Sound. 
     43    SoundSystem->DeleteSound(FireSound); 
     44} 
    3545 
    3646 
  • cafu/trunk/Games/DeathMatch/Code/cw_BattleScythe.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /*************************************/ 
    23 /*** Carried Weapon - BattleScythe ***/ 
    24 /*************************************/ 
    25  
    2622#ifndef _CW_BATTLESCYTHE_HPP_ 
    2723#define _CW_BATTLESCYTHE_HPP_ 
    2824 
    2925#include "cw.hpp" 
    30 #include "SoundSystem/SoundSys.hpp" 
    31 #include "SoundSystem/SoundShaderManager.hpp" 
    32 #include "SoundSystem/Sound.hpp" 
    3326 
    3427 
    35 struct CarriedWeaponBattleScytheT : public CarriedWeaponT 
     28class CarriedWeaponBattleScytheT : public CarriedWeaponT 
    3629{ 
    37     CarriedWeaponBattleScytheT() 
    38         : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/BattleScythe"))) 
    39     { 
    40     }; 
     30    public: 
    4131 
    42     ~CarriedWeaponBattleScytheT() 
    43     { 
    44         // Release Sound. 
    45         SoundSystem->DeleteSound(FireSound); 
    46     }; 
    47  
    48     ModelProxyT& GetViewWeaponModel  () const; 
    49     ModelProxyT& GetPlayerWeaponModel() const; 
     32    CarriedWeaponBattleScytheT(ModelManagerT& ModelMan); 
     33    ~CarriedWeaponBattleScytheT(); 
    5034 
    5135    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_CrossBow.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /*********************************/ 
    23 /*** Carried Weapon - CrossBow ***/ 
    24 /*********************************/ 
    25  
    2622#include "cw_CrossBow.hpp" 
    2723#include "HumanPlayer.hpp" 
     
    3127#include "Libs/LookupTables.hpp" 
    3228#include "../../GameWorld.hpp" 
    33 #include "Models/Model_proxy.hpp" 
     29#include "Models/ModelManager.hpp" 
    3430 
    3531 
    36 ModelProxyT& CarriedWeaponCrossBowT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/DartGun_v.mdl"); return M; } 
    37 ModelProxyT& CarriedWeaponCrossBowT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/DartGun_p.mdl"); return M; } 
     32CarriedWeaponCrossBowT::CarriedWeaponCrossBowT(ModelManagerT& ModelMan) 
     33    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DartGun_v.mdl"), 
     34                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DartGun_p.mdl")) 
     35{ 
     36} 
    3837 
    3938 
  • cafu/trunk/Games/DeathMatch/Code/cw_CrossBow.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /*********************************/ 
    23 /*** Carried Weapon - CrossBow ***/ 
    24 /*********************************/ 
    25  
    2622#ifndef _CW_CROSSBOW_HPP_ 
    2723#define _CW_CROSSBOW_HPP_ 
     
    3026 
    3127 
    32 struct CarriedWeaponCrossBowT : public CarriedWeaponT 
     28class CarriedWeaponCrossBowT : public CarriedWeaponT 
    3329{ 
    34     ModelProxyT& GetViewWeaponModel  () const; 
    35     ModelProxyT& GetPlayerWeaponModel() const; 
     30    public: 
     31 
     32    CarriedWeaponCrossBowT(ModelManagerT& ModelMan); 
    3633 
    3734    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_Egon.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /*****************************/ 
    23 /*** Carried Weapon - Egon ***/ 
    24 /*****************************/ 
    25  
    2622#include "cw_Egon.hpp" 
    2723#include "HumanPlayer.hpp" 
     
    2925#include "Constants_WeaponSlots.hpp" 
    3026#include "Libs/LookupTables.hpp" 
    31 #include "Models/Model_proxy.hpp" 
     27#include "Models/ModelManager.hpp" 
    3228 
    3329 
    34 ModelProxyT& CarriedWeaponEgonT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Egon_v.mdl"); return M; } 
    35 ModelProxyT& CarriedWeaponEgonT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Egon_p.mdl"); return M; } 
     30CarriedWeaponEgonT::CarriedWeaponEgonT(ModelManagerT& ModelMan) 
     31    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Egon_v.mdl"), 
     32                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Egon_p.mdl")) 
     33{ 
     34} 
    3635 
    3736 
  • cafu/trunk/Games/DeathMatch/Code/cw_Egon.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /*****************************/ 
    23 /*** Carried Weapon - Egon ***/ 
    24 /*****************************/ 
    25  
    2622#ifndef _CW_EGON_HPP_ 
    2723#define _CW_EGON_HPP_ 
     
    3026 
    3127 
    32 struct CarriedWeaponEgonT : public CarriedWeaponT 
     28class CarriedWeaponEgonT : public CarriedWeaponT 
    3329{ 
    34     ModelProxyT& GetViewWeaponModel  () const; 
    35     ModelProxyT& GetPlayerWeaponModel() const; 
     30    public: 
     31 
     32    CarriedWeaponEgonT(ModelManagerT& ModelMan); 
    3633 
    3734    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_FaceHugger.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /***********************************/ 
    23 /*** Carried Weapon - FaceHugger ***/ 
    24 /***********************************/ 
    25  
    2622#include "cw_FaceHugger.hpp" 
    2723#include "HumanPlayer.hpp" 
     
    2925#include "Libs/LookupTables.hpp" 
    3026#include "../../GameWorld.hpp" 
    31 #include "Models/Model_proxy.hpp" 
     27#include "Models/ModelManager.hpp" 
    3228#include "ParticleEngine/ParticleEngineMS.hpp" 
     29#include "SoundSystem/SoundSys.hpp" 
     30#include "SoundSystem/SoundShaderManager.hpp" 
     31#include "SoundSystem/Sound.hpp" 
    3332 
    3433 
    35 ModelProxyT& CarriedWeaponFaceHuggerT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/FaceHugger_v.mdl"); return M; } 
    36 ModelProxyT& CarriedWeaponFaceHuggerT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/FaceHugger_p.mdl"); return M; } 
     34CarriedWeaponFaceHuggerT::CarriedWeaponFaceHuggerT(ModelManagerT& ModelMan) 
     35    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/FaceHugger_v.mdl"), 
     36                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/FaceHugger_p.mdl")), 
     37      FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))) 
     38{ 
     39} 
     40 
     41 
     42CarriedWeaponFaceHuggerT::~CarriedWeaponFaceHuggerT() 
     43{ 
     44    // Release Sound. 
     45    SoundSystem->DeleteSound(FireSound); 
     46} 
    3747 
    3848 
  • cafu/trunk/Games/DeathMatch/Code/cw_FaceHugger.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /***********************************/ 
    23 /*** Carried Weapon - FaceHugger ***/ 
    24 /***********************************/ 
    25  
    2622#ifndef _CW_FACEHUGGER_HPP_ 
    2723#define _CW_FACEHUGGER_HPP_ 
    2824 
    2925#include "cw.hpp" 
    30 #include "SoundSystem/SoundSys.hpp" 
    31 #include "SoundSystem/SoundShaderManager.hpp" 
    32 #include "SoundSystem/Sound.hpp" 
    3326 
    3427 
    35 struct CarriedWeaponFaceHuggerT : public CarriedWeaponT 
     28class CarriedWeaponFaceHuggerT : public CarriedWeaponT 
    3629{ 
    37     CarriedWeaponFaceHuggerT() 
    38         : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))) 
    39     { 
    40     }; 
     30    public: 
    4131 
    42     ~CarriedWeaponFaceHuggerT() 
    43     { 
    44         // Release Sound. 
    45         SoundSystem->DeleteSound(FireSound); 
    46     }; 
    47  
    48     ModelProxyT& GetViewWeaponModel  () const; 
    49     ModelProxyT& GetPlayerWeaponModel() const; 
     32    CarriedWeaponFaceHuggerT(ModelManagerT& ModelMan); 
     33    ~CarriedWeaponFaceHuggerT(); 
    5034 
    5135    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_Gauss.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /******************************/ 
    23 /*** Carried Weapon - Gauss ***/ 
    24 /******************************/ 
    25  
    2622#include "cw_Gauss.hpp" 
    2723#include "HumanPlayer.hpp" 
     
    2925#include "Constants_WeaponSlots.hpp" 
    3026#include "Libs/LookupTables.hpp" 
    31 #include "Models/Model_proxy.hpp" 
     27#include "Models/ModelManager.hpp" 
    3228 
    3329 
    34 ModelProxyT& CarriedWeaponGaussT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Gauss_v.mdl"); return M; } 
    35 ModelProxyT& CarriedWeaponGaussT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Gauss_p.mdl"); return M; } 
     30CarriedWeaponGaussT::CarriedWeaponGaussT(ModelManagerT& ModelMan) 
     31    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Gauss_v.mdl"), 
     32                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Gauss_p.mdl")) 
     33{ 
     34} 
    3635 
    3736 
  • cafu/trunk/Games/DeathMatch/Code/cw_Gauss.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /******************************/ 
    23 /*** Carried Weapon - Gauss ***/ 
    24 /******************************/ 
    25  
    2622#ifndef _CW_GAUSS_HPP_ 
    2723#define _CW_GAUSS_HPP_ 
     
    3026 
    3127 
    32 struct CarriedWeaponGaussT : public CarriedWeaponT 
     28class CarriedWeaponGaussT : public CarriedWeaponT 
    3329{ 
    34     ModelProxyT& GetViewWeaponModel  () const; 
    35     ModelProxyT& GetPlayerWeaponModel() const; 
     30    public: 
     31 
     32    CarriedWeaponGaussT(ModelManagerT& ModelMan); 
    3633 
    3734    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_Grenade.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /********************************/ 
    23 /*** Carried Weapon - Grenade ***/ 
    24 /********************************/ 
    25  
    2622#include "cw_Grenade.hpp" 
    2723#include "HumanPlayer.hpp" 
     
    2925#include "Libs/LookupTables.hpp" 
    3026#include "../../GameWorld.hpp" 
    31 #include "Models/Model_proxy.hpp" 
     27#include "Models/ModelManager.hpp" 
     28#include "SoundSystem/SoundSys.hpp" 
     29#include "SoundSystem/SoundShaderManager.hpp" 
     30#include "SoundSystem/Sound.hpp" 
    3231 
    3332 
    34 ModelProxyT& CarriedWeaponGrenadeT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Grenade_v.mdl"); return M; } 
    35 ModelProxyT& CarriedWeaponGrenadeT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Grenade_p.mdl"); return M; } 
     33CarriedWeaponGrenadeT::CarriedWeaponGrenadeT(ModelManagerT& ModelMan) 
     34    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Grenade_v.mdl"), 
     35                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Grenade_p.mdl")), 
     36      FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))) 
     37{ 
     38} 
     39 
     40 
     41CarriedWeaponGrenadeT::~CarriedWeaponGrenadeT() 
     42{ 
     43    // Release Sound. 
     44    SoundSystem->DeleteSound(FireSound); 
     45} 
    3646 
    3747 
  • cafu/trunk/Games/DeathMatch/Code/cw_Grenade.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /********************************/ 
    23 /*** Carried Weapon - Grenade ***/ 
    24 /********************************/ 
    25  
    2622#ifndef _CW_GRENADE_HPP_ 
    2723#define _CW_GRENADE_HPP_ 
    2824 
    2925#include "cw.hpp" 
    30 #include "SoundSystem/SoundSys.hpp" 
    31 #include "SoundSystem/SoundShaderManager.hpp" 
    32 #include "SoundSystem/Sound.hpp" 
    3326 
    3427 
    35 struct CarriedWeaponGrenadeT : public CarriedWeaponT 
     28class CarriedWeaponGrenadeT : public CarriedWeaponT 
    3629{ 
    37     CarriedWeaponGrenadeT() 
    38         : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))) 
    39     { 
    40     }; 
     30    public: 
    4131 
    42     ~CarriedWeaponGrenadeT() 
    43     { 
    44         // Release Sound. 
    45         SoundSystem->DeleteSound(FireSound); 
    46     }; 
    47  
    48     ModelProxyT& GetViewWeaponModel  () const; 
    49     ModelProxyT& GetPlayerWeaponModel() const; 
     32    CarriedWeaponGrenadeT(ModelManagerT& ModelMan); 
     33    ~CarriedWeaponGrenadeT(); 
    5034 
    5135    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_Pistol.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /*******************************/ 
    23 /*** Carried Weapon - Pistol ***/ 
    24 /*******************************/ 
    25  
    2622#include "cw_Pistol.hpp" 
    2723#include "HumanPlayer.hpp" 
    2824#include "Constants_AmmoSlots.hpp" 
    2925#include "Constants_WeaponSlots.hpp" 
    30 #include "Models/Model_proxy.hpp" 
     26#include "Models/ModelManager.hpp" 
    3127 
    3228 
    33 ModelProxyT& CarriedWeaponPistolT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Beretta_v.mdl"); return M; } 
    34 ModelProxyT& CarriedWeaponPistolT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Beretta_p.mdl"); return M; } 
     29CarriedWeaponPistolT::CarriedWeaponPistolT(ModelManagerT& ModelMan) 
     30    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Beretta_v.mdl"), 
     31                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Beretta_p.mdl")) 
     32{ 
     33} 
    3534 
    3635 
  • cafu/trunk/Games/DeathMatch/Code/cw_Pistol.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /*******************************/ 
    23 /*** Carried Weapon - Pistol ***/ 
    24 /*******************************/ 
    25  
    2622#ifndef _CW_PISTOL_HPP_ 
    2723#define _CW_PISTOL_HPP_ 
     
    3026 
    3127 
    32 struct CarriedWeaponPistolT : public CarriedWeaponT 
     28class CarriedWeaponPistolT : public CarriedWeaponT 
    3329{ 
    34     ModelProxyT& GetViewWeaponModel  () const; 
    35     ModelProxyT& GetPlayerWeaponModel() const; 
     30    public: 
     31 
     32    CarriedWeaponPistolT(ModelManagerT& ModelMan); 
    3633 
    3734    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_RPG.cpp

    r285 r423  
    2020*/ 
    2121 
    22 /****************************/ 
    23 /*** Carried Weapon - RPG ***/ 
    24 /****************************/ 
    25  
    2622#include "cw_RPG.hpp" 
    2723#include "HumanPlayer.hpp" 
     
    3026#include "Libs/LookupTables.hpp" 
    3127#include "../../GameWorld.hpp" 
    32 #include "Models/Model_proxy.hpp" 
     28#include "Models/ModelManager.hpp" 
    3329 
    3430 
    35 ModelProxyT& CarriedWeaponRPGT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Bazooka_v.mdl"); return M; } 
    36 ModelProxyT& CarriedWeaponRPGT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Bazooka_v.mdl"); return M; } 
     31CarriedWeaponRPGT::CarriedWeaponRPGT(ModelManagerT& ModelMan) 
     32    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Bazooka_v.mdl"), 
     33                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Bazooka_p.mdl")) 
     34{ 
     35} 
    3736 
    3837 
  • cafu/trunk/Games/DeathMatch/Code/cw_RPG.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /****************************/ 
    23 /*** Carried Weapon - RPG ***/ 
    24 /****************************/ 
    25  
    2622#ifndef _CW_RPG_HPP_ 
    2723#define _CW_RPG_HPP_ 
     
    3026 
    3127 
    32 struct CarriedWeaponRPGT : public CarriedWeaponT 
     28class CarriedWeaponRPGT : public CarriedWeaponT 
    3329{ 
    34     ModelProxyT& GetViewWeaponModel  () const; 
    35     ModelProxyT& GetPlayerWeaponModel() const; 
     30    public: 
     31 
     32    CarriedWeaponRPGT(ModelManagerT& ModelMan); 
    3633 
    3734    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/DeathMatch/Code/cw_Shotgun.cpp

    r285 r423  
    1919================================================================================= 
    2020*/ 
    21  
    22 /********************************/ 
    23 /*** Carried Weapon - Shotgun ***/ 
    24 /********************************/ 
    2521 
    2622#include "cw_Shotgun.hpp" 
     
    3228#include "Libs/LookupTables.hpp" 
    3329#include "../../GameWorld.hpp" 
    34 #include "Models/Model_proxy.hpp" 
     30#include "Models/ModelManager.hpp" 
    3531#include "ParticleEngine/ParticleEngineMS.hpp" 
    36  
    37  
    38 ModelProxyT& CarriedWeaponShotgunT::GetViewWeaponModel  () const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Shotgun_v.mdl"); return M; } 
    39 ModelProxyT& CarriedWeaponShotgunT::GetPlayerWeaponModel() const { static ModelProxyT M("Games/DeathMatch/Models/Weapons/Shotgun_p.mdl"); return M; } 
     32#include "SoundSystem/SoundSys.hpp" 
     33#include "SoundSystem/SoundShaderManager.hpp" 
     34#include "SoundSystem/Sound.hpp" 
     35 
     36 
     37CarriedWeaponShotgunT::CarriedWeaponShotgunT(ModelManagerT& ModelMan) 
     38    : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Shotgun_v.mdl"), 
     39                     ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Shotgun_p.mdl")), 
     40      FireSound   (SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_sBarrel"))), 
     41      AltFireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_dBarrel"))) 
     42{ 
     43} 
     44 
     45 
     46CarriedWeaponShotgunT::~CarriedWeaponShotgunT() 
     47{ 
     48    // Release Sound. 
     49    SoundSystem->DeleteSound(FireSound); 
     50    SoundSystem->DeleteSound(AltFireSound); 
     51} 
    4052 
    4153 
  • cafu/trunk/Games/DeathMatch/Code/cw_Shotgun.hpp

    r285 r423  
    2020*/ 
    2121 
    22 /********************************/ 
    23 /*** Carried Weapon - Shotgun ***/ 
    24 /********************************/ 
    25  
    2622#ifndef _CW_SHOTGUN_HPP_ 
    2723#define _CW_SHOTGUN_HPP_ 
    2824 
    2925#include "cw.hpp" 
    30 #include "SoundSystem/SoundSys.hpp" 
    31 #include "SoundSystem/SoundShaderManager.hpp" 
    32 #include "SoundSystem/Sound.hpp" 
    3326 
    3427 
    35 struct CarriedWeaponShotgunT : public CarriedWeaponT 
     28class CarriedWeaponShotgunT : public CarriedWeaponT 
    3629{ 
    37     CarriedWeaponShotgunT() 
    38         : FireSound   (SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_sBarrel"))), 
    39           AltFireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_dBarrel"))) 
    40     { 
    41     }; 
     30    public: 
    4231 
    43     ~CarriedWeaponShotgunT() 
    44     { 
    45         // Release Sound. 
    46         SoundSystem->DeleteSound(FireSound); 
    47         SoundSystem->DeleteSound(AltFireSound); 
    48     }; 
    49  
    50     ModelProxyT& GetViewWeaponModel  () const; 
    51     ModelProxyT& GetPlayerWeaponModel() const; 
     32    CarriedWeaponShotgunT(ModelManagerT& ModelMan); 
     33    ~CarriedWeaponShotgunT(); 
    5234 
    5335    bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 
  • cafu/trunk/Games/Game.hpp

    r379 r423  
    3030class BaseEntityT; 
    3131template<class T> class Vector3T; 
     32class ModelManagerT; 
    3233namespace cf { namespace ClipSys { class CollisionModelT; } } 
    3334namespace cf { namespace GameSys { class GameWorldI; } } 
     
    5152            /// @param AsClient     Tells whether we're running as client. 
    5253            /// @param AsServer     Tells whether we're running as server. 
    53             virtual void Initialize(bool AsClient, bool AsServer)=0; 
     54            virtual void Initialize(bool AsClient, bool AsServer, ModelManagerT& ModelMan)=0; 
    5455 
    5556            /// Called to shutdown the game. 
  • cafu/trunk/Games/GameWorld.hpp

    r285 r423  
    2525 
    2626class BaseEntityT; 
     27class CafuModelT; 
    2728namespace cf { namespace ClipSys { class ClipWorldT; } } 
    2829 
     
    6667            /// Removes the entity identified by 'EntityID' from the (server) world. 
    6768            virtual void RemoveEntity(unsigned long EntityID)=0; 
     69 
     70            /// Returns a model for the given filename. 
     71            /// The returned model instance is managed by the GameWorldI implementation in a ModelManagerT, 
     72            /// thus the caller does not have to (and if fact, must not) delete the CafuModelT instance. 
     73            virtual const CafuModelT* GetModel(const std::string& FileName) const=0; 
    6874        }; 
    6975    } 
  • cafu/trunk/Libs/GuiSys/GuiImpl.cpp

    r415 r423  
    9999const CafuModelT* GuiResourcesT::GetModel(const std::string& FileName, std::string& ErrorMsg) 
    100100{ 
    101     return m_ModelMan.GetModel(FileName, ErrorMsg); 
     101    return m_ModelMan.GetModel(FileName, &ErrorMsg); 
    102102} 
    103103 
  • cafu/trunk/Libs/Models/ModelManager.cpp

    r414 r423  
    4646 
    4747 
    48 const CafuModelT* ModelManagerT::GetModel(const std::string& FileName, std::string& ErrorMsg) const 
     48const CafuModelT* ModelManagerT::GetModel(const std::string& FileName, std::string* ErrorMsg) const 
    4949{ 
    50     ErrorMsg=""; 
     50    if (ErrorMsg) (*ErrorMsg)=""; 
    5151    std::map<std::string, CafuModelT*>::const_iterator It=m_Models.find(FileName); 
    5252 
     
    8080 
    8181        NewModel=new CafuModelT(Loader); 
    82         ErrorMsg="The file could not be loaded (unknown error)."; 
     82        if (ErrorMsg) (*ErrorMsg)="The file could not be loaded (unknown error)."; 
    8383    } 
    8484    catch (const ModelLoaderT::LoadErrorT& LE) 
     
    8787 
    8888        NewModel=new CafuModelT(Loader); 
    89         ErrorMsg=LE.what(); 
     89        if (ErrorMsg) (*ErrorMsg)=LE.what(); 
    9090    } 
    9191 
  • cafu/trunk/Libs/Models/ModelManager.hpp

    r415 r423  
    6262    /// @param ErrorMsg   Is set to the error message if there was an error loading the model, 
    6363    ///                   or the empty string \c "" when the model was successfully loaded. 
    64     const CafuModelT* GetModel(const std::string& FileName, std::string& ErrorMsg) const; 
     64    const CafuModelT* GetModel(const std::string& FileName, std::string* ErrorMsg=NULL) const; 
    6565 
    6666 
  • cafu/trunk/Libs/SceneGraph/ModelNode.cpp

    r419 r423  
    6161cf::SceneGraph::ModelNodeT* cf::SceneGraph::ModelNodeT::CreateFromFile_cw(std::istream& InFile, aux::PoolT& Pool, ModelManagerT& ModelMan) 
    6262{ 
    63     std::string ErrorMsg; 
    6463    ModelNodeT* ModelNode=new ModelNodeT(); 
    6564 
    66     ModelNode->m_Model    =ModelMan.GetModel(Pool.ReadString(InFile), ErrorMsg); 
     65    ModelNode->m_Model    =ModelMan.GetModel(Pool.ReadString(InFile)); 
    6766    ModelNode->m_Label    =aux::ReadString(InFile); 
    6867    ModelNode->m_Origin   =aux::ReadVector3f(InFile);