{
float placex, placez;
if (which == 0) {
- placex = vertex[model.Triangles[i].vertex[0]].x;
- placez = vertex[model.Triangles[i].vertex[0]].z;
+ placex = model.vertex[model.Triangles[i].vertex[0]].x;
+ placez = model.vertex[model.Triangles[i].vertex[0]].z;
texcoords[0][0] = (placex - position.x) / (size) / 2 + .5;
texcoords[0][1] = (placez - position.z) / (size) / 2 + .5;
vertex[0].x = placex;
vertex[0].z = placez;
- vertex[0].y = vertex[model.Triangles[i].vertex[0]].y;
+ vertex[0].y = model.vertex[model.Triangles[i].vertex[0]].y;
- placex = vertex[model.Triangles[i].vertex[1]].x;
- placez = vertex[model.Triangles[i].vertex[1]].z;
+ placex = model.vertex[model.Triangles[i].vertex[1]].x;
+ placez = model.vertex[model.Triangles[i].vertex[1]].z;
texcoords[1][0] = (placex - position.x) / (size) / 2 + .5;
texcoords[1][1] = (placez - position.z) / (size) / 2 + .5;
vertex[1].x = placex;
vertex[1].z = placez;
- vertex[1].y = vertex[model.Triangles[i].vertex[1]].y;
+ vertex[1].y = model.vertex[model.Triangles[i].vertex[1]].y;
- placex = vertex[model.Triangles[i].vertex[2]].x;
- placez = vertex[model.Triangles[i].vertex[2]].z;
+ placex = model.vertex[model.Triangles[i].vertex[2]].x;
+ placez = model.vertex[model.Triangles[i].vertex[2]].z;
texcoords[2][0] = (placex - position.x) / (size) / 2 + .5;
texcoords[2][1] = (placez - position.z) / (size) / 2 + .5;
vertex[2].x = placex;
vertex[2].z = placez;
- vertex[2].y = vertex[model.Triangles[i].vertex[2]].y;
+ vertex[2].y = model.vertex[model.Triangles[i].vertex[2]].y;
} else if (which == 1) {
- placex = vertex[model.Triangles[i].vertex[0]].y;
- placez = vertex[model.Triangles[i].vertex[0]].z;
+ placex = model.vertex[model.Triangles[i].vertex[0]].y;
+ placez = model.vertex[model.Triangles[i].vertex[0]].z;
texcoords[0][0] = (placex - position.y) / (size) / 2 + .5;
texcoords[0][1] = (placez - position.z) / (size) / 2 + .5;
- vertex[0].x = vertex[model.Triangles[i].vertex[0]].x;
+ vertex[0].x = model.vertex[model.Triangles[i].vertex[0]].x;
vertex[0].z = placez;
vertex[0].y = placex;
- placex = vertex[model.Triangles[i].vertex[1]].y;
- placez = vertex[model.Triangles[i].vertex[1]].z;
+ placex = model.vertex[model.Triangles[i].vertex[1]].y;
+ placez = model.vertex[model.Triangles[i].vertex[1]].z;
texcoords[1][0] = (placex - position.y) / (size) / 2 + .5;
texcoords[1][1] = (placez - position.z) / (size) / 2 + .5;
- vertex[1].x = vertex[model.Triangles[i].vertex[1]].x;
+ vertex[1].x = model.vertex[model.Triangles[i].vertex[1]].x;
vertex[1].z = placez;
vertex[1].y = placex;
- placex = vertex[model.Triangles[i].vertex[2]].y;
- placez = vertex[model.Triangles[i].vertex[2]].z;
+ placex = model.vertex[model.Triangles[i].vertex[2]].y;
+ placez = model.vertex[model.Triangles[i].vertex[2]].z;
texcoords[2][0] = (placex - position.y) / (size) / 2 + .5;
texcoords[2][1] = (placez - position.z) / (size) / 2 + .5;
- vertex[2].x = vertex[model.Triangles[i].vertex[2]].x;
+ vertex[2].x = model.vertex[model.Triangles[i].vertex[2]].x;
vertex[2].z = placez;
vertex[2].y = placex;
} else {
- placex = vertex[model.Triangles[i].vertex[0]].x;
- placez = vertex[model.Triangles[i].vertex[0]].y;
+ placex = model.vertex[model.Triangles[i].vertex[0]].x;
+ placez = model.vertex[model.Triangles[i].vertex[0]].y;
texcoords[0][0] = (placex - position.x) / (size) / 2 + .5;
texcoords[0][1] = (placez - position.y) / (size) / 2 + .5;
vertex[0].x = placex;
- vertex[0].z = vertex[model.Triangles[i].vertex[0]].z;
+ vertex[0].z = model.vertex[model.Triangles[i].vertex[0]].z;
vertex[0].y = placez;
- placex = vertex[model.Triangles[i].vertex[1]].x;
- placez = vertex[model.Triangles[i].vertex[1]].y;
+ placex = model.vertex[model.Triangles[i].vertex[1]].x;
+ placez = model.vertex[model.Triangles[i].vertex[1]].y;
texcoords[1][0] = (placex - position.x) / (size) / 2 + .5;
texcoords[1][1] = (placez - position.y) / (size) / 2 + .5;
vertex[1].x = placex;
- vertex[1].z = vertex[model.Triangles[i].vertex[1]].z;
+ vertex[1].z = model.vertex[model.Triangles[i].vertex[1]].z;
vertex[1].y = placez;
- placex = vertex[model.Triangles[i].vertex[2]].x;
- placez = vertex[model.Triangles[i].vertex[2]].y;
+ placex = model.vertex[model.Triangles[i].vertex[2]].x;
+ placez = model.vertex[model.Triangles[i].vertex[2]].y;
texcoords[2][0] = (placex - position.x) / (size) / 2 + .5;
texcoords[2][1] = (placez - position.y) / (size) / 2 + .5;
vertex[2].x = placex;
- vertex[2].z = vertex[model.Triangles[i].vertex[2]].z;
+ vertex[2].z = model.vertex[model.Triangles[i].vertex[2]].z;
vertex[2].y = placez;
}
}
LOG(std::string("Loading decal...") + Folders::getResourcePath(filename));
type = decalstype;
- decals.clear();
color = 0;
tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
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))
if (vArray)
free(vArray);
vArray = 0;
+
+ decals.clear();
}
Model::Model()