other fixes
This commit is contained in:
@@ -34,6 +34,11 @@ Heightmap::Heightmap(const float& t_minHeight, const float& t_maxHeight,
|
||||
delete data;
|
||||
}
|
||||
|
||||
bool Heightmap::isOutside(const Vec4& position) const {
|
||||
return position.x <= leftUp.x || position.x >= rightDown.x ||
|
||||
position.z <= leftUp.z || position.z >= rightDown.z;
|
||||
}
|
||||
|
||||
Heightmap::~Heightmap() {
|
||||
if (map) {
|
||||
for (int i = 0; i < mapHeight; i++) {
|
||||
@@ -43,7 +48,7 @@ Heightmap::~Heightmap() {
|
||||
}
|
||||
}
|
||||
|
||||
const float& Heightmap::getHeightOffset(const Vec4& playerPosition) {
|
||||
const float& Heightmap::getHeightOffset(const Vec4& playerPosition) const {
|
||||
float widthPercentage = getWidthPercentage(playerPosition);
|
||||
float heightPercentage = getHeightPercentage(playerPosition);
|
||||
|
||||
@@ -56,11 +61,11 @@ const float& Heightmap::getHeightOffset(const Vec4& playerPosition) {
|
||||
return map[x][y];
|
||||
}
|
||||
|
||||
float Heightmap::getWidthPercentage(const Vec4& playerPosition) {
|
||||
float Heightmap::getWidthPercentage(const Vec4& playerPosition) const {
|
||||
return (playerPosition.x - leftUp.x) / (rightDown.x - leftUp.x);
|
||||
}
|
||||
|
||||
float Heightmap::getHeightPercentage(const Vec4& playerPosition) {
|
||||
float Heightmap::getHeightPercentage(const Vec4& playerPosition) const {
|
||||
return (playerPosition.z - leftUp.z) / (rightDown.z - leftUp.z);
|
||||
}
|
||||
|
||||
@@ -100,7 +105,7 @@ void Heightmap::allocateMap(const unsigned char* data, const int& width,
|
||||
}
|
||||
|
||||
float Heightmap::getGameHeight(const u8& inputColor, const u8& minColor,
|
||||
const u8& maxColor) {
|
||||
const u8& maxColor) const {
|
||||
const float mapRange = maxColor - minColor;
|
||||
const float gameRange = maxHeight - minHeight;
|
||||
|
||||
|
||||
@@ -18,29 +18,29 @@ using Tyra::ObjLoaderOptions;
|
||||
|
||||
namespace Demo {
|
||||
Terrain::Terrain(TextureRepository* repo)
|
||||
: heightmap(-5.0F, // Min height
|
||||
450.0F, // Max height
|
||||
Vec4(-784.6F, 0.0F, -1648.0F, 1.0F), // Left up
|
||||
Vec4(1144.0F, 0.0F, 1772.3F, 1.0F) // Right down
|
||||
: heightmap(20.0F, // Min height
|
||||
320.0F, // Max height
|
||||
Vec4(-750.0F, 0.0F, -1400.0F, 1.0F), // Left up
|
||||
Vec4(920.0F, 0.0F, 1520.0F, 1.0F) // Right down
|
||||
) {
|
||||
// ObjLoader loader;
|
||||
ObjLoader loader;
|
||||
|
||||
// ObjLoaderOptions objOptions;
|
||||
// objOptions.flipUVs = true;
|
||||
// objOptions.scale = 100.0F;
|
||||
ObjLoaderOptions objOptions;
|
||||
objOptions.flipUVs = true;
|
||||
objOptions.scale = 100.0F;
|
||||
|
||||
// auto* data = loader.load(
|
||||
// FileUtils::fromCwd("game/models/terrain/terrain.obj"), objOptions);
|
||||
// data->normalsEnabled = false;
|
||||
// mesh = new StaticMesh(*data);
|
||||
auto* data = loader.load(
|
||||
FileUtils::fromCwd("game/models/terrain/terrain.obj"), objOptions);
|
||||
data->normalsEnabled = false;
|
||||
mesh = new StaticMesh(*data);
|
||||
|
||||
// delete data;
|
||||
delete data;
|
||||
|
||||
// repo->addByMesh(mesh, FileUtils::fromCwd("game/models/terrain/"), "png");
|
||||
repo->addByMesh(mesh, FileUtils::fromCwd("game/models/terrain/"), "png");
|
||||
|
||||
// allocateOptions();
|
||||
allocateOptions();
|
||||
|
||||
// pair = new RendererStaticPair{mesh, options};
|
||||
pair = new RendererStaticPair{mesh, options};
|
||||
}
|
||||
|
||||
float Terrain::getHeightOffset(const Vec4& playerPosition) {
|
||||
|
||||
Reference in New Issue
Block a user