Gave the skydome it's own class which contains the nightTexture and changed the loader and the level XML.

This commit is contained in:
Faerbit 2015-03-04 21:28:46 +01:00
parent 2c333773b2
commit 3e86b70778
6 changed files with 42 additions and 10 deletions

View File

@ -12117,6 +12117,7 @@
<skydome>
<model>skydome.obj</model>
<texture>skydomeNew.png</texture>
<nightTexture>nightskydome.png</nightTexture>
</skydome>
<physics>

View File

@ -115,7 +115,7 @@ void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseD
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));
if (runTime > 2.0f) {
@ -205,7 +205,7 @@ void Level::setStrength(float strength) {
this->strength = strength;
}
void Level::setSkydomeObject(Object* object){
void Level::setSkydomeObject(Skydome object){
this->skydome = object;
}
@ -261,6 +261,6 @@ Terrain* Level::getTerrain() {
return &terrain;
}
Object* Level::getSkydome() {
return skydome;
Skydome* Level::getSkydome() {
return &skydome;
}

View File

@ -10,6 +10,7 @@
#include "camera.hh"
#include "physics.hh"
#include "trigger.hh"
#include "skydome.hh"
extern "C" {
#include "extern/lua/src/lua.h"
@ -36,13 +37,13 @@ class Level {
glm::vec4 getFogColour();
void setSkydomeSize(float size);
float getSkydomeSize();
Object* getSkydome();
Skydome* getSkydome();
std::vector<Object*>* getObjects();
std::vector<Object*>* getPhysicsObjects();
void deleteObject(int objectIndex);
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
void setStrength(float strength);
void setSkydomeObject(Object* object);
void setSkydomeObject(Skydome object);
void addObject(Object* object);
void addPhysicsObject(Object* object);
void setAmbientLight(glm::vec3 colour);
@ -70,7 +71,7 @@ class Level {
Light directionalLight;
Object* cameraCenter;
int playerIndex;
Object* skydome;
Skydome skydome;
Physics physics;
Camera camera;
Terrain terrain;

View File

@ -70,7 +70,6 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
//load the skydome
XMLElement* skydomeElement = doc->FirstChildElement("skydome");
std::string skydomeTexture = queryString(skydomeElement, "texture");
std::string skydomeModelFileName = queryString(skydomeElement, "model");
std::string skydomePath = "../" + globalGeometryPath + skydomeModelFileName;
if(stat(skydomePath.c_str(), &buf) != 0){
@ -78,14 +77,21 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
exit(-1);
}
Model skydomeModel = Model(skydomeModelFileName, level->getSkydomeSize());
std::string skydomeTexture = queryString(skydomeElement, "texture");
std::string skydomeTexturePath = "../" + globalTexturePath + skydomeTexture;
if(stat(skydomeTexturePath.c_str(), &buf) != 0){
std::cout << "The texture file " << skydomeTexturePath << " does not exist." << std::endl;
exit(-1);
}
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),
glm::vec3(0.0f, 0.0f, 0.0f), true);
std::string nightTexture = queryString(skydomeElement, "nightTexture");
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);
//load lighting parameters

13
skydome.cc Normal file
View 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
View 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;
};