X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;ds=sidebyside;f=Source%2FModels.cpp;h=0b8105396bd4f00204e73440c319a0783707d65f;hb=2a9d19feea3589e45e3f6aa4e7b6052732b35f3f;hp=41d5d5cfd05d2b360e95f655fdcdab6cfd3f3be7;hpb=8e94b0e0f79e8fc55ace5699ffe039462d9e155d;p=lugaru.git diff --git a/Source/Models.cpp b/Source/Models.cpp index 41d5d5c..0b81053 100644 --- a/Source/Models.cpp +++ b/Source/Models.cpp @@ -3,20 +3,18 @@ Copyright (C) 2003, 2010 - Wolfire Games This file is part of Lugaru. -Lugaru is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. +Lugaru is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. -This program is distributed in the hope that it will be useful, +Lugaru is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +along with Lugaru. If not, see . */ #include "Game.h" @@ -66,43 +64,6 @@ int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate) return firstintersecting; } -int Model::LineCheckSlide(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate) -{ - static int j; - static float distance; - static float olddistance; - static int intersecting; - static int firstintersecting; - static XYZ point; - - *p1 = *p1 - *move; - *p2 = *p2 - *move; - if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) - return -1; - firstintersecting = -1; - if (*rotate) - *p1 = DoRotation(*p1, 0, -*rotate, 0); - if (*rotate) - *p2 = DoRotation(*p2, 0, -*rotate, 0); - - for (j = 0; j < TriangleNum; j++) { - intersecting = LineFacetd(p1, p2, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], &facenormals[j], &point); - distance = (point.x - p1->x) * (point.x - p1->x) + (point.y - p1->y) * (point.y - p1->y) + (point.z - p1->z) * (point.z - p1->z); - if ((distance < olddistance || firstintersecting == -1) && intersecting) { - olddistance = distance; - firstintersecting = j; - } - } - - distance = abs((facenormals[firstintersecting].x * p2->x) + (facenormals[firstintersecting].y * p2->y) + (facenormals[firstintersecting].z * p2->z) - ((facenormals[firstintersecting].x * vertex[Triangles[firstintersecting].vertex[0]].x) + (facenormals[firstintersecting].y * vertex[Triangles[firstintersecting].vertex[0]].y) + (facenormals[firstintersecting].z * vertex[Triangles[firstintersecting].vertex[0]].z))); - *p2 -= facenormals[firstintersecting] * distance; - - if (*rotate) - *p2 = DoRotation(*p2, 0, *rotate, 0); - *p2 = *p2 + *move; - return firstintersecting; -} - int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate) { static int j; @@ -1029,7 +990,6 @@ void Model::drawdifftex(GLuint texture) glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - //drawdiffteximmediate(texture); } void Model::drawdifftex(Texture texture) @@ -1062,49 +1022,6 @@ void Model::drawdifftex(Texture texture) glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - //drawdiffteximmediate(texture); -} - -void Model::drawdiffteximmediate(GLuint texture) -{ - glBindTexture(GL_TEXTURE_2D, (unsigned long)texture); - - glBegin(GL_TRIANGLES); - for (int i = 0; i < TriangleNum; i++) { - /*if(Triangles[i].vertex[0]=0&&Triangles[i].vertex[1]>=0&&Triangles[i].vertex[2]>=0){ - if(isnormal(vertex[Triangles[i].vertex[0]].x)&&isnormal(vertex[Triangles[i].vertex[0]].y)&&isnormal(vertex[Triangles[i].vertex[0]].z) - &&isnormal(vertex[Triangles[i].vertex[1]].x)&&isnormal(vertex[Triangles[i].vertex[1]].y)&&isnormal(vertex[Triangles[i].vertex[1]].z) - &&isnormal(vertex[Triangles[i].vertex[2]].x)&&isnormal(vertex[Triangles[i].vertex[2]].y)&&isnormal(vertex[Triangles[i].vertex[2]].z)){ - */glTexCoord2f(Triangles[i].gx[0], Triangles[i].gy[0]); - if (color) - glColor3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z); - if (!color && !flat) - glNormal3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z); - if (!color && flat) - glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y); - glVertex3f(vertex[Triangles[i].vertex[0]].x, vertex[Triangles[i].vertex[0]].y, vertex[Triangles[i].vertex[0]].z); - - glTexCoord2f(Triangles[i].gx[1], Triangles[i].gy[1]); - if (color) - glColor3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z); - if (!color && !flat) - glNormal3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z); - if (!color && flat) - glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y); - glVertex3f(vertex[Triangles[i].vertex[1]].x, vertex[Triangles[i].vertex[1]].y, vertex[Triangles[i].vertex[1]].z); - - glTexCoord2f(Triangles[i].gx[2], Triangles[i].gy[2]); - if (color) - glColor3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z); - if (!color && !flat) - glNormal3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z); - if (!color && flat) - glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y); - glVertex3f(vertex[Triangles[i].vertex[2]].x, vertex[Triangles[i].vertex[2]].y, vertex[Triangles[i].vertex[2]].z); - //} - //} - } - glEnd(); } void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture)