is anyone here?

This commit is contained in:
Ben Kyd
2019-11-12 14:56:46 +00:00
parent 11445de644
commit 859aef604c
8 changed files with 61 additions and 23 deletions

View File

@@ -12,7 +12,7 @@ uniform sampler2DArray tex;
void main() {
outColour = texture(tex, TexCoord);
//outColour = vec4(.9, .9, .9, 1);
// outColour = vec4(.9, .9, .9, 1);
if (outColour.w == .0)
discard;

View File

@@ -9,6 +9,7 @@ public:
glm::vec3 Max;
};
// TODO: Trees
class EntityCollider {
public:
@@ -30,5 +31,4 @@ private:
};
#endif

View File

@@ -4,9 +4,9 @@ Camera::Camera() {
projMatrix = glm::perspective(glm::radians(45.0f), 1.0f, 0.1f, 1000.0f);
roll = 0.0f;
pitch = 0.0f;
yaw = 0.0f;
Roll = 0.0f;
Pitch = 0.0f;
Yaw = 0.0f;
Position = {};
LookDirection = {};
@@ -19,9 +19,9 @@ Camera::Camera(int w, int h) {
projMatrix = glm::perspective(glm::radians(45.0f), (float)w / float(h), 0.1f, 1000.0f);
roll = 0.0f;
pitch = 0.0f;
yaw = 0.0f;
Roll = 0.0f;
Pitch = 0.0f;
Yaw = 0.0f;
Position = {};
LookDirection = {};
@@ -38,9 +38,9 @@ void Camera::UpdateView() {
glm::mat4 matYaw = glm::mat4(1.0f); //identity matrix
// roll, pitch and yaw
matRoll = glm::rotate(matRoll, roll, glm::vec3(0.0f, 0.0f, 1.0f));
matPitch = glm::rotate(matPitch, pitch, glm::vec3(1.0f, 0.0f, 0.0f));
matYaw = glm::rotate(matYaw, yaw, glm::vec3(0.0f, 1.0f, 0.0f));
matRoll = glm::rotate(matRoll, Roll, glm::vec3(0.0f, 0.0f, 1.0f));
matPitch = glm::rotate(matPitch, Pitch, glm::vec3(1.0f, 0.0f, 0.0f));
matYaw = glm::rotate(matYaw, Yaw, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 rotate = matRoll * matPitch * matYaw;
@@ -99,8 +99,8 @@ void Camera::MoveCamera(Uint8* state) {
// Rotate by camera direction
glm::mat2 rotate {
cos(yaw), -sin(yaw),
sin(yaw), cos(yaw)
cos(Yaw), -sin(Yaw),
sin(Yaw), cos(Yaw)
};
glm::vec2 f(0.0, 1.0);
@@ -149,11 +149,33 @@ void Camera::MouseMoved(glm::vec2 mouseDelta) {
// note that yaw and pitch must be converted to radians.
// this is done in UpdateView() by glm::rotate
yaw += MouseSensitivity * (mouseDelta.x/100);
pitch += MouseSensitivity * (mouseDelta.y/100);
pitch = glm::clamp<float>(pitch, -M_PI/2, M_PI/2);
Yaw += MouseSensitivity * (mouseDelta.x/100);
Pitch += MouseSensitivity * (mouseDelta.y/100);
Pitch = glm::clamp<float>(Pitch, -M_PI/2, M_PI/2);
UpdateView();
}
void Camera::UpdatePosition(glm::vec3 position) {
Position = position;
}
void Camera::UpdateEulerLookDirection(float roll, float pitch, float yaw) {
Roll = roll; Pitch = pitch; Yaw = yaw;
LookDirection.x = cos(Yaw) * cos(Pitch);
LookDirection.y = sin(Yaw) * cos(Pitch);
LookDirection.z = sin(Pitch);
}
void Camera::UpdateLookDirection(glm::vec3 lookDirection) {
LookDirection = lookDirection;
// TODO: calculate euler values from
// look unit vector
}

View File

@@ -22,11 +22,15 @@ public:
float MouseSensitivity = 0.1f;
float CameraSpeed = 2.0f;
void UpdatePosition(glm::vec3 position);
void UpdateEulerLookDirection(float roll, float pitch, float yaw);
void UpdateLookDirection(glm::vec3 lookDirection);
glm::vec3 Position = {};
float Roll, Pitch, Yaw;
glm::vec3 LookDirection = {};
private:
float roll, pitch, yaw;
glm::mat4 viewMatrix = {};
glm::mat4 projMatrix = {};

View File

@@ -53,7 +53,7 @@ Chunk::Chunk(int x, int z, std::shared_ptr<FastNoise> terrainGenerator) {
continue;
}
if (pow(y / (float)CHUNK_HEIGHT, 1.1024f) + terrainGenerator->GetValueFractal(x + (Z * CHUNK_WIDTH), y, z + (X * CHUNK_DEPTH)) * 0.60f < 0.5f) {
if (pow(y / (float)CHUNK_HEIGHT, 1.1024f) + terrainGenerator->GetNoise(x + (Z * CHUNK_WIDTH), y, z + (X * CHUNK_DEPTH)) * 0.60f < 0.5f) {
Voxels.push_back((uint8_t)EBlockType::Grass);
continue;

View File

@@ -13,7 +13,19 @@ Entity::Entity(glm::vec3 postion, glm::vec3 direction, std::shared_ptr<Camera> c
}
}
Player::Player {
Player::Player(glm::vec3 position, glm::vec3 direction) {
}
void Player::Move(Uint8* state) {
}
void Player::HandleMouseSDL(SDL_Event e) {
}
void UpdatePosition(glm::vec3 position);
void UpdateDirection(glm::vec3 direction);
void CameaUpdateProjection(int xres, int yres);

View File

@@ -39,7 +39,7 @@ public:
Player(glm::vec3 position, glm::vec3 direction = {0.0f, 0.0f, 0.0f});
void Move(Uint8* state);
void HandleMouse(SDL_Event e);
void HandleMouseSDL(SDL_Event e);
void UpdatePosition(glm::vec3 position);
void UpdateDirection(glm::vec3 direction);

View File

@@ -24,9 +24,9 @@ void World::LoadWorld() {
m_noiseGenerator = std::make_shared<FastNoise>();
m_noiseGenerator->SetSeed(rand());
m_noiseGenerator->SetNoiseType(FastNoise::SimplexFractal);
m_noiseGenerator->SetNoiseType(FastNoise::Perlin);
m_noiseGenerator->SetFractalOctaves(5);
m_noiseGenerator->SetFractalOctaves(8);
for (int x = -4; x < 50; x++)
for (int y = -50; y < 4; y++) {