}
}
-void Weapon::DoStuff(int i)
+/* 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;
static XYZ start, end, colpoint, normalrot, footvel, footpoint;
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;
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;
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;
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)));
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)));
if (whichhit != -1) {
hitsomething = 1;
closestdistance = -1;
- closestswordpoint = colpoint; //(position+tippoint)/2;
- point[0] = DoRotation(Object::objects[k]->model.vertex[Object::objects[k]->model.Triangles[whichhit].vertex[0]], 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
- point[1] = DoRotation(Object::objects[k]->model.vertex[Object::objects[k]->model.Triangles[whichhit].vertex[1]], 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
- point[2] = DoRotation(Object::objects[k]->model.vertex[Object::objects[k]->model.Triangles[whichhit].vertex[2]], 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
+ closestswordpoint = colpoint;
+ point[0] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 0), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
+ point[1] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 1), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
+ point[2] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 2), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
if (DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance, &colpoint )) {
if (distance < closestdistance || closestdistance == -1) {
closestpoint = colpoint;
//Move
int i = 0;
for (std::vector<Weapon>::iterator weapon = begin(); weapon != end(); ++weapon) {
- weapon->DoStuff(i++);
+ weapon->doStuff(i++);
}
}
-void Weapon::Draw()
+void Weapon::draw()
{
static XYZ terrainlight;
static GLfloat M[16];
glDepthMask(1);
for (std::vector<Weapon>::iterator weapon = begin(); weapon != end(); ++weapon) {
- weapon->Draw();
+ weapon->draw();
}
return 0;
}