Changeset 423
- Timestamp:
- 11/18/11 09:44:14 (6 months ago)
- Location:
- cafu/trunk
- Files:
-
- 56 modified
-
Ca3DE/Both/Ca3DEWorld.cpp (modified) (3 diffs)
-
Ca3DE/Both/Ca3DEWorld.hpp (modified) (2 diffs)
-
Ca3DE/ClassDiagram.dia (modified) (previous)
-
Ca3DE/MainCanvas.cpp (modified) (1 diff)
-
CaBSP/LoadWorld.cpp (modified) (2 diffs)
-
CaWE/GameConfig.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/CompanyBot.cpp (modified) (9 diffs)
-
Games/DeathMatch/Code/CompanyBot.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/Corpse.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/GameImpl.cpp (modified) (8 diffs)
-
Games/DeathMatch/Code/GameImpl.hpp (modified) (4 diffs)
-
Games/DeathMatch/Code/HumanPlayer.cpp (modified) (12 diffs)
-
Games/DeathMatch/Code/HumanPlayer.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/Weapon357.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/Weapon9mmAR.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponBattleScythe.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponCrossbow.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponEgon.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponFaceHugger.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponGauss.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponGrenade.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponHornetGun.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/WeaponPistol.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponRPG.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponShotgun.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/WeaponTripmine.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw.hpp (modified) (4 diffs)
-
Games/DeathMatch/Code/cw_357.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_357.hpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw_9mmAR.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_9mmAR.hpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw_BattleScythe.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw_BattleScythe.hpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw_CrossBow.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_CrossBow.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_Egon.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_Egon.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_FaceHugger.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_FaceHugger.hpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw_Gauss.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_Gauss.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_Grenade.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_Grenade.hpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw_Pistol.cpp (modified) (1 diff)
-
Games/DeathMatch/Code/cw_Pistol.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_RPG.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_RPG.hpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_Shotgun.cpp (modified) (2 diffs)
-
Games/DeathMatch/Code/cw_Shotgun.hpp (modified) (1 diff)
-
Games/Game.hpp (modified) (2 diffs)
-
Games/GameWorld.hpp (modified) (2 diffs)
-
Libs/GuiSys/GuiImpl.cpp (modified) (1 diff)
-
Libs/Models/ModelManager.cpp (modified) (3 diffs)
-
Libs/Models/ModelManager.hpp (modified) (1 diff)
-
Libs/SceneGraph/ModelNode.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cafu/trunk/Ca3DE/Both/Ca3DEWorld.cpp
r419 r423 27 27 #include "ClipSys/TraceSolid.hpp" 28 28 #include "MaterialSystem/Material.hpp" 29 #include "Models/ModelManager.hpp" 29 30 #include "../../Common/WorldMan.hpp" 30 31 #include "SceneGraph/BspTreeNode.hpp" … … 50 51 GameEntities(World->GameEntities), 51 52 ClipWorld(new cf::ClipSys::ClipWorldT(World->CollModel)), 52 EntityManager(new EntityManagerT(*this)) 53 EntityManager(new EntityManagerT(*this)), 54 m_ModelMan(ModelMan) 53 55 { 54 56 } … … 167 169 EntityManager->RemoveEntity(EntityID); 168 170 } 171 172 173 const CafuModelT* Ca3DEWorldT::GetModel(const std::string& FileName) const 174 { 175 return m_ModelMan.GetModel(FileName); 176 } -
cafu/trunk/Ca3DE/Both/Ca3DEWorld.hpp
r419 r423 68 68 unsigned long CreateNewEntity(const std::map<std::string, std::string>& Properties, unsigned long CreationFrameNr, const VectorT& Origin); 69 69 void RemoveEntity(unsigned long EntityID); 70 const CafuModelT* GetModel(const std::string& FileName) const; 70 71 71 72 … … 74 75 Ca3DEWorldT(const Ca3DEWorldT&); ///< Use of the Copy Constructor is not allowed. 75 76 void operator = (const Ca3DEWorldT&); ///< Use of the Assignment Operator is not allowed. 77 78 ModelManagerT& m_ModelMan; 76 79 }; 77 80 -
cafu/trunk/Ca3DE/MainCanvas.cpp
r419 r423 409 409 410 410 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); 412 413 413 414 -
cafu/trunk/CaBSP/LoadWorld.cpp
r419 r423 453 453 std::string ErrorMsg; 454 454 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); 456 456 457 457 if (ErrorMsg!="") Console->Warning(ErrorMsg); … … 582 582 std::string ErrorMsg; 583 583 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); 585 585 586 586 if (ErrorMsg!="") Console->Warning(ErrorMsg); -
cafu/trunk/CaWE/GameConfig.cpp
r415 r423 255 255 { 256 256 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); 258 258 259 259 if (ErrorMsg) -
cafu/trunk/Games/DeathMatch/Code/CompanyBot.cpp
r285 r423 36 36 #include "MaterialSystem/MaterialManager.hpp" 37 37 #include "MaterialSystem/Renderer.hpp" 38 #include "Models/AnimPose.hpp" 39 #include "Models/Model_cmdl.hpp" 38 40 39 41 … … 74 76 0, // ActiveWeaponSequNr 75 77 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) 78 81 { 79 82 // Wir könnten im Boden stecken oder darüber schweben - korrigiere entsprechend! … … 193 196 Physics::MoveHuman(State, ClipModel, FrameTime, VectorT(), VectorT(), false, DummyOldWishJump, 0.0, GameWorld->GetClipWorld()); 194 197 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(); 196 201 197 202 // As we're in "dead" state, the ClipModel is no longer registered with the clip world, … … 255 260 double NewSpeed=length(XYVel); 256 261 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(); 258 265 259 266 if (OldSpeed<1000 && NewSpeed>1000) { State.ModelSequNr=3; State.ModelFrameNr=0.0; } … … 303 310 if (!HasLight.GetValueBool()) return false; 304 311 305 if ( TimeForLightSource<2.0f)306 { 307 // 0.0 <= TimeForLightSource < 2.0308 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)]); 309 316 const unsigned long Red =char(255.0f*Value); 310 317 const unsigned long Green=char(255.0f*Value*0.9f); … … 315 322 else 316 323 { 317 // 2.0 <= TimeForLightSource < 6.0318 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)]); 319 326 const unsigned long Green=char(255.0f*(Value*0.8f+0.1f)); 320 327 … … 323 330 } 324 331 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)]; 326 333 const VectorT RelX =scale(VectorT(LookupTables::Angle16ToCos[State.Heading], LookupTables::Angle16ToSin[State.Heading], 0.0), 80.0*Value); 327 334 const VectorT RelY =scale(VectorT(LookupTables::Angle16ToSin[State.Heading], LookupTables::Angle16ToCos[State.Heading], 0.0), 500.0); … … 342 349 MatSys::Renderer->Translate(MatSys::RendererI::MODEL_TO_WORLD, 0.0f, 0.0f, -32.0f); 343 350 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); 348 358 } 349 359 … … 352 362 { 353 363 // 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(); 355 367 356 368 // 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; 359 371 } 360 372 -
cafu/trunk/Games/DeathMatch/Code/CompanyBot.hpp
r285 r423 24 24 25 25 #include "../../BaseEntity.hpp" 26 #include "Models/Model_proxy.hpp"27 26 #include "btBulletDynamicsCommon.h" 28 27 29 28 29 class CafuModelT; 30 30 class EntityCreateParamsT; 31 31 … … 59 59 private: 60 60 61 const ModelProxyT CompanyBotModel; 62 float TimeForLightSource; 61 const CafuModelT* m_CompanyBotModel; 62 const CafuModelT* m_WeaponModel; 63 float m_TimeForLightSource; 63 64 64 65 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 26 26 #include "Corpse.hpp" 27 27 #include "EntityCreateParams.hpp" 28 #include " HumanPlayer.hpp"28 #include "GameImpl.hpp" 29 29 #include "TypeSys.hpp" 30 30 #include "MaterialSystem/Renderer.hpp" 31 #include "Models/Model_ proxy.hpp"31 #include "Models/Model_cmdl.hpp" 32 32 33 33 … … 85 85 MatSys::Renderer->Translate(MatSys::RendererI::MODEL_TO_WORLD, 0.0f, 0.0f, -32.0f); 86 86 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 } 88 101 } -
cafu/trunk/Games/DeathMatch/Code/GameImpl.cpp
r285 r423 23 23 24 24 #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" 25 36 #include "EntityCreateParams.hpp" 26 37 #include "HumanPlayer.hpp" … … 28 39 #include "ScriptState.hpp" 29 40 #include "TypeSys.hpp" 41 #include "Models/ModelManager.hpp" 30 42 #include "SoundSystem/SoundSys.hpp" 31 43 #include "SoundSystem/SoundShaderManager.hpp" … … 76 88 77 89 78 void cf::GameSys::GameImplT::Initialize(bool AsClient, bool AsServer) 79 { 90 void 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 80 114 RunningAsClient=AsClient; 81 115 RunningAsServer=AsServer; … … 103 137 // but also to effectively load and initialize the models only at that later time, what might be very expensive, too! 104 138 { 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 116 139 // And the rest. Observe that static detail models are NOT mentioned (how could they?). 117 140 static ModelProxyT M01("Games/DeathMatch/Models/Items/Ammo_DartGun.mdl"); … … 139 162 140 163 // 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"))); 151 174 } 152 175 … … 167 190 168 191 // 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]; 171 194 } 172 195 … … 174 197 { 175 198 } 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! 176 205 } 177 206 … … 363 392 delete BaseEntity; 364 393 } 394 395 396 const CafuModelT* cf::GameSys::GameImplT::GetPlayerModel(unsigned int ModelIndex) const 397 { 398 return m_PlayerModels[ModelIndex<m_PlayerModels.Size() ? ModelIndex : 0]; 399 } 400 401 402 const 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 27 27 28 28 29 class CafuModelT; 30 class CarriedWeaponT; 29 31 class PhysicsWorldT; 30 32 class SoundI; … … 44 46 45 47 // Implement the methods of the GameI interface. 46 void Initialize(bool AsClient, bool AsServer );48 void Initialize(bool AsClient, bool AsServer, ModelManagerT& ModelMan); 47 49 void Release(); 48 50 void Sv_PrepareNewWorld(const char* WorldFileName, const cf::ClipSys::CollisionModelT* WorldCollMdl); … … 57 59 void FreeBaseEntity(BaseEntityT* BaseEntity); 58 60 61 59 62 // 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 60 73 bool IsSvThinking() const { return IsThinking; } 61 74 ScriptStateT* GetScriptState() const { return ScriptState; } … … 70 83 GameImplT(); 71 84 72 bool RunningAsClient;73 bool RunningAsServer;85 bool RunningAsClient; 86 bool RunningAsServer; 74 87 75 PhysicsWorldT* Sv_PhysicsWorld;76 PhysicsWorldT* Cl_PhysicsWorld;88 PhysicsWorldT* Sv_PhysicsWorld; 89 PhysicsWorldT* Cl_PhysicsWorld; 77 90 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(). 80 93 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. 82 97 }; 83 98 } -
cafu/trunk/Games/DeathMatch/Code/HumanPlayer.cpp
r285 r423 32 32 #include "Constants_WeaponSlots.hpp" 33 33 #include "EntityCreateParams.hpp" 34 #include "GameImpl.hpp" 34 35 #include "PhysicsWorld.hpp" 35 36 #include "Libs/LookupTables.hpp" 36 37 #include "Libs/Physics.hpp" 38 37 39 #include "SoundSystem/SoundSys.hpp" 38 40 #include "../../GameWorld.hpp" … … 46 48 #include "MaterialSystem/Material.hpp" 47 49 #include "MaterialSystem/MaterialManager.hpp" 48 #include "Models/Model_proxy.hpp" 50 #include "Models/AnimPose.hpp" 51 #include "Models/Model_cmdl.hpp" 49 52 #include "OpenGL/OpenGLWindow.hpp" 50 53 #include "ParticleEngine/ParticleEngineMS.hpp" … … 217 220 State.Health-=Amount; 218 221 } 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];242 222 } 243 223 … … 478 458 if (State.HaveWeapons & (1 << State.ActiveWeaponSlot)) 479 459 { 480 const CarriedWeaponT* CarriedWeapon= CarriedWeaponT::GetCarriedWeapon(State.ActiveWeaponSlot);460 const CarriedWeaponT* CarriedWeapon=cf::GameSys::GameImplT::GetInstance().GetCarriedWeapon(State.ActiveWeaponSlot); 481 461 482 462 // 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(); 486 469 const bool AnimSequenceWrap=NewFrameNr<State.ActiveWeaponFrameNr; 487 470 … … 711 694 712 695 // 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(); 716 701 break; 717 702 } … … 719 704 case StateOfExistance_Dead: 720 705 { 721 ModelProxyT& PlayerModel =GetModelFromPlayerModelIndex(State.ModelIndex);722 706 bool DummyOldWishJump=false; 723 707 const double OldOriginZ =State.Origin.z; … … 747 731 748 732 // 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(); 750 738 751 739 // We entered this state after we died. … … 899 887 switch (EventID) 900 888 { 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; 903 891 } 904 892 } … … 977 965 978 966 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); 982 971 } 983 972 } … … 993 982 994 983 // 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 } 998 998 } 999 999 } … … 1004 1004 // Code for state driven effects. 1005 1005 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); 1007 1007 1008 1008 … … 1164 1164 else 1165 1165 { 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); 1167 1168 1168 1169 // 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(); 1170 1172 } 1171 1173 -
cafu/trunk/Games/DeathMatch/Code/HumanPlayer.hpp
r285 r423 30 30 class EntityCreateParamsT; 31 31 class EntStaticDetailModelT; 32 class ModelProxyT;33 32 namespace cf { namespace GuiSys { class GuiI; } } 34 33 … … 38 37 public: 39 38 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". 44 41 45 42 -
cafu/trunk/Games/DeathMatch/Code/Weapon357.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/Weapon9mmAR.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponBattleScythe.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponCrossbow.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponEgon.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponFaceHugger.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponGauss.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponGrenade.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponHornetGun.cpp
r285 r423 28 28 #include "Constants_WeaponSlots.hpp" 29 29 #include "EntityCreateParams.hpp" 30 #include "GameImpl.hpp" 30 31 #include "HumanPlayer.hpp" 31 32 #include "TypeSys.hpp" -
cafu/trunk/Games/DeathMatch/Code/WeaponPistol.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponRPG.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponShotgun.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" … … 64 65 65 66 // 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; 67 68 68 69 // And finally retire for a while. -
cafu/trunk/Games/DeathMatch/Code/WeaponTripmine.cpp
r285 r423 29 29 #include "Constants_WeaponSlots.hpp" 30 30 #include "EntityCreateParams.hpp" 31 #include "GameImpl.hpp" 31 32 #include "HumanPlayer.hpp" 32 33 #include "TypeSys.hpp" -
cafu/trunk/Games/DeathMatch/Code/cw.cpp
r285 r423 20 20 */ 21 21 22 /**********************/23 /*** Carried Weapon ***/24 /**********************/25 26 22 #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"38 23 39 24 40 const CarriedWeaponT* CarriedWeaponT::GetCarriedWeapon(char ActiveWeaponSlot) 25 CarriedWeaponT::CarriedWeaponT(const CafuModelT* ViewModel, const CafuModelT* PlayerModel) 26 : m_ViewModel(ViewModel), 27 m_PlayerModel(PlayerModel) 41 28 { 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 } 54 30 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 };68 31 69 return ActiveWeaponSlot<13 ? CarriedWeaponPtrs[ActiveWeaponSlot] : &CarriedWeapon_NONE_DUMMY; 32 CarriedWeaponT::~CarriedWeaponT() 33 { 70 34 } 71 35 -
cafu/trunk/Games/DeathMatch/Code/cw.hpp
r285 r423 20 20 */ 21 21 22 /**********************/23 /*** Carried Weapon ***/24 /**********************/25 26 22 #ifndef _CARRIEDWEAPON_HPP_ 27 23 #define _CARRIEDWEAPON_HPP_ … … 33 29 class EntHumanPlayerT; 34 30 struct PlayerCommandT; 35 class ModelProxyT; 31 class CafuModelT; 32 class ModelManagerT; 33 class SoundI; 36 34 37 35 38 // The ONLYpurpose of this interface is to localize (group) the code and data39 // 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 NOTrelated 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! 43 41 class CarriedWeaponT 44 42 { 45 43 public: 46 44 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); 51 47 52 48 /// The destructor. 49 virtual ~CarriedWeaponT(); 53 50 54 51 // This function indicates the ammo that this weapon consumes for primary fire. … … 62 59 // virtual char GetAmmoSlotForSecondaryFire() const; 63 60 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; } 66 63 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; } 69 66 70 67 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. 75 71 virtual bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; 76 72 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(). 79 75 virtual void ServerSide_Think(EntHumanPlayerT* Player, const PlayerCommandT& PlayerCommand, bool ThinkingOnServerSide, unsigned long ServerFrameNr, bool AnimSequenceWrap) const; 80 76 81 77 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. 84 79 virtual void ClientSide_HandlePrimaryFireEvent(const EntHumanPlayerT* Player, const VectorT& LastSeenAmbientColor) const; 85 80 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. 87 82 virtual void ClientSide_HandleSecondaryFireEvent(const EntHumanPlayerT* Player, const VectorT& LastSeenAmbientColor) const; 88 83 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. 91 86 virtual void ClientSide_HandleStateDrivenEffects(const EntHumanPlayerT* Player) const; 92 87 … … 95 90 96 91 92 private: 97 93 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. 100 96 }; 101 97 -
cafu/trunk/Games/DeathMatch/Code/cw_357.cpp
r285 r423 19 19 ================================================================================= 20 20 */ 21 22 /****************************/23 /*** Carried Weapon - 357 ***/24 /****************************/25 21 26 22 #include "cw_357.hpp" … … 32 28 #include "Libs/LookupTables.hpp" 33 29 #include "../../GameWorld.hpp" 34 #include "Models/Model _proxy.hpp"30 #include "Models/ModelManager.hpp" 35 31 #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 37 CarriedWeapon357T::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 45 CarriedWeapon357T::~CarriedWeapon357T() 46 { 47 // Release Sound. 48 SoundSystem->DeleteSound(FireSound); 49 } 40 50 41 51 -
cafu/trunk/Games/DeathMatch/Code/cw_357.hpp
r285 r423 20 20 */ 21 21 22 /****************************/23 /*** Carried Weapon - 357 ***/24 /****************************/25 26 22 #ifndef _CW_357_HPP_ 27 23 #define _CW_357_HPP_ 28 24 29 25 #include "cw.hpp" 30 #include "SoundSystem/SoundSys.hpp"31 #include "SoundSystem/SoundShaderManager.hpp"32 #include "SoundSystem/Sound.hpp"33 26 34 27 35 structCarriedWeapon357T : public CarriedWeaponT28 class CarriedWeapon357T : public CarriedWeaponT 36 29 { 37 CarriedWeapon357T() 38 : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/DesertEagle_Shot1"))) 39 { 40 }; 30 public: 41 31 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(); 50 34 51 35 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_9mmAR.cpp
r285 r423 19 19 ================================================================================= 20 20 */ 21 22 /******************************/23 /*** Carried Weapon - 9mmAR ***/24 /******************************/25 21 26 22 #include "cw_9mmAR.hpp" … … 32 28 #include "Libs/LookupTables.hpp" 33 29 #include "../../GameWorld.hpp" 34 #include "Models/Model _proxy.hpp"30 #include "Models/ModelManager.hpp" 35 31 #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 37 CarriedWeapon9mmART::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 46 CarriedWeapon9mmART::~CarriedWeapon9mmART() 47 { 48 // Release Sound. 49 SoundSystem->DeleteSound(FireSound); 50 SoundSystem->DeleteSound(AltFireSound); 51 } 40 52 41 53 -
cafu/trunk/Games/DeathMatch/Code/cw_9mmAR.hpp
r285 r423 20 20 */ 21 21 22 /******************************/23 /*** Carried Weapon - 9mmAR ***/24 /******************************/25 26 22 #ifndef _CW_9MMAR_HPP_ 27 23 #define _CW_9MMAR_HPP_ 28 24 29 25 #include "cw.hpp" 30 #include "SoundSystem/SoundSys.hpp"31 #include "SoundSystem/SoundShaderManager.hpp"32 #include "SoundSystem/Sound.hpp"33 26 34 27 35 structCarriedWeapon9mmART : public CarriedWeaponT28 class CarriedWeapon9mmART : public CarriedWeaponT 36 29 { 37 CarriedWeapon9mmART() 38 : FireSound (SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_Shot1"))), 39 AltFireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mmAR_GLauncher"))) 40 { 41 }; 30 public: 42 31 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(); 52 34 53 35 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_BattleScythe.cpp
r285 r423 20 20 */ 21 21 22 /*************************************/23 /*** Carried Weapon - BattleScythe ***/24 /*************************************/25 26 22 #include "cw_BattleScythe.hpp" 27 23 #include "HumanPlayer.hpp" 28 24 #include "Constants_WeaponSlots.hpp" 29 25 #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" 31 30 32 31 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; } 32 CarriedWeaponBattleScytheT::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 40 CarriedWeaponBattleScytheT::~CarriedWeaponBattleScytheT() 41 { 42 // Release Sound. 43 SoundSystem->DeleteSound(FireSound); 44 } 35 45 36 46 -
cafu/trunk/Games/DeathMatch/Code/cw_BattleScythe.hpp
r285 r423 20 20 */ 21 21 22 /*************************************/23 /*** Carried Weapon - BattleScythe ***/24 /*************************************/25 26 22 #ifndef _CW_BATTLESCYTHE_HPP_ 27 23 #define _CW_BATTLESCYTHE_HPP_ 28 24 29 25 #include "cw.hpp" 30 #include "SoundSystem/SoundSys.hpp"31 #include "SoundSystem/SoundShaderManager.hpp"32 #include "SoundSystem/Sound.hpp"33 26 34 27 35 structCarriedWeaponBattleScytheT : public CarriedWeaponT28 class CarriedWeaponBattleScytheT : public CarriedWeaponT 36 29 { 37 CarriedWeaponBattleScytheT() 38 : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/BattleScythe"))) 39 { 40 }; 30 public: 41 31 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(); 50 34 51 35 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_CrossBow.cpp
r285 r423 20 20 */ 21 21 22 /*********************************/23 /*** Carried Weapon - CrossBow ***/24 /*********************************/25 26 22 #include "cw_CrossBow.hpp" 27 23 #include "HumanPlayer.hpp" … … 31 27 #include "Libs/LookupTables.hpp" 32 28 #include "../../GameWorld.hpp" 33 #include "Models/Model _proxy.hpp"29 #include "Models/ModelManager.hpp" 34 30 35 31 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; } 32 CarriedWeaponCrossBowT::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 } 38 37 39 38 -
cafu/trunk/Games/DeathMatch/Code/cw_CrossBow.hpp
r285 r423 20 20 */ 21 21 22 /*********************************/23 /*** Carried Weapon - CrossBow ***/24 /*********************************/25 26 22 #ifndef _CW_CROSSBOW_HPP_ 27 23 #define _CW_CROSSBOW_HPP_ … … 30 26 31 27 32 structCarriedWeaponCrossBowT : public CarriedWeaponT28 class CarriedWeaponCrossBowT : public CarriedWeaponT 33 29 { 34 ModelProxyT& GetViewWeaponModel () const; 35 ModelProxyT& GetPlayerWeaponModel() const; 30 public: 31 32 CarriedWeaponCrossBowT(ModelManagerT& ModelMan); 36 33 37 34 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_Egon.cpp
r285 r423 20 20 */ 21 21 22 /*****************************/23 /*** Carried Weapon - Egon ***/24 /*****************************/25 26 22 #include "cw_Egon.hpp" 27 23 #include "HumanPlayer.hpp" … … 29 25 #include "Constants_WeaponSlots.hpp" 30 26 #include "Libs/LookupTables.hpp" 31 #include "Models/Model _proxy.hpp"27 #include "Models/ModelManager.hpp" 32 28 33 29 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; } 30 CarriedWeaponEgonT::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 } 36 35 37 36 -
cafu/trunk/Games/DeathMatch/Code/cw_Egon.hpp
r285 r423 20 20 */ 21 21 22 /*****************************/23 /*** Carried Weapon - Egon ***/24 /*****************************/25 26 22 #ifndef _CW_EGON_HPP_ 27 23 #define _CW_EGON_HPP_ … … 30 26 31 27 32 structCarriedWeaponEgonT : public CarriedWeaponT28 class CarriedWeaponEgonT : public CarriedWeaponT 33 29 { 34 ModelProxyT& GetViewWeaponModel () const; 35 ModelProxyT& GetPlayerWeaponModel() const; 30 public: 31 32 CarriedWeaponEgonT(ModelManagerT& ModelMan); 36 33 37 34 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_FaceHugger.cpp
r285 r423 20 20 */ 21 21 22 /***********************************/23 /*** Carried Weapon - FaceHugger ***/24 /***********************************/25 26 22 #include "cw_FaceHugger.hpp" 27 23 #include "HumanPlayer.hpp" … … 29 25 #include "Libs/LookupTables.hpp" 30 26 #include "../../GameWorld.hpp" 31 #include "Models/Model _proxy.hpp"27 #include "Models/ModelManager.hpp" 32 28 #include "ParticleEngine/ParticleEngineMS.hpp" 29 #include "SoundSystem/SoundSys.hpp" 30 #include "SoundSystem/SoundShaderManager.hpp" 31 #include "SoundSystem/Sound.hpp" 33 32 34 33 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; } 34 CarriedWeaponFaceHuggerT::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 42 CarriedWeaponFaceHuggerT::~CarriedWeaponFaceHuggerT() 43 { 44 // Release Sound. 45 SoundSystem->DeleteSound(FireSound); 46 } 37 47 38 48 -
cafu/trunk/Games/DeathMatch/Code/cw_FaceHugger.hpp
r285 r423 20 20 */ 21 21 22 /***********************************/23 /*** Carried Weapon - FaceHugger ***/24 /***********************************/25 26 22 #ifndef _CW_FACEHUGGER_HPP_ 27 23 #define _CW_FACEHUGGER_HPP_ 28 24 29 25 #include "cw.hpp" 30 #include "SoundSystem/SoundSys.hpp"31 #include "SoundSystem/SoundShaderManager.hpp"32 #include "SoundSystem/Sound.hpp"33 26 34 27 35 structCarriedWeaponFaceHuggerT : public CarriedWeaponT28 class CarriedWeaponFaceHuggerT : public CarriedWeaponT 36 29 { 37 CarriedWeaponFaceHuggerT() 38 : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))) 39 { 40 }; 30 public: 41 31 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(); 50 34 51 35 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_Gauss.cpp
r285 r423 20 20 */ 21 21 22 /******************************/23 /*** Carried Weapon - Gauss ***/24 /******************************/25 26 22 #include "cw_Gauss.hpp" 27 23 #include "HumanPlayer.hpp" … … 29 25 #include "Constants_WeaponSlots.hpp" 30 26 #include "Libs/LookupTables.hpp" 31 #include "Models/Model _proxy.hpp"27 #include "Models/ModelManager.hpp" 32 28 33 29 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; } 30 CarriedWeaponGaussT::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 } 36 35 37 36 -
cafu/trunk/Games/DeathMatch/Code/cw_Gauss.hpp
r285 r423 20 20 */ 21 21 22 /******************************/23 /*** Carried Weapon - Gauss ***/24 /******************************/25 26 22 #ifndef _CW_GAUSS_HPP_ 27 23 #define _CW_GAUSS_HPP_ … … 30 26 31 27 32 structCarriedWeaponGaussT : public CarriedWeaponT28 class CarriedWeaponGaussT : public CarriedWeaponT 33 29 { 34 ModelProxyT& GetViewWeaponModel () const; 35 ModelProxyT& GetPlayerWeaponModel() const; 30 public: 31 32 CarriedWeaponGaussT(ModelManagerT& ModelMan); 36 33 37 34 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_Grenade.cpp
r285 r423 20 20 */ 21 21 22 /********************************/23 /*** Carried Weapon - Grenade ***/24 /********************************/25 26 22 #include "cw_Grenade.hpp" 27 23 #include "HumanPlayer.hpp" … … 29 25 #include "Libs/LookupTables.hpp" 30 26 #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" 32 31 33 32 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; } 33 CarriedWeaponGrenadeT::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 41 CarriedWeaponGrenadeT::~CarriedWeaponGrenadeT() 42 { 43 // Release Sound. 44 SoundSystem->DeleteSound(FireSound); 45 } 36 46 37 47 -
cafu/trunk/Games/DeathMatch/Code/cw_Grenade.hpp
r285 r423 20 20 */ 21 21 22 /********************************/23 /*** Carried Weapon - Grenade ***/24 /********************************/25 26 22 #ifndef _CW_GRENADE_HPP_ 27 23 #define _CW_GRENADE_HPP_ 28 24 29 25 #include "cw.hpp" 30 #include "SoundSystem/SoundSys.hpp"31 #include "SoundSystem/SoundShaderManager.hpp"32 #include "SoundSystem/Sound.hpp"33 26 34 27 35 structCarriedWeaponGrenadeT : public CarriedWeaponT28 class CarriedWeaponGrenadeT : public CarriedWeaponT 36 29 { 37 CarriedWeaponGrenadeT() 38 : FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/FaceHugger_Throw"))) 39 { 40 }; 30 public: 41 31 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(); 50 34 51 35 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_Pistol.cpp
r285 r423 20 20 */ 21 21 22 /*******************************/23 /*** Carried Weapon - Pistol ***/24 /*******************************/25 26 22 #include "cw_Pistol.hpp" 27 23 #include "HumanPlayer.hpp" 28 24 #include "Constants_AmmoSlots.hpp" 29 25 #include "Constants_WeaponSlots.hpp" 30 #include "Models/Model _proxy.hpp"26 #include "Models/ModelManager.hpp" 31 27 32 28 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; } 29 CarriedWeaponPistolT::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 } 35 34 36 35 -
cafu/trunk/Games/DeathMatch/Code/cw_Pistol.hpp
r285 r423 20 20 */ 21 21 22 /*******************************/23 /*** Carried Weapon - Pistol ***/24 /*******************************/25 26 22 #ifndef _CW_PISTOL_HPP_ 27 23 #define _CW_PISTOL_HPP_ … … 30 26 31 27 32 structCarriedWeaponPistolT : public CarriedWeaponT28 class CarriedWeaponPistolT : public CarriedWeaponT 33 29 { 34 ModelProxyT& GetViewWeaponModel () const; 35 ModelProxyT& GetPlayerWeaponModel() const; 30 public: 31 32 CarriedWeaponPistolT(ModelManagerT& ModelMan); 36 33 37 34 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_RPG.cpp
r285 r423 20 20 */ 21 21 22 /****************************/23 /*** Carried Weapon - RPG ***/24 /****************************/25 26 22 #include "cw_RPG.hpp" 27 23 #include "HumanPlayer.hpp" … … 30 26 #include "Libs/LookupTables.hpp" 31 27 #include "../../GameWorld.hpp" 32 #include "Models/Model _proxy.hpp"28 #include "Models/ModelManager.hpp" 33 29 34 30 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; } 31 CarriedWeaponRPGT::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 } 37 36 38 37 -
cafu/trunk/Games/DeathMatch/Code/cw_RPG.hpp
r285 r423 20 20 */ 21 21 22 /****************************/23 /*** Carried Weapon - RPG ***/24 /****************************/25 26 22 #ifndef _CW_RPG_HPP_ 27 23 #define _CW_RPG_HPP_ … … 30 26 31 27 32 structCarriedWeaponRPGT : public CarriedWeaponT28 class CarriedWeaponRPGT : public CarriedWeaponT 33 29 { 34 ModelProxyT& GetViewWeaponModel () const; 35 ModelProxyT& GetPlayerWeaponModel() const; 30 public: 31 32 CarriedWeaponRPGT(ModelManagerT& ModelMan); 36 33 37 34 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/DeathMatch/Code/cw_Shotgun.cpp
r285 r423 19 19 ================================================================================= 20 20 */ 21 22 /********************************/23 /*** Carried Weapon - Shotgun ***/24 /********************************/25 21 26 22 #include "cw_Shotgun.hpp" … … 32 28 #include "Libs/LookupTables.hpp" 33 29 #include "../../GameWorld.hpp" 34 #include "Models/Model _proxy.hpp"30 #include "Models/ModelManager.hpp" 35 31 #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 37 CarriedWeaponShotgunT::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 46 CarriedWeaponShotgunT::~CarriedWeaponShotgunT() 47 { 48 // Release Sound. 49 SoundSystem->DeleteSound(FireSound); 50 SoundSystem->DeleteSound(AltFireSound); 51 } 40 52 41 53 -
cafu/trunk/Games/DeathMatch/Code/cw_Shotgun.hpp
r285 r423 20 20 */ 21 21 22 /********************************/23 /*** Carried Weapon - Shotgun ***/24 /********************************/25 26 22 #ifndef _CW_SHOTGUN_HPP_ 27 23 #define _CW_SHOTGUN_HPP_ 28 24 29 25 #include "cw.hpp" 30 #include "SoundSystem/SoundSys.hpp"31 #include "SoundSystem/SoundShaderManager.hpp"32 #include "SoundSystem/Sound.hpp"33 26 34 27 35 structCarriedWeaponShotgunT : public CarriedWeaponT28 class CarriedWeaponShotgunT : public CarriedWeaponT 36 29 { 37 CarriedWeaponShotgunT() 38 : FireSound (SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_sBarrel"))), 39 AltFireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_dBarrel"))) 40 { 41 }; 30 public: 42 31 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(); 52 34 53 35 bool ServerSide_PickedUpByEntity(BaseEntityT* Entity) const; -
cafu/trunk/Games/Game.hpp
r379 r423 30 30 class BaseEntityT; 31 31 template<class T> class Vector3T; 32 class ModelManagerT; 32 33 namespace cf { namespace ClipSys { class CollisionModelT; } } 33 34 namespace cf { namespace GameSys { class GameWorldI; } } … … 51 52 /// @param AsClient Tells whether we're running as client. 52 53 /// @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; 54 55 55 56 /// Called to shutdown the game. -
cafu/trunk/Games/GameWorld.hpp
r285 r423 25 25 26 26 class BaseEntityT; 27 class CafuModelT; 27 28 namespace cf { namespace ClipSys { class ClipWorldT; } } 28 29 … … 66 67 /// Removes the entity identified by 'EntityID' from the (server) world. 67 68 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; 68 74 }; 69 75 } -
cafu/trunk/Libs/GuiSys/GuiImpl.cpp
r415 r423 99 99 const CafuModelT* GuiResourcesT::GetModel(const std::string& FileName, std::string& ErrorMsg) 100 100 { 101 return m_ModelMan.GetModel(FileName, ErrorMsg);101 return m_ModelMan.GetModel(FileName, &ErrorMsg); 102 102 } 103 103 -
cafu/trunk/Libs/Models/ModelManager.cpp
r414 r423 46 46 47 47 48 const CafuModelT* ModelManagerT::GetModel(const std::string& FileName, std::string &ErrorMsg) const48 const CafuModelT* ModelManagerT::GetModel(const std::string& FileName, std::string* ErrorMsg) const 49 49 { 50 ErrorMsg="";50 if (ErrorMsg) (*ErrorMsg)=""; 51 51 std::map<std::string, CafuModelT*>::const_iterator It=m_Models.find(FileName); 52 52 … … 80 80 81 81 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)."; 83 83 } 84 84 catch (const ModelLoaderT::LoadErrorT& LE) … … 87 87 88 88 NewModel=new CafuModelT(Loader); 89 ErrorMsg=LE.what();89 if (ErrorMsg) (*ErrorMsg)=LE.what(); 90 90 } 91 91 -
cafu/trunk/Libs/Models/ModelManager.hpp
r415 r423 62 62 /// @param ErrorMsg Is set to the error message if there was an error loading the model, 63 63 /// 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; 65 65 66 66 -
cafu/trunk/Libs/SceneGraph/ModelNode.cpp
r419 r423 61 61 cf::SceneGraph::ModelNodeT* cf::SceneGraph::ModelNodeT::CreateFromFile_cw(std::istream& InFile, aux::PoolT& Pool, ModelManagerT& ModelMan) 62 62 { 63 std::string ErrorMsg;64 63 ModelNodeT* ModelNode=new ModelNodeT(); 65 64 66 ModelNode->m_Model =ModelMan.GetModel(Pool.ReadString(InFile) , ErrorMsg);65 ModelNode->m_Model =ModelMan.GetModel(Pool.ReadString(InFile)); 67 66 ModelNode->m_Label =aux::ReadString(InFile); 68 67 ModelNode->m_Origin =aux::ReadVector3f(InFile);
