fixed minimap generation
|
Before Width: | Height: | Size: 837 B After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 754 B After Width: | Height: | Size: 756 B |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 11 KiB |
@@ -64,15 +64,25 @@ namespace battleship{
|
||||
}
|
||||
else{
|
||||
map->load(name);
|
||||
|
||||
int numPlayers = map->getNumSpawnPoints();
|
||||
int numVerts = 3 * map->getNodeParent()->getChild(0)->getMesh(0)->getMeshBase().numTris;
|
||||
oldLandmassVertHeights = new float[numVerts];
|
||||
|
||||
for(int i = 0; i < numPlayers; i++)
|
||||
game->addPlayer(new Player(0, 0, 0, Vector3(1, 1, 1)));
|
||||
|
||||
map->loadPlayersGameObjects();
|
||||
|
||||
MeshData meshData = map->getNodeParent()->getChild(0)->getMesh(0)->getMeshBase();
|
||||
int minId = 0, numVerts = 3 * meshData.numTris;
|
||||
oldLandmassVertHeights = new float[numVerts];
|
||||
|
||||
for(int i = 0; i < numVerts; i++){
|
||||
oldLandmassVertHeights[i] = meshData.vertices[i].pos->y;
|
||||
|
||||
if(oldLandmassVertHeights[i] < oldLandmassVertHeights[minId])
|
||||
minId = i;
|
||||
}
|
||||
|
||||
map->setBaseHeight(oldLandmassVertHeights[minId]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,16 +422,16 @@ namespace battleship{
|
||||
Vector3 mapSize = map->getMapSize(), cellSize = map->getCellSize();
|
||||
int width = int(mapSize.x / cellSize.x);
|
||||
int height = int(mapSize.z / cellSize.z);
|
||||
int numChannels = 3;
|
||||
int cellId = 0, numChannels = 3;
|
||||
int size = width * height * numChannels;
|
||||
int cellId = 0;
|
||||
float baseHeight = map->getBaseHeight();
|
||||
|
||||
u8 *imgData = new u8[size];
|
||||
|
||||
for(u8 *p = imgData; p != imgData + size; p+= numChannels, cellId++){
|
||||
float min = .6, max = 1.;
|
||||
float heightFactor = min + (max - min) * (cells[cellId].pos.y - baseHeight) / mapSize.y;
|
||||
float bottomCellHeight = cells[cellId].pos.y - map->getCellSize().y * cells[cellId].underWaterCellIds.size();
|
||||
float heightFactor = min + (max - min) * (bottomCellHeight - baseHeight) / mapSize.y;
|
||||
Vector3 color = (cells[cellId].type == Map::Cell::Type::WATER ? Vector3::VEC_K : Vector3::VEC_J);
|
||||
|
||||
*p = color.x * heightFactor * 255.f;
|
||||
|
||||