Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Submission copy
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPri committed Nov 28, 2017
1 parent 88d766a commit 37d574d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NeverGreenGrove/NeverGreenGrove/shaders/fragment.shader
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void main()
float startFog = 0.0f;
float endFog = 100.0f;

float fogIntensity = 0.0;//1.0 - clamp((endFog - fogCoordinate) / (endFog - startFog), 0.0, 1.0);
float fogIntensity = 1.0 - clamp((endFog - fogCoordinate) / (endFog - startFog), 0.0, 1.0);

//folllowing from ta
//ambient lighting
Expand Down
4 changes: 4 additions & 0 deletions NeverGreenGrove/NeverGreenGrove/src/Chunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class Chunk
void Translate(const glm::vec3& vec) { m_Terrain.Translate(vec); m_Forest.Translate((1.0f/ OBJECTSPACE_TO_REALWORLD)*vec); }
float MinDistanceToAnyTree(float from_x, float from_y);

float GetHeight(float x, float y) {
return m_Terrain.Get2DGrid().at(x).at(y).y;
}

private:
TerrainBlock m_Terrain;
Forest m_Forest;
Expand Down
2 changes: 2 additions & 0 deletions NeverGreenGrove/NeverGreenGrove/src/Forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ void Forest::TreeA::Draw() const
shaderProgram->SetUniformInt("object_type", 0);

glBindVertexArray(TreeObj::GetInstance()->GetVAO());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TreeObj::GetInstance()->GetTexture());
glDrawArrays(GL_TRIANGLES, 0, TreeObj::GetInstance()->GetNumberOfVertices());
glBindTexture(GL_TEXTURE_2D, 0);
Expand All @@ -286,6 +287,7 @@ void Forest::TreeB::Draw() const
shaderProgram->SetUniformInt("object_type", 0);

glBindVertexArray(TreeObj::GetInstance()->GetVAO());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TreeObj::GetInstance()->GetTexture());
glDrawArrays(GL_TRIANGLES, 0, TreeObj::GetInstance()->GetNumberOfVertices());
glBindTexture(GL_TEXTURE_2D, 0);
Expand Down
2 changes: 1 addition & 1 deletion NeverGreenGrove/NeverGreenGrove/src/NeverGreenGrove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void PerFrameCalc()
g_deltaTime = currentFrame - g_lastFrame;
g_lastFrame = currentFrame;

g_camera.moveCamera(g_deltaTime, 3.0f);
g_camera.moveCamera(g_deltaTime, /*g_World->GetHeight(g_camera.GetPos()) +*/ 3.0f);
}

// Callback declarations for camera ---------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions NeverGreenGrove/NeverGreenGrove/src/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ class World
void Update(glm::vec3 cam_pos);
bool TreeToClose(glm::vec3 cam_pos);

float GetHeight(glm::vec3 cam_pos) {
try
{
Point my_chunk{ cam_pos.x / 128, cam_pos.z / 128 };

return m_Map.at(my_chunk)->GetHeight((int)cam_pos.x % 128, (int)cam_pos.z % 128);
}
catch (const std::exception&)
{
return 0.0f;
}
}

private:

struct Point {long long x, y; };
Expand Down

0 comments on commit 37d574d

Please sign in to comment.