X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects%2FWeapons.cpp;h=31ea8c16f4f76edcb3c8bb2948183ed14cb23baa;hb=188b251d145503cab17680a22cbabf58b24358d5;hp=38ee55be357d52d38babdc9b223992e581f3e0a9;hpb=d177a567280631cd91a677debafada8cef7e0413;p=lugaru.git diff --git a/Source/Objects/Weapons.cpp b/Source/Objects/Weapons.cpp index 38ee55b..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; @@ -166,7 +203,7 @@ void Weapon::DoStuff(int i) if (whichhit != -1) { if (Object::objects[k]->type == treetrunktype) { Object::objects[k]->model.MakeDecal(breakdecal, DoRotation(colpoint - Object::objects[k]->position, 0, -Object::objects[k]->yaw, 0), .1, 1, Random() % 360); - normalrot = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0); + normalrot = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0); velocity = 0; if (type == knife) position = colpoint - normalrot * .1; @@ -451,7 +488,7 @@ void Weapon::DoStuff(int i) if (whichhit != -1) { hitsomething = 1; position = colpoint; - terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1; + terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1; ReflectVector(&velocity, &terrainnormal); position += terrainnormal * .002; @@ -481,7 +518,7 @@ void Weapon::DoStuff(int i) if (whichhit != -1) { hitsomething = 1; tippoint = colpoint; - terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1; + terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1; ReflectVector(&tipvelocity, &terrainnormal); tippoint += terrainnormal * .002; @@ -518,7 +555,7 @@ void Weapon::DoStuff(int i) if (whichhit != -1) { hitsomething = 1; mid = colpoint; - terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1; + terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1; ReflectVector(&velocity, &terrainnormal); bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal))); @@ -553,7 +590,7 @@ void Weapon::DoStuff(int i) if (whichhit != -1) { hitsomething = 1; mid = colpoint; - terrainnormal = DoRotation(Object::objects[k]->model.facenormals[whichhit], 0, Object::objects[k]->yaw, 0) * -1; + terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1; ReflectVector(&tipvelocity, &terrainnormal); bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));