Gave the skydome it's own class which contains the nightTexture and changed the loader and the level XML.
This commit is contained in:
parent
2c333773b2
commit
3e86b70778
@ -12117,6 +12117,7 @@
|
|||||||
<skydome>
|
<skydome>
|
||||||
<model>skydome.obj</model>
|
<model>skydome.obj</model>
|
||||||
<texture>skydomeNew.png</texture>
|
<texture>skydomeNew.png</texture>
|
||||||
|
<nightTexture>nightskydome.png</nightTexture>
|
||||||
</skydome>
|
</skydome>
|
||||||
|
|
||||||
<physics>
|
<physics>
|
||||||
|
8
level.cc
8
level.cc
@ -115,7 +115,7 @@ void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseD
|
|||||||
physicsObjects[i]->setRotation(physics.getRotation(i));
|
physicsObjects[i]->setRotation(physics.getRotation(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
skydome->setPosition(glm::vec3(cameraCenter->getPosition().x,
|
skydome.setPosition(glm::vec3(cameraCenter->getPosition().x,
|
||||||
0.0f, cameraCenter->getPosition().z));
|
0.0f, cameraCenter->getPosition().z));
|
||||||
|
|
||||||
if (runTime > 2.0f) {
|
if (runTime > 2.0f) {
|
||||||
@ -205,7 +205,7 @@ void Level::setStrength(float strength) {
|
|||||||
this->strength = strength;
|
this->strength = strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::setSkydomeObject(Object* object){
|
void Level::setSkydomeObject(Skydome object){
|
||||||
this->skydome = object;
|
this->skydome = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,6 +261,6 @@ Terrain* Level::getTerrain() {
|
|||||||
return &terrain;
|
return &terrain;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object* Level::getSkydome() {
|
Skydome* Level::getSkydome() {
|
||||||
return skydome;
|
return &skydome;
|
||||||
}
|
}
|
||||||
|
7
level.hh
7
level.hh
@ -10,6 +10,7 @@
|
|||||||
#include "camera.hh"
|
#include "camera.hh"
|
||||||
#include "physics.hh"
|
#include "physics.hh"
|
||||||
#include "trigger.hh"
|
#include "trigger.hh"
|
||||||
|
#include "skydome.hh"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "extern/lua/src/lua.h"
|
#include "extern/lua/src/lua.h"
|
||||||
@ -36,13 +37,13 @@ class Level {
|
|||||||
glm::vec4 getFogColour();
|
glm::vec4 getFogColour();
|
||||||
void setSkydomeSize(float size);
|
void setSkydomeSize(float size);
|
||||||
float getSkydomeSize();
|
float getSkydomeSize();
|
||||||
Object* getSkydome();
|
Skydome* getSkydome();
|
||||||
std::vector<Object*>* getObjects();
|
std::vector<Object*>* getObjects();
|
||||||
std::vector<Object*>* getPhysicsObjects();
|
std::vector<Object*>* getPhysicsObjects();
|
||||||
void deleteObject(int objectIndex);
|
void deleteObject(int objectIndex);
|
||||||
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
|
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
|
||||||
void setStrength(float strength);
|
void setStrength(float strength);
|
||||||
void setSkydomeObject(Object* object);
|
void setSkydomeObject(Skydome object);
|
||||||
void addObject(Object* object);
|
void addObject(Object* object);
|
||||||
void addPhysicsObject(Object* object);
|
void addPhysicsObject(Object* object);
|
||||||
void setAmbientLight(glm::vec3 colour);
|
void setAmbientLight(glm::vec3 colour);
|
||||||
@ -70,7 +71,7 @@ class Level {
|
|||||||
Light directionalLight;
|
Light directionalLight;
|
||||||
Object* cameraCenter;
|
Object* cameraCenter;
|
||||||
int playerIndex;
|
int playerIndex;
|
||||||
Object* skydome;
|
Skydome skydome;
|
||||||
Physics physics;
|
Physics physics;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
Terrain terrain;
|
Terrain terrain;
|
||||||
|
12
loader.cc
12
loader.cc
@ -70,7 +70,6 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
|
|
||||||
//load the skydome
|
//load the skydome
|
||||||
XMLElement* skydomeElement = doc->FirstChildElement("skydome");
|
XMLElement* skydomeElement = doc->FirstChildElement("skydome");
|
||||||
std::string skydomeTexture = queryString(skydomeElement, "texture");
|
|
||||||
std::string skydomeModelFileName = queryString(skydomeElement, "model");
|
std::string skydomeModelFileName = queryString(skydomeElement, "model");
|
||||||
std::string skydomePath = "../" + globalGeometryPath + skydomeModelFileName;
|
std::string skydomePath = "../" + globalGeometryPath + skydomeModelFileName;
|
||||||
if(stat(skydomePath.c_str(), &buf) != 0){
|
if(stat(skydomePath.c_str(), &buf) != 0){
|
||||||
@ -78,14 +77,21 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
Model skydomeModel = Model(skydomeModelFileName, level->getSkydomeSize());
|
Model skydomeModel = Model(skydomeModelFileName, level->getSkydomeSize());
|
||||||
|
std::string skydomeTexture = queryString(skydomeElement, "texture");
|
||||||
std::string skydomeTexturePath = "../" + globalTexturePath + skydomeTexture;
|
std::string skydomeTexturePath = "../" + globalTexturePath + skydomeTexture;
|
||||||
if(stat(skydomeTexturePath.c_str(), &buf) != 0){
|
if(stat(skydomeTexturePath.c_str(), &buf) != 0){
|
||||||
std::cout << "The texture file " << skydomeTexturePath << " does not exist." << std::endl;
|
std::cout << "The texture file " << skydomeTexturePath << " does not exist." << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
Material skydomeMaterial = Material(skydomeTexture, 1.0f, 0.0f, 0.0f, 0.0f);
|
Material skydomeMaterial = Material(skydomeTexture, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||||
Object* skydomeObject = new Object(skydomeModel, skydomeMaterial, glm::vec3(0.0f, 0.0f, 0.0f),
|
std::string nightTexture = queryString(skydomeElement, "nightTexture");
|
||||||
glm::vec3(0.0f, 0.0f, 0.0f), true);
|
std::string nightTexturePath = "../" + globalTexturePath + nightTexture;
|
||||||
|
if(stat(nightTexturePath.c_str(), &buf) != 0){
|
||||||
|
std::cout << "The texture file " << nightTexturePath << " does not exist." << std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
Material nightMaterial = Material(nightTexture, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
Skydome skydomeObject = Skydome(skydomeModel, skydomeMaterial, nightMaterial);
|
||||||
level->setSkydomeObject(skydomeObject);
|
level->setSkydomeObject(skydomeObject);
|
||||||
|
|
||||||
//load lighting parameters
|
//load lighting parameters
|
||||||
|
13
skydome.cc
Normal file
13
skydome.cc
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "skydome.hh"
|
||||||
|
|
||||||
|
Skydome::Skydome(Model model, Material material, Material nightTexture) :
|
||||||
|
Object(model, material, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), true){
|
||||||
|
this->nightTexture = nightTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
Skydome::Skydome() {
|
||||||
|
}
|
||||||
|
|
||||||
|
Material* Skydome::getNightTexture() {
|
||||||
|
return &nightTexture;
|
||||||
|
}
|
11
skydome.hh
Normal file
11
skydome.hh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "object.hh"
|
||||||
|
|
||||||
|
class Skydome : public Object {
|
||||||
|
public:
|
||||||
|
Skydome(Model model, Material material, Material nightTexture);
|
||||||
|
Skydome();
|
||||||
|
Material* getNightTexture();
|
||||||
|
private:
|
||||||
|
Material nightTexture;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user