From 188b251d145503cab17680a22cbabf58b24358d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Wed, 4 Jan 2017 15:00:53 +0100 Subject: [PATCH] Moved Weapon model and texture loading in Weapon class --- Source/GameInitDispose.cpp | 33 +-------------------------------- Source/Objects/Weapons.cpp | 37 +++++++++++++++++++++++++++++++++++++ Source/Objects/Weapons.hpp | 2 ++ 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index 2922eaf..984202f 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -661,38 +661,7 @@ void Game::LoadStuff() realtexdetail = texdetail; - LOG("Loading weapon data..."); - - Weapon::knifetextureptr.load("Textures/Knife.png", 0); - Weapon::bloodknifetextureptr.load("Textures/BloodKnife.png", 0); - Weapon::lightbloodknifetextureptr.load("Textures/BloodKnifeLight.png", 0); - Weapon::swordtextureptr.load("Textures/Sword.jpg", 1); - Weapon::bloodswordtextureptr.load("Textures/SwordBlood.jpg", 1); - Weapon::lightbloodswordtextureptr.load("Textures/SwordBloodLight.jpg", 1); - Weapon::stafftextureptr.load("Textures/Staff.jpg", 1); - - Weapon::throwingknifemodel.load("Models/ThrowingKnife.solid"); - Weapon::throwingknifemodel.Scale(.001, .001, .001); - Weapon::throwingknifemodel.Rotate(90, 0, 0); - Weapon::throwingknifemodel.Rotate(0, 90, 0); - Weapon::throwingknifemodel.flat = 0; - Weapon::throwingknifemodel.CalculateNormals(1); - - Weapon::swordmodel.load("Models/Sword.solid"); - Weapon::swordmodel.Scale(.001, .001, .001); - Weapon::swordmodel.Rotate(90, 0, 0); - Weapon::swordmodel.Rotate(0, 90, 0); - Weapon::swordmodel.Rotate(0, 0, 90); - Weapon::swordmodel.flat = 1; - Weapon::swordmodel.CalculateNormals(1); - - Weapon::staffmodel.load("Models/Staff.solid"); - Weapon::staffmodel.Scale(.005, .005, .005); - Weapon::staffmodel.Rotate(90, 0, 0); - Weapon::staffmodel.Rotate(0, 90, 0); - Weapon::staffmodel.Rotate(0, 0, 90); - Weapon::staffmodel.flat = 1; - Weapon::staffmodel.CalculateNormals(1); + Weapon::Load(); terrain.shadowtexture.load("Textures/Shadow.png", 0); terrain.bloodtexture.load("Textures/Blood.png", 0); diff --git a/Source/Objects/Weapons.cpp b/Source/Objects/Weapons.cpp index 5ef40e6..31ea8c1 100644 --- a/Source/Objects/Weapons.cpp +++ b/Source/Objects/Weapons.cpp @@ -97,6 +97,43 @@ void Weapon::setType(int t) } } +/* Load weapons models and textures */ +void Weapon::Load() +{ + LOG("Loading weapon data..."); + + knifetextureptr.load("Textures/Knife.png", 0); + bloodknifetextureptr.load("Textures/BloodKnife.png", 0); + lightbloodknifetextureptr.load("Textures/BloodKnifeLight.png", 0); + swordtextureptr.load("Textures/Sword.jpg", 1); + bloodswordtextureptr.load("Textures/SwordBlood.jpg", 1); + lightbloodswordtextureptr.load("Textures/SwordBloodLight.jpg", 1); + stafftextureptr.load("Textures/Staff.jpg", 1); + + throwingknifemodel.load("Models/ThrowingKnife.solid"); + throwingknifemodel.Scale(.001, .001, .001); + throwingknifemodel.Rotate(90, 0, 0); + throwingknifemodel.Rotate(0, 90, 0); + throwingknifemodel.flat = 0; + throwingknifemodel.CalculateNormals(1); + + swordmodel.load("Models/Sword.solid"); + swordmodel.Scale(.001, .001, .001); + swordmodel.Rotate(90, 0, 0); + swordmodel.Rotate(0, 90, 0); + swordmodel.Rotate(0, 0, 90); + swordmodel.flat = 1; + swordmodel.CalculateNormals(1); + + staffmodel.load("Models/Staff.solid"); + staffmodel.Scale(.005, .005, .005); + staffmodel.Rotate(90, 0, 0); + staffmodel.Rotate(0, 90, 0); + staffmodel.Rotate(0, 0, 90); + staffmodel.flat = 1; + staffmodel.CalculateNormals(1); +} + void Weapon::DoStuff(int i) { static int whichpatchx, whichpatchz, whichhit; diff --git a/Source/Objects/Weapons.hpp b/Source/Objects/Weapons.hpp index 2f802f7..33d93aa 100644 --- a/Source/Objects/Weapons.hpp +++ b/Source/Objects/Weapons.hpp @@ -57,6 +57,8 @@ public: static Model staffmodel; static Texture stafftextureptr; + static void Load(); + void Draw(); void DoStuff(int); -- 2.39.2