58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <raylib.h>
|
|
#include <raymath.h>
|
|
#include <vector>
|
|
|
|
class Sky {
|
|
private:
|
|
struct Sun {
|
|
Vector3 position;
|
|
Vector3 direction;
|
|
Color color;
|
|
float intensity;
|
|
float angle; // Sun angle for day/night cycle
|
|
|
|
void updatePosition(float timeOfDay);
|
|
Vector3 getLightDirection() const { return direction; }
|
|
};
|
|
|
|
Sun sun;
|
|
Color horizonColor;
|
|
Color zenithColor;
|
|
Color fogColor;
|
|
float fogDensity;
|
|
float timeOfDay; // 0.0 to 1.0 (0 = midnight, 0.5 = noon)
|
|
|
|
Shader skyShader;
|
|
Mesh skyDome;
|
|
Model skyModel;
|
|
bool shaderLoaded;
|
|
|
|
public:
|
|
Sky();
|
|
~Sky();
|
|
|
|
void update(float deltaTime);
|
|
void render(const Camera3D& camera);
|
|
void renderSkybox(const Camera3D& camera); // Render skybox that follows camera
|
|
|
|
void setTimeOfDay(float time);
|
|
float getTimeOfDay() const { return timeOfDay; }
|
|
|
|
Vector3 getSunDirection() const { return sun.direction; }
|
|
Color getSunColor() const { return sun.color; }
|
|
float getSunIntensity() const { return sun.intensity; }
|
|
|
|
Color getFogColor() const { return fogColor; }
|
|
float getFogDensity() const { return fogDensity; }
|
|
|
|
Color getAmbientLight() const;
|
|
|
|
private:
|
|
void updateColors();
|
|
void createSkyDome();
|
|
Color interpolateColor(const Color& a, const Color& b, float t) const;
|
|
void drawGradientSky() const;
|
|
void drawSun(const Camera3D& camera) const;
|
|
}; |