Compare commits
No commits in common. "27fb7a448c77a2b5cd3c73b1aabc88382a54e155" and "4afb9d6f4f0bdf8381cf06938c93ff0890310cd7" have entirely different histories.
27fb7a448c
...
4afb9d6f4f
@ -8,7 +8,7 @@ namespace ZL {
|
||||
int Environment::windowHeaderHeight = 0;
|
||||
int Environment::width = 0;
|
||||
int Environment::height = 0;
|
||||
float Environment::zoom = 18.f;
|
||||
float Environment::zoom = 14.f;
|
||||
|
||||
bool Environment::leftPressed = false;
|
||||
bool Environment::rightPressed = false;
|
||||
@ -36,8 +36,8 @@ Vector3f Environment::shipPosition = {0,0,0};
|
||||
float Environment::shipVelocity = 0.f;
|
||||
|
||||
|
||||
const float Environment::CONST_Z_NEAR = 5.f;
|
||||
const float Environment::CONST_Z_FAR = 5000.f;
|
||||
const float Environment::CONST_Z_NEAR = 10.f;
|
||||
const float Environment::CONST_Z_FAR = 10000.f;
|
||||
|
||||
|
||||
} // namespace ZL
|
||||
|
||||
18
Game.cpp
18
Game.cpp
@ -463,12 +463,8 @@ namespace ZL
|
||||
CheckGlError();
|
||||
|
||||
drawCubemap();
|
||||
planetObject.draw(renderer);
|
||||
if (planetObject.planetIsFar(Environment::shipPosition))
|
||||
{
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
drawShip();
|
||||
planetObject.draw(renderer);
|
||||
drawBoxes();
|
||||
|
||||
drawUI();
|
||||
@ -616,19 +612,11 @@ namespace ZL
|
||||
{
|
||||
if (event.key.keysym.sym == SDLK_i)
|
||||
{
|
||||
Environment::shipVelocity += 500.f;
|
||||
Environment::shipVelocity += 5000.f;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_k)
|
||||
{
|
||||
Environment::shipVelocity -= 500.f;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_o)
|
||||
{
|
||||
Environment::shipVelocity += 50.f;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_l)
|
||||
{
|
||||
Environment::shipVelocity -= 50.f;
|
||||
Environment::shipVelocity -= 5000.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,30 +6,30 @@
|
||||
|
||||
namespace ZL {
|
||||
|
||||
static constexpr float PLANET_RADIUS = 20000.f;
|
||||
static Vector3f PLANET_CENTER_OFFSET = Vector3f{ 0.f, 0.f, -45000.f };
|
||||
static constexpr float PLANET_RADIUS = 1000000.f;
|
||||
static Vector3f PLANET_CENTER_OFFSET = Vector3f{ 0.f, 0.f, -2250000.f };
|
||||
|
||||
// --- 1. Дальний диапазон (FAR) ---
|
||||
static constexpr float FAR_Z_NEAR = 2000.0f;
|
||||
static constexpr float FAR_Z_FAR = 200000.0f;
|
||||
static constexpr float FAR_Z_NEAR = 50000.0f;
|
||||
static constexpr float FAR_Z_FAR = 10000000.0f;
|
||||
|
||||
// Дистанция, где НАЧИНАЕТСЯ переход FAR -> MIDDLE
|
||||
static constexpr float TRANSITION_FAR_START = 3000.0f;
|
||||
static constexpr float TRANSITION_FAR_START = 400000.0f;
|
||||
|
||||
// --- 2. Средний диапазон (MIDDLE) ---
|
||||
static constexpr float MIDDLE_Z_NEAR = 200.f;
|
||||
static constexpr float MIDDLE_Z_FAR = 20000.f;
|
||||
static constexpr float MIDDLE_Z_NEAR = 500.f;
|
||||
static constexpr float MIDDLE_Z_FAR = 50000.f;
|
||||
|
||||
// Дистанция, где ЗАВЕРШАЕТСЯ переход FAR -> MIDDLE и НАЧИНАЕТСЯ MIDDLE -> NEAR
|
||||
static constexpr float TRANSITION_MIDDLE_START = 500.f;
|
||||
static constexpr float TRANSITION_MIDDLE_START = 10000.f;
|
||||
|
||||
// --- 3. Ближний диапазон (NEAR) ---
|
||||
// Новые константы для максимальной точности
|
||||
static constexpr float NEAR_Z_NEAR = 5.0f;
|
||||
static constexpr float NEAR_Z_FAR = 5000.0f;
|
||||
static constexpr float NEAR_Z_NEAR = 50.0f;
|
||||
static constexpr float NEAR_Z_FAR = 50000.0f;
|
||||
|
||||
// Дистанция, где ЗАВЕРШАЕТСЯ переход MIDDLE -> NEAR
|
||||
static constexpr float TRANSITION_NEAR_END = 40.f;
|
||||
static constexpr float TRANSITION_NEAR_END = 10.f;
|
||||
|
||||
std::pair<float, float> calculateZRange(const Vector3f& shipPosition) {
|
||||
|
||||
@ -147,22 +147,13 @@ namespace ZL {
|
||||
|
||||
// Масштабируем: хотим отклонение от 1.0 до 1.1
|
||||
// Значит амплитуда = 0.1
|
||||
float height = 1.0f + (noiseValue * 0.01f); // * 0.2 даст вариацию высоты
|
||||
float height = 1.0f + (noiseValue * 0.002f); // * 0.2 даст вариацию высоты
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool PlanetObject::planetIsFar(const Vector3f& shipPosition)
|
||||
{
|
||||
const Vector3f planetWorldPosition = PLANET_CENTER_OFFSET;
|
||||
const float distanceToPlanetCenter = (planetWorldPosition - shipPosition).length();
|
||||
const float distanceToPlanetSurface = distanceToPlanetCenter - PLANET_RADIUS;
|
||||
|
||||
return distanceToPlanetSurface > 0.1*TRANSITION_MIDDLE_START;
|
||||
}
|
||||
|
||||
|
||||
PlanetObject::PlanetObject()
|
||||
: perlin(77777)
|
||||
@ -181,8 +172,8 @@ namespace ZL {
|
||||
planetRenderStruct.data = planetMesh;
|
||||
planetRenderStruct.RefreshVBO();
|
||||
|
||||
sandTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/sand.png", ""));
|
||||
//sandTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/rock.png", ""));
|
||||
//sandTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/sand.png", ""));
|
||||
sandTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/rock.png", ""));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -59,8 +59,6 @@ namespace ZL {
|
||||
|
||||
void draw(Renderer& renderer);
|
||||
|
||||
bool planetIsFar(const Vector3f& shipPosition);
|
||||
|
||||
|
||||
private:
|
||||
bool drawDataDirty = true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user