LOG(std::string("Loading decal...") + Folders::getResourcePath(filename));
type = decalstype;
- decals.clear();
color = 0;
tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
-//TODO: phase out in favor of Texture
-void Model::drawdifftex(GLuint texture)
-{
- glEnableClientState(GL_NORMAL_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- if (color) {
- glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
- } else {
- glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
- }
-
- glBindTexture(GL_TEXTURE_2D, (unsigned long)texture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
-
- glDrawArrays(GL_TRIANGLES, 0, Triangles.size() * 3);
-
- if (color) {
- glDisableClientState(GL_COLOR_ARRAY);
- } else {
- glDisableClientState(GL_NORMAL_ARRAY);
- }
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-}
-
void Model::drawdifftex(Texture texture)
{
glEnableClientState(GL_NORMAL_ARRAY);
void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture)
{
if (decalstoggle) {
- if (type != decalstype)
+ if (type != decalstype) {
return;
- static int lasttype;
- static bool blend;
+ }
- blend = 1;
+ bool blend = true;
+ int lasttype = -1;
- lasttype = -1;
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
if (Triangles[i].facenormal.y < -.1 && (vertex[Triangles[i].vertex[0]].y < where->y || vertex[Triangles[i].vertex[1]].y < where->y || vertex[Triangles[i].vertex[2]].y < where->y)) {
distance = abs(((Triangles[i].facenormal.x * where->x) + (Triangles[i].facenormal.y * where->y) + (Triangles[i].facenormal.z * where->z) - ((Triangles[i].facenormal.x * vertex[Triangles[i].vertex[0]].x) + (Triangles[i].facenormal.y * vertex[Triangles[i].vertex[0]].y) + (Triangles[i].facenormal.z * vertex[Triangles[i].vertex[0]].z))) / Triangles[i].facenormal.y);
- if (*opacity - distance / 10 > 0) {
+ if ((*opacity - distance / 10) > 0) {
Decal decal(*where, atype, *opacity - distance / 10, *rotation, *size, *this, i, 0);
if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
for (unsigned int i = 0; i < Triangles.size(); i++) {
distance = abs(((Triangles[i].facenormal.x * where.x) + (Triangles[i].facenormal.y * where.y) + (Triangles[i].facenormal.z * where.z) - ((Triangles[i].facenormal.x * vertex[Triangles[i].vertex[0]].x) + (Triangles[i].facenormal.y * vertex[Triangles[i].vertex[0]].y) + (Triangles[i].facenormal.z * vertex[Triangles[i].vertex[0]].z))));
if (distance < .02 && abs(Triangles[i].facenormal.y) > abs(Triangles[i].facenormal.x) && abs(Triangles[i].facenormal.y) > abs(Triangles[i].facenormal.z)) {
- if (opacity - distance / 10 > 0) {
+ if ((opacity - distance / 10) > 0) {
Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 0);
if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
}
}
} else if (distance < .02 && abs(Triangles[i].facenormal.x) > abs(Triangles[i].facenormal.y) && abs(Triangles[i].facenormal.x) > abs(Triangles[i].facenormal.z)) {
- if (opacity - distance / 10 > 0) {
+ if ((opacity - distance / 10) > 0) {
Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 1);
if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
}
}
} else if (distance < .02 && abs(Triangles[i].facenormal.z) > abs(Triangles[i].facenormal.y) && abs(Triangles[i].facenormal.z) > abs(Triangles[i].facenormal.x)) {
- if (opacity - distance / 10 > 0) {
+ if ((opacity - distance / 10) > 0) {
Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 2);
if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
}
}
+const XYZ& Model::getTriangleVertex(unsigned triangleId, unsigned vertexId) const
+{
+ return vertex[Triangles[triangleId].vertex[vertexId]];
+}
+
void Model::deleteDeadDecals()
{
for (int i = decals.size() - 1; i >= 0; i--) {
if (vArray)
free(vArray);
vArray = 0;
+
+ decals.clear();
}
Model::Model()
: vertexNum(0),
- hastexture(0),
- type(0), oldtype(0),
+ type(nothing),
owner(0),
vertex(0),
normals(0),
- vArray(0)
+ vArray(0),
+ color(0),
+ boundingspherecenter(),
+ boundingsphereradius(0),
+ flat(false)
{
memset(&modelTexture, 0, sizeof(modelTexture));
- color = 0;
-
- boundingspherecenter = 0;
- boundingsphereradius = 0;
-
- flat = 0;
-
- type = nothing;
}