starty = i;
}
- if (startx < 0)startx = 0;
- if (starty < 0)starty = 0;
- if (endx > size - 1)endx = size - 1;
- if (endy > size - 1)endy = size - 1;
+ if (startx < 0)
+ startx = 0;
+ if (starty < 0)
+ starty = 0;
+ if (endx > size - 1)
+ endx = size - 1;
+ if (endy > size - 1)
+ endy = size - 1;
for (i = startx; i <= endx; i++) {
for (j = starty; j <= endy; j++) {
highest = -1000;
lowest = 1000;
for (k = 0; k < 2; k++) {
- if (heightmap[i + k][j] > highest)highest = heightmap[i + k][j];
- if (heightmap[i + k][j] < lowest)lowest = heightmap[i + k][j];
- if (heightmap[i + k][j + 1] > highest)highest = heightmap[i + k][j + 1];
- if (heightmap[i + k][j + 1] < lowest)lowest = heightmap[i + k][j + 1];
+ if (heightmap[i + k][j] > highest)
+ highest = heightmap[i + k][j];
+ if (heightmap[i + k][j] < lowest)
+ lowest = heightmap[i + k][j];
+ if (heightmap[i + k][j + 1] > highest)
+ highest = heightmap[i + k][j + 1];
+ if (heightmap[i + k][j + 1] < lowest)
+ lowest = heightmap[i + k][j + 1];
}
if ((p1.y <= highest || p2.y <= highest) && (p1.y >= lowest || p2.y >= lowest)) {
triangles[0].x = i;
vertex.z = j * scale;
vertex.y = heightmap[i][j] * scale;
distance = distsq(&viewer, &vertex);
- if (distance > viewdistsquared)distance = viewdistsquared;
+ if (distance > viewdistsquared)
+ distance = viewdistsquared;
colors[i][j][3] = (viewdistsquared - (distance - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
}
}
vertex.z = j * scale;
vertex.y = heightmap[i][j] * scale;
distance = distsq(&viewer, &vertex);
- if (distance > viewdistsquared)distance = viewdistsquared;
+ if (distance > viewdistsquared)
+ distance = viewdistsquared;
colors[i][j][3] = (viewdistsquared - (distance - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
}
}
minypatch[whichx][whichy] = 10000;
for (a = 0; a < size / subdivision; a++) {
for (b = 0; b < size / subdivision; b++) {
- if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale > maxypatch[whichx][whichy]) maxypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
- if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale < minypatch[whichx][whichy]) minypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
+ if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale > maxypatch[whichx][whichy])
+ maxypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
+ if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale < minypatch[whichx][whichy])
+ minypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
}
}
heightypatch[whichx][whichy] = (maxypatch[whichx][whichy] - minypatch[whichx][whichy]);
- if (heightypatch[whichx][whichy] < size / subdivision * scale)heightypatch[whichx][whichy] = size / subdivision * scale;
+ if (heightypatch[whichx][whichy] < size / subdivision * scale)
+ heightypatch[whichx][whichy] = size / subdivision * scale;
avgypatch[whichx][whichy] = (minypatch[whichx][whichy] + maxypatch[whichx][whichy]) / 2;
for (i = whichx * size / subdivision; i < (whichx + 1)*size / subdivision - 1; i++) {
bool Terrain::load(const char *fileName)
{
- static long i, j;
+ static long i, j;
static long x, y;
static float patch_size;
}
}
texture.bpp = 24;
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
texdetail = temptexdetail;
}
}
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
float slopeness;
textureness[i][j] = -1;
}
}
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
for (i = 0; i < size; i++) {
slopeness = heightmap[i][j] - heightmap[i][j - 1];
}
opacityother[i][j] = slopeness * slopeness * 2;
- if (opacityother[i][j] > 1)opacityother[i][j] = 1;
+ if (opacityother[i][j] > 1)
+ opacityother[i][j] = 1;
opacityother[i][j] -= (float)abs(Random() % 100) / 300;
}
if (environment == desertenvironment) {
slopeness = heightmap[i][j] - heightmap[i][j - 1];
}
opacityother[i][j] = slopeness * slopeness * 2;
- if (opacityother[i][j] > 1)opacityother[i][j] = 1;
+ if (opacityother[i][j] > 1)
+ opacityother[i][j] = 1;
opacityother[i][j] -= (float)abs(Random() % 100) / 300;
}
if (environment == grassyenvironment) {
slopeness = heightmap[i][j] - heightmap[i][j + 1];
}
opacityother[i][j] = slopeness * slopeness * 10;
- if (opacityother[i][j] > 1)opacityother[i][j] = 1;
+ if (opacityother[i][j] > 1)
+ opacityother[i][j] = 1;
opacityother[i][j] -= (float)abs(Random() % 100) / 100;
}
}
}
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
for (i = 0; i < size; i++) {
for (j = 0; j < size; j++) {
}
}
}
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
/*float total;
int todivide;
for(j=0;j<size;j++){
total=0;
todivide=0;
- if(i!=0){ total+=opacityother[j][i-1]; todivide++;}
- if(i!=size-1){ total+=opacityother[j][i+1]; todivide++;}
- if(j!=0){ total+=opacityother[j-1][i]; todivide++;}
- if(j!=size-1){ total+=opacityother[j+1][i]; todivide++;}
- if(i!=0&&j!=0){ total+=opacityother[j-1][i-1]; todivide++;}
- if(i!=size-1&&j!=0){ total+=opacityother[j-1][i+1]; todivide++;}
- if(j!=size-1&&i!=size-1){ total+=opacityother[j+1][i+1]; todivide++;}
- if(j!=size-1&&i!=0){ total+=opacityother[j+1][i-1]; todivide++;}
+ if(i!=0){total+=opacityother[j][i-1]; todivide++;}
+ if(i!=size-1){total+=opacityother[j][i+1]; todivide++;}
+ if(j!=0){total+=opacityother[j-1][i]; todivide++;}
+ if(j!=size-1){total+=opacityother[j+1][i]; todivide++;}
+ if(i!=0&&j!=0){total+=opacityother[j-1][i-1]; todivide++;}
+ if(i!=size-1&&j!=0){total+=opacityother[j-1][i+1]; todivide++;}
+ if(j!=size-1&&i!=size-1){total+=opacityother[j+1][i+1]; todivide++;}
+ if(j!=size-1&&i!=0){total+=opacityother[j+1][i-1]; todivide++;}
total+=opacityother[j][i]; todivide++;
opacityother[j][i]=total/(float)todivide;
for (i = 0; i < size; i++) {
for (j = 0; j < size; j++) {
- if (opacityother[i][j] < .1)opacityother[i][j] = 0;
+ if (opacityother[i][j] < .1)
+ opacityother[i][j] = 0;
if (textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == -1) {
- if (!opacityother[i][j])textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allfirst;
- if (opacityother[i][j] == 1)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allsecond;
+ if (!opacityother[i][j])
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allfirst;
+ if (opacityother[i][j] == 1)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allsecond;
}
- if (opacityother[i][j] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
x = i;
y = j;
if (i > 0) {
i--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
if (j > 0) {
j--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
j++;
}
if (j < size - 1) {
j++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
j--;
}
i++;
if (i < size - 1) {
i++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
if (j > 0) {
j--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
j++;
}
if (j < size - 1) {
j++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
j--;
}
i--;
if (j > 0) {
j--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
j++;
}
if (j < size - 1) {
j++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
j--;
}
}
}
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
patch_size = size / subdivision;
patch_elements = (patch_size) * (patch_size) * 54;
void Terrain::drawpatch(int whichx, int whichy, float opacity)
{
- if (opacity >= 1)glDisable(GL_BLEND);
+ if (opacity >= 1)
+ glDisable(GL_BLEND);
if (opacity < 1) {
glEnable(GL_BLEND);
UpdateTransparency(whichx, whichy);
pointx /= scale;
pointz /= scale;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return 0;
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ return 0;
startpoint.x = pointx;
startpoint.y = -1000;
point2x /= scale;
point2z /= scale;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return 0;
- if (point2x >= size - 1 || point2z >= size - 1 || point2x <= 0 || point2z <= 0)return 0;
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ return 0;
+ if (point2x >= size - 1 || point2z >= size - 1 || point2x <= 0 || point2z <= 0)
+ return 0;
startpoint.x = point2x;
startpoint.y = -1000;
pointx /= scale;
pointz /= scale;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return 0;
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ return 0;
tilex = pointx;
tiley = pointz;
pointz /= scale;
height1 = 0;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return height1;
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ return height1;
tilex = pointx;
tiley = pointz;
pointz /= scale;
height1 = 0;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return height1;
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ return height1;
tilex = pointx;
tiley = pointz;
//Only nearby blocks
beginx = (viewer.x - viewdistance) / (patch_size) - 1;
- if (beginx < 0)beginx = 0;
+ if (beginx < 0)
+ beginx = 0;
beginz = (viewer.z - viewdistance) / (patch_size) - 1;
- if (beginz < 0)beginz = 0;
+ if (beginz < 0)
+ beginz = 0;
endx = (viewer.x + viewdistance) / (patch_size) + 1;
- if (endx > subdivision)endx = subdivision;
+ if (endx > subdivision)
+ endx = subdivision;
endz = (viewer.z + viewdistance) / (patch_size) + 1;
- if (endz > subdivision)endz = subdivision;
+ if (endz > subdivision)
+ endz = subdivision;
if (!layer) {
for (i = beginx; i < endx; i++) {
if (opacity == 1 && j != subdivision && i != subdivision)
if (distance[i + 1][j + 1] > viewdistsquared * fadestart - viewdistsquared)
opacity = 0;
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (frustum.CubeInFrustum(i * patch_size + patch_size * .5, avgypatch[i][j], j * patch_size + patch_size * .5, heightypatch[i][j] / 2)) {
if (environment == desertenvironment && distance[i][j] > viewdistsquared / 4)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(0);
for (i = 0; i < numdecals; i++) {
- if (decaltype[i] == blooddecalfast && decalalivetime[i] < 2)decalalivetime[i] = 2;
+ if (decaltype[i] == blooddecalfast && decalalivetime[i] < 2)
+ decalalivetime[i] = 2;
if ((decaltype[i] == shadowdecal || decaltype[i] == shadowdecalpermanent) && decaltype[i] != lasttype) {
shadowtexture.bind();
if (!blend) {
}
if (decaltype[i] == shadowdecal || decaltype[i] == shadowdecalpermanent) {
distancemult = (viewdistsquared - (distsq(&viewer, &decalposition[i]) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
- if (distancemult >= 1)glColor4f(1, 1, 1, decalopacity[i]);
- if (distancemult < 1)glColor4f(1, 1, 1, decalopacity[i]*distancemult);
+ if (distancemult >= 1)
+ glColor4f(1, 1, 1, decalopacity[i]);
+ if (distancemult < 1)
+ glColor4f(1, 1, 1, decalopacity[i]*distancemult);
}
if (decaltype[i] == footprintdecal || decaltype[i] == bodyprintdecal) {
distancemult = (viewdistsquared - (distsq(&viewer, &decalposition[i]) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
if (distancemult >= 1) {
glColor4f(1, 1, 1, decalopacity[i]);
- if (decalalivetime[i] > 3)glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2);
+ if (decalalivetime[i] > 3)
+ glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2);
}
if (distancemult < 1) {
glColor4f(1, 1, 1, decalopacity[i]*distancemult);
- if (decalalivetime[i] > 3)glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2 * distancemult);
+ if (decalalivetime[i] > 3)
+ glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2 * distancemult);
}
}
if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow)) {
distancemult = (viewdistsquared - (distsq(&viewer, &decalposition[i]) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
if (distancemult >= 1) {
glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]);
- if (decalalivetime[i] < 4)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*.25);
- if (decalalivetime[i] > 58)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2);
+ if (decalalivetime[i] < 4)
+ glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*.25);
+ if (decalalivetime[i] > 58)
+ glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2);
}
if (distancemult < 1) {
glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*distancemult);
- if (decalalivetime[i] < 4)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*distancemult * .25);
- if (decalalivetime[i] > 58)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2 * distancemult);
+ if (decalalivetime[i] < 4)
+ glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*distancemult * .25);
+ if (decalalivetime[i] > 58)
+ glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2 * distancemult);
}
}
lasttype = decaltype[i];
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
+ glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glBegin(GL_TRIANGLES);
for (int j = 0; j < 3; j++) {
}
for (i = numdecals - 1; i >= 0; i--) {
decalalivetime[i] += multiplier;
- if (decaltype[i] == blooddecalslow)decalalivetime[i] -= multiplier * 2 / 3;
- if (decaltype[i] == blooddecalfast)decalalivetime[i] += multiplier * 4;
- if (decaltype[i] == shadowdecal)DeleteDecal(i);
- if (decaltype[i] == footprintdecal && decalalivetime[i] >= 5)DeleteDecal(i);
- if (decaltype[i] == bodyprintdecal && decalalivetime[i] >= 5)DeleteDecal(i);
- if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow) && decalalivetime[i] >= 60)DeleteDecal(i);
+ if (decaltype[i] == blooddecalslow)
+ decalalivetime[i] -= multiplier * 2 / 3;
+ if (decaltype[i] == blooddecalfast)
+ decalalivetime[i] += multiplier * 4;
+ if (decaltype[i] == shadowdecal)
+ DeleteDecal(i);
+ if (decaltype[i] == footprintdecal && decalalivetime[i] >= 5)
+ DeleteDecal(i);
+ if (decaltype[i] == bodyprintdecal && decalalivetime[i] >= 5)
+ DeleteDecal(i);
+ if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow) && decalalivetime[i] >= 60)
+ DeleteDecal(i);
}
glAlphaFunc(GL_GREATER, 0.0001);
}
rot = getLighting(where.x, where.z);
decalbrightness[numdecals] = (rot.x + rot.y + rot.z) / 3;
- if (decalbrightness[numdecals] < .4)decalbrightness[numdecals] = .4;
+ if (decalbrightness[numdecals] < .4)
+ decalbrightness[numdecals] = .4;
if (environment == grassyenvironment) {
decalbrightness[numdecals] *= .6;
}
- if (decalbrightness[numdecals] > 1)decalbrightness[numdecals] = 1;
+ if (decalbrightness[numdecals] > 1)
+ decalbrightness[numdecals] = 1;
decalbright = decalbrightness[numdecals];
decalposition[numdecals] = where;
if (!(decaltexcoords[numdecals][0][1] < 0 && decaltexcoords[numdecals][1][1] < 0 && decaltexcoords[numdecals][2][1] < 0))
if (!(decaltexcoords[numdecals][0][0] > 1 && decaltexcoords[numdecals][1][0] > 1 && decaltexcoords[numdecals][2][0] > 1))
if (!(decaltexcoords[numdecals][0][1] > 1 && decaltexcoords[numdecals][1][1] > 1 && decaltexcoords[numdecals][2][1] > 1))
- if (numdecals < max_decals - 1)numdecals++;
+ if (numdecals < max_decals - 1)
+ numdecals++;
decalbrightness[numdecals] = decalbright;
if (!(decaltexcoords[numdecals][0][1] < 0 && decaltexcoords[numdecals][1][1] < 0 && decaltexcoords[numdecals][2][1] < 0))
if (!(decaltexcoords[numdecals][0][0] > 1 && decaltexcoords[numdecals][1][0] > 1 && decaltexcoords[numdecals][2][0] > 1))
if (!(decaltexcoords[numdecals][0][1] > 1 && decaltexcoords[numdecals][1][1] > 1 && decaltexcoords[numdecals][2][1] > 1))
- if (numdecals < max_decals - 1)numdecals++;
+ if (numdecals < max_decals - 1)
+ numdecals++;
}
}
*/
brightness = dotproduct(&lightloc, &normals[i][j]);
- if (brightness > 1)brightness = 1;
- if (brightness < 0)brightness = 0;
+ if (brightness > 1)
+ brightness = 1;
+ if (brightness < 0)
+ brightness = 0;
colors[i][j][0] = light.color[0] * brightness + light.ambient[0];
colors[i][j][1] = light.color[1] * brightness + light.ambient[1];
colors[i][j][2] = light.color[2] * brightness + light.ambient[2];
- if (colors[i][j][0] > 1)colors[i][j][0] = 1;
- if (colors[i][j][1] > 1)colors[i][j][1] = 1;
- if (colors[i][j][2] > 1)colors[i][j][2] = 1;
- if (colors[i][j][0] < 0)colors[i][j][0] = 0;
- if (colors[i][j][1] < 0)colors[i][j][1] = 0;
- if (colors[i][j][2] < 0)colors[i][j][2] = 0;
+ if (colors[i][j][0] > 1) colors[i][j][0] = 1;
+ if (colors[i][j][1] > 1) colors[i][j][1] = 1;
+ if (colors[i][j][2] > 1) colors[i][j][2] = 1;
+ if (colors[i][j][0] < 0) colors[i][j][0] = 0;
+ if (colors[i][j][1] < 0) colors[i][j][1] = 0;
+ if (colors[i][j][2] < 0) colors[i][j][2] = 0;
}
}
}
}
}
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
}
brightness = dotproduct(&lightloc, &normals[i][j]);
- if (shadowed)brightness *= 1 - shadowed;
+ if (shadowed)
+ brightness *= 1 - shadowed;
- if (brightness > 1)brightness = 1;
- if (brightness < 0)brightness = 0;
+ if (brightness > 1)
+ brightness = 1;
+ if (brightness < 0)
+ brightness = 0;
colors[i][j][0] = light.color[0] * brightness + light.ambient[0];
colors[i][j][1] = light.color[1] * brightness + light.ambient[1];
colors[i][j][2] = light.color[2] * brightness + light.ambient[2];
- if (colors[i][j][0] > 1)colors[i][j][0] = 1;
- if (colors[i][j][1] > 1)colors[i][j][1] = 1;
- if (colors[i][j][2] > 1)colors[i][j][2] = 1;
- if (colors[i][j][0] < 0)colors[i][j][0] = 0;
- if (colors[i][j][1] < 0)colors[i][j][1] = 0;
- if (colors[i][j][2] < 0)colors[i][j][2] = 0;
+ if (colors[i][j][0] > 1) colors[i][j][0] = 1;
+ if (colors[i][j][1] > 1) colors[i][j][1] = 1;
+ if (colors[i][j][2] > 1) colors[i][j][2] = 1;
+ if (colors[i][j][0] < 0) colors[i][j][0] = 0;
+ if (colors[i][j][1] < 0) colors[i][j][1] = 0;
+ if (colors[i][j][2] < 0) colors[i][j][2] = 0;
}
}
- if (visibleloading) Game::LoadingScreen();
+ if (visibleloading)
+ Game::LoadingScreen();
//Smooth shadows
for (i = 0; i < size; i++) {