camera max height/ default are calculated based on the max height of a map
This commit is contained in:
parent
12dcc54c5a
commit
91abdd3ed4
|
@ -549,6 +549,10 @@ void Game::init(bool initForPreviewOnly)
|
||||||
|
|
||||||
gameCamera.init(map->getW(), map->getH());
|
gameCamera.init(map->getW(), map->getH());
|
||||||
|
|
||||||
|
if(gameCamera.getCalculatedDefault()<map->getMaxMapHeight()+13.0f){
|
||||||
|
gameCamera.setCalculatedDefault(map->getMaxMapHeight()+13.0f);
|
||||||
|
}
|
||||||
|
|
||||||
if(world.getThisFaction() != NULL) {
|
if(world.getThisFaction() != NULL) {
|
||||||
const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex());
|
const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex());
|
||||||
gameCamera.setPos(Vec2f(v.x, v.y));
|
gameCamera.setPos(Vec2f(v.x, v.y));
|
||||||
|
|
|
@ -46,6 +46,7 @@ const float GameCamera::centerOffsetZ= 8.0f;
|
||||||
GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
|
GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
|
||||||
destPos(0.f, defaultHeight, 0.f), destAng(startingVAng, startingHAng) {
|
destPos(0.f, defaultHeight, 0.f), destAng(startingVAng, startingHAng) {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
calculatedDefault=defaultHeight;
|
||||||
state= sGame;
|
state= sGame;
|
||||||
|
|
||||||
cacheVisibleQuad.clear();
|
cacheVisibleQuad.clear();
|
||||||
|
@ -88,6 +89,14 @@ void GameCamera::setMaxHeight(float value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameCamera::setCalculatedDefault(float calculatedDefault){
|
||||||
|
this->calculatedDefault= calculatedDefault;
|
||||||
|
if(maxHeight>0 && maxHeight<calculatedDefault){
|
||||||
|
setMaxHeight(calculatedDefault);
|
||||||
|
}
|
||||||
|
resetPosition();
|
||||||
|
}
|
||||||
|
|
||||||
void GameCamera::init(int limitX, int limitY){
|
void GameCamera::init(int limitX, int limitY){
|
||||||
this->limitX= limitX;
|
this->limitX= limitX;
|
||||||
this->limitY= limitY;
|
this->limitY= limitY;
|
||||||
|
@ -239,7 +248,7 @@ void GameCamera::switchState(){
|
||||||
state= sGame;
|
state= sGame;
|
||||||
destAng.x = startingVAng;
|
destAng.x = startingVAng;
|
||||||
destAng.y = startingHAng;
|
destAng.y = startingHAng;
|
||||||
destPos.y = defaultHeight;
|
destPos.y = calculatedDefault;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +256,7 @@ void GameCamera::resetPosition(){
|
||||||
state= sGame;
|
state= sGame;
|
||||||
destAng.x = startingVAng;
|
destAng.x = startingVAng;
|
||||||
destAng.y = startingHAng;
|
destAng.y = startingHAng;
|
||||||
destPos.y = defaultHeight;
|
destPos.y = calculatedDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameCamera::centerXZ(float x, float z){
|
void GameCamera::centerXZ(float x, float z){
|
||||||
|
|
|
@ -83,6 +83,8 @@ private:
|
||||||
float maxVAng;
|
float maxVAng;
|
||||||
float fov;
|
float fov;
|
||||||
|
|
||||||
|
float calculatedDefault;
|
||||||
|
|
||||||
int MaxVisibleQuadItemCache;
|
int MaxVisibleQuadItemCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -130,6 +132,10 @@ public:
|
||||||
|
|
||||||
void setClampBounds(bool value) { clampBounds = value; }
|
void setClampBounds(bool value) { clampBounds = value; }
|
||||||
void setMaxHeight(float value);
|
void setMaxHeight(float value);
|
||||||
|
float getCalculatedDefault() const{ return calculatedDefault; }
|
||||||
|
void setCalculatedDefault(float calculatedDefault);
|
||||||
|
|
||||||
|
float getMaxHeight() const {return maxHeight;}
|
||||||
void setFov(float value) { fov = value; }
|
void setFov(float value) { fov = value; }
|
||||||
void setMinVAng(float value) { minVAng = value; }
|
void setMinVAng(float value) { minVAng = value; }
|
||||||
void setMaxVAng(float value) { maxVAng = value; }
|
void setMaxVAng(float value) { maxVAng = value; }
|
||||||
|
|
|
@ -273,6 +273,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||||
|
|
||||||
void Map::init(Tileset *tileset) {
|
void Map::init(Tileset *tileset) {
|
||||||
Logger::getInstance().add("Heightmap computations", true);
|
Logger::getInstance().add("Heightmap computations", true);
|
||||||
|
maxMapHeight=0.0f;
|
||||||
smoothSurface(tileset);
|
smoothSurface(tileset);
|
||||||
computeNormals();
|
computeNormals();
|
||||||
computeInterpolatedHeights();
|
computeInterpolatedHeights();
|
||||||
|
@ -1094,6 +1095,7 @@ void Map::computeInterpolatedHeights(){
|
||||||
|
|
||||||
void Map::smoothSurface(Tileset *tileset) {
|
void Map::smoothSurface(Tileset *tileset) {
|
||||||
float *oldHeights = new float[getSurfaceCellArraySize()];
|
float *oldHeights = new float[getSurfaceCellArraySize()];
|
||||||
|
int arraySize=getSurfaceCellArraySize();
|
||||||
|
|
||||||
for (int i = 0; i < getSurfaceCellArraySize(); ++i) {
|
for (int i = 0; i < getSurfaceCellArraySize(); ++i) {
|
||||||
oldHeights[i] = surfaceCells[i].getHeight();
|
oldHeights[i] = surfaceCells[i].getHeight();
|
||||||
|
@ -1135,6 +1137,9 @@ void Map::smoothSurface(Tileset *tileset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
height /= numUsedToSmooth;
|
height /= numUsedToSmooth;
|
||||||
|
if(maxMapHeight<height){
|
||||||
|
maxMapHeight=height;
|
||||||
|
}
|
||||||
|
|
||||||
getSurfaceCell(i, j)->setHeight(height);
|
getSurfaceCell(i, j)->setHeight(height);
|
||||||
Object *object = getSurfaceCell(i, j)->getObject();
|
Object *object = getSurfaceCell(i, j)->getObject();
|
||||||
|
|
|
@ -166,6 +166,7 @@ private:
|
||||||
SurfaceCell *surfaceCells;
|
SurfaceCell *surfaceCells;
|
||||||
Vec2i *startLocations;
|
Vec2i *startLocations;
|
||||||
Checksum checksumValue;
|
Checksum checksumValue;
|
||||||
|
float maxMapHeight;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Map(Map&);
|
Map(Map&);
|
||||||
|
@ -194,6 +195,7 @@ public:
|
||||||
float getHeightFactor() const {return heightFactor;}
|
float getHeightFactor() const {return heightFactor;}
|
||||||
float getWaterLevel() const {return waterLevel;}
|
float getWaterLevel() const {return waterLevel;}
|
||||||
float getCliffLevel() const {return cliffLevel;}
|
float getCliffLevel() const {return cliffLevel;}
|
||||||
|
float getMaxMapHeight() const {return maxMapHeight;}
|
||||||
Vec2i getStartLocation(int locationIndex) const;
|
Vec2i getStartLocation(int locationIndex) const;
|
||||||
bool getSubmerged(const SurfaceCell *sc) const {return sc->getHeight()<waterLevel;}
|
bool getSubmerged(const SurfaceCell *sc) const {return sc->getHeight()<waterLevel;}
|
||||||
bool getSubmerged(const Cell *c) const {return c->getHeight()<waterLevel;}
|
bool getSubmerged(const Cell *c) const {return c->getHeight()<waterLevel;}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user