Commit e62037d2 authored by Håkon Berg Borhaug's avatar Håkon Berg Borhaug
Browse files

Diagonal movement of landscape

parent 2826b080
......@@ -35,6 +35,8 @@ class GameManager : public SceneObject
std::shared_ptr<Plane> ls2_;
std::shared_ptr<Plane> ls3_;
std::shared_ptr<Plane> ls4_;
std::shared_ptr<Plane> ls5_;
std::shared_ptr<Plane> sbw_;
std::shared_ptr<Plane> sbn_;
std::shared_ptr<Plane> sbe_;
......
......@@ -84,5 +84,6 @@ private:
Texture texture; // = Texture("C:/dev/uni/DTE-3609_VR_graphics_animation/start_code/resources/textures/road.jpg");
unsigned int textureSlot = 0;
bool fixed;
float scaling;
};
......@@ -11,6 +11,11 @@
Character::Character()
{
list_id_ = glGenLists(1);
auto translation = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 30.0f, 0.0f));
auto rotation = glm::rotate(glm::mat4(1.0f), glm::radians(30.0f), glm::vec3(0.0f, 0.0f, 1.0f));
matrix_ = translation * rotation;
}
Character::~Character()
......
#include "../include/GameManager.hpp"
#include <math.h>
GameManager::GameManager()
{
}
......@@ -23,17 +25,29 @@ void GameManager::privateInit()
// Adding the camera to the scene
cam_.reset(new Camera());
// Landscape
auto landscapeTexturePath = "C:/dev/uni/DTE-3609_VR_graphics_animation/start_code/resources/textures/road.jpg";
auto landscapeSize = 200.0f;
auto landscapeScaling = 3.0f;
auto landscapeRealSize = landscapeSize * landscapeScaling;
ls1_.reset(new Plane(glm::vec3(0.0f, -50.0f, 0.0f), landscapeTexturePath));
ls1_.reset(new Plane(glm::vec3(0.0f, -50.0f, 0.0f), landscapeTexturePath, glm::vec3(0.0f, 0.0f, 1.0f),
30.0f, glm::vec3(landscapeScaling, landscapeScaling, landscapeScaling)));
this->addSubObject(ls1_);
ls2_.reset(new Plane(glm::vec3(200.0f, -50.0f, 0.0f), landscapeTexturePath));
ls2_.reset(new Plane(glm::vec3(landscapeRealSize * cos(glm::radians(30.0f)), -50.0f + landscapeRealSize * sin(glm::radians(30.0f)), 0.0f), landscapeTexturePath, glm::vec3(0.0f, 0.0f, 1.0f),
30.0f, glm::vec3(landscapeScaling, landscapeScaling, landscapeScaling)));
this->addSubObject(ls2_);
ls3_.reset(new Plane(glm::vec3(400.0f, -50.0f, 0.0f), landscapeTexturePath));
ls3_.reset(new Plane(glm::vec3(2 * landscapeRealSize * cos(glm::radians(30.0f)), -50.0f + 2 * landscapeRealSize * sin(glm::radians(30.0f)), 0.0f), landscapeTexturePath, glm::vec3(0.0f, 0.0f, 1.0f),
30.0f,glm::vec3(landscapeScaling, landscapeScaling, landscapeScaling)));
this->addSubObject(ls3_);
ls4_.reset(new Plane(glm::vec3(600.0f, -50.0f, 0.0f),landscapeTexturePath));
ls4_.reset(new Plane(glm::vec3(3 * landscapeRealSize * cos(glm::radians(30.0f)), -50.0f + 3 * landscapeRealSize * sin(glm::radians(30.0f)), 0.0f),landscapeTexturePath, glm::vec3(0.0f, 0.0f, 1.0f),
30.0f, glm::vec3(landscapeScaling, landscapeScaling, landscapeScaling)));
this->addSubObject(ls4_);
ls5_.reset(new Plane(glm::vec3(4 * landscapeRealSize * cos(glm::radians(30.0f)), -50.0f + 4 * landscapeRealSize * sin(glm::radians(30.0f)), 0.0f),landscapeTexturePath, glm::vec3(0.0f, 0.0f, 1.0f),
30.0f, glm::vec3(landscapeScaling, landscapeScaling, landscapeScaling)));
this->addSubObject(ls5_);
// Skybox
float skyboxSize = 10000.0f;
std::string skyboxTexturePathPrefix = "C:/dev/uni/DTE-3609_VR_graphics_animation/start_code/resources/textures/skybox_";
......@@ -56,15 +70,19 @@ void GameManager::privateInit()
0.0f, glm::vec3(skyboxSize / 200, skyboxSize / 200, skyboxSize / 200), true, false));
this->addSubObject(sbd_);
// Character
character_.reset(new Character());
this->addSubObject(character_);
// Snow
snow_.reset(new Snow());
this->addSubObject(snow_);
// Text
text_.reset(new Text());
this->addSubObject(text_);
// Minimap
minimap_.reset(new Minimap());
this->addSubObject(minimap_);
......
......@@ -5,7 +5,7 @@
#include "../include/Projection.h"
Plane::Plane(glm::vec3 trans, std::string texturePath, glm::vec3 rotationAxis, float rotationAngle, glm::vec3 scale, bool isFixed, bool isTilted)
: texture(Texture(texturePath)), fixed(isFixed)
: texture(Texture(texturePath)), fixed(isFixed), scaling(scale[0])
{
auto translation = glm::translate(glm::mat4(1.0f), trans);
......@@ -144,11 +144,11 @@ void Plane::privateUpdate()
if (fixed)
return;
if (matrix_[3].x < -400) {
matrix_ = glm::translate(matrix_, glm::vec3(798.0f, 0.0f, 0.0f));
if (matrix_[3].x < - 1.5 * 200 * scaling) {
matrix_ = glm::translate(matrix_, glm::vec3(1.5 * 200 * scaling - 2, 0.0f, 0.0f));
}
else {
matrix_ = glm::translate(matrix_, glm::vec3(-2.0f, 0.0f, 0.0f));
matrix_ = glm::translate(matrix_, glm::vec3(-1.0f, 0.0f, 0.0f));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment