Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1.  
  2. //I Higmap render
  3. if (0 < camera.getCameraPosition().x && camera.getCameraPosition().x < heightmap._image->width
  4.                 && 0 < camera.getCameraPosition().z && camera.getCameraPosition().z < heightmap._image->height)
  5.             {
  6.                 if (camera.getCameraPosition().y - 1 < heightmap.getHeight((int)camera.getCameraPosition().x, (int)camera.getCameraPosition().z))
  7.                 {
  8.                     camera.newHeight(heightmap.getHeight((int)camera.getCameraPosition().x, (int)camera.getCameraPosition().z));
  9.                 }
  10.             }
  11.  
  12. //Imgu
  13. ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
  14.             ImGui::Text("Camera Height %.3f", camera.getCameraPosition().y);
  15.             if (0 < camera.getCameraPosition().x && camera.getCameraPosition().x < heightmap._image->width
  16.                 && 0 < camera.getCameraPosition().z && camera.getCameraPosition().z < heightmap._image->height)
  17.             {
  18.                 ImGui::Text("Map Height %.3f", heightmap.getHeight((int)camera.getCameraPosition().x, (int)camera.getCameraPosition().z));
  19.             }
  20.  
  21. //Camera.cpp
  22. void Camera::newHeight(float floor)
  23. {
  24.     this->position.y = floor + 1;
  25.     this->view = glm::lookAt(
  26.         this->position, //Camera location
  27.         this->position + this->direction,  //Camera looking towards origo
  28.         this->up   //y-axis is considered "up"
  29.     );
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement