Changed fogColor to fogColour. Moved some global Parameters to the xml.
This commit is contained in:
parent
8c7648a51e
commit
9764bc9d0b
@ -39,7 +39,61 @@ Converter::Converter(std::string level){
|
|||||||
doc->LoadFile(charXmlFile);
|
doc->LoadFile(charXmlFile);
|
||||||
if (doc->ErrorID()!=0){
|
if (doc->ErrorID()!=0){
|
||||||
printf("Could not open xml, creating new xml.\n");
|
printf("Could not open xml, creating new xml.\n");
|
||||||
|
std::vector<XMLElement*> lightAttributes;
|
||||||
|
lightAttributes.push_back(doc->NewElement("xOffset"));
|
||||||
|
lightAttributes.push_back(doc->NewElement("yOffset"));
|
||||||
|
lightAttributes.push_back(doc->NewElement("zOffset"));
|
||||||
|
lightAttributes.push_back(doc->NewElement("rColour"));
|
||||||
|
lightAttributes.push_back(doc->NewElement("gColour"));
|
||||||
|
lightAttributes.push_back(doc->NewElement("bColour"));
|
||||||
|
lightAttributes.push_back(doc->NewElement("intensity"));
|
||||||
|
XMLElement* rColourAmbient = doc->NewElement("rColour");
|
||||||
|
XMLElement* gColourAmbient = doc->NewElement("gColour");
|
||||||
|
XMLElement* bColourAmbient = doc->NewElement("bColour");
|
||||||
|
XMLElement* rColourFog = doc->NewElement("rColour");
|
||||||
|
XMLElement* gColourFog = doc->NewElement("gColour");
|
||||||
|
XMLElement* bColourFog = doc->NewElement("bColour");
|
||||||
|
XMLElement* alphaFog = doc->NewElement("alpha");
|
||||||
|
|
||||||
|
lightAttributes[0]->SetText("-1.0");
|
||||||
|
lightAttributes[1]->SetText("1.5");
|
||||||
|
lightAttributes[2]->SetText("1.0");
|
||||||
|
lightAttributes[3]->SetText("1.0");
|
||||||
|
lightAttributes[4]->SetText("1.0");
|
||||||
|
lightAttributes[5]->SetText("0.9");
|
||||||
|
lightAttributes[6]->SetText("0.2");
|
||||||
|
rColourAmbient->SetText("1.0");
|
||||||
|
gColourAmbient->SetText("1.0");
|
||||||
|
bColourAmbient->SetText("1.0");
|
||||||
|
rColourFog->SetText("0.10");
|
||||||
|
gColourFog->SetText("0.14");
|
||||||
|
bColourFog->SetText("0.14");
|
||||||
|
alphaFog->SetText("1.0");
|
||||||
|
|
||||||
|
XMLElement* ambientLight = doc->NewElement("ambientLight");
|
||||||
|
XMLElement* fogColour = doc->NewElement("fogColour");
|
||||||
|
XMLElement* directionalLight = doc->NewElement("directionalLight");
|
||||||
|
|
||||||
|
ambientLight->InsertEndChild(rColourAmbient);
|
||||||
|
ambientLight->InsertEndChild(gColourAmbient);
|
||||||
|
ambientLight->InsertEndChild(bColourAmbient);
|
||||||
|
fogColour->InsertEndChild(rColourFog);
|
||||||
|
fogColour->InsertEndChild(gColourFog);
|
||||||
|
fogColour->InsertEndChild(bColourFog);
|
||||||
|
fogColour->InsertEndChild(alphaFog);
|
||||||
|
for(int i=0;i<7;i++){
|
||||||
|
directionalLight->InsertEndChild(lightAttributes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLElement* skydome = doc->NewElement("skydome");
|
||||||
|
XMLElement* skydomeTexture = doc->NewElement("texture");
|
||||||
|
skydomeTexture->SetText("skydome.png");
|
||||||
|
skydome->InsertEndChild(skydomeTexture);
|
||||||
|
|
||||||
|
doc->InsertEndChild(ambientLight);
|
||||||
|
doc->InsertEndChild(fogColour);
|
||||||
|
doc->InsertEndChild(directionalLight);
|
||||||
|
doc->InsertEndChild(skydome);
|
||||||
}else{
|
}else{
|
||||||
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
||||||
int idGreen, idBlue;
|
int idGreen, idBlue;
|
||||||
|
@ -180,7 +180,7 @@ void Graphics::render(Level* level)
|
|||||||
|
|
||||||
// set fog Parameters
|
// set fog Parameters
|
||||||
lightingShader->setUniform("fogEnd", (farPlane)-35.0f);
|
lightingShader->setUniform("fogEnd", (farPlane)-35.0f);
|
||||||
lightingShader->setUniform("fogColor", level->getFogColor());
|
lightingShader->setUniform("fogColor", level->getFogColour());
|
||||||
lightingShader->setUniform("cameraCenter", level->getCameraCenter()->getPosition());
|
lightingShader->setUniform("cameraCenter", level->getCameraCenter()->getPosition());
|
||||||
|
|
||||||
// set Material Parameters
|
// set Material Parameters
|
||||||
|
54
level.cc
54
level.cc
@ -60,7 +60,7 @@ void Level::load() {
|
|||||||
//addTerrainPhysic
|
//addTerrainPhysic
|
||||||
physics.addTerrain(terrain.getHeightmapWidth(), terrain.getHeightmapHeight(), terrain.getHeightmap());
|
physics.addTerrain(terrain.getHeightmapWidth(), terrain.getHeightmapHeight(), terrain.getHeightmap());
|
||||||
|
|
||||||
//Loading Objects via xml
|
//Loading from xml:
|
||||||
XMLDocument* doc = new XMLDocument();
|
XMLDocument* doc = new XMLDocument();
|
||||||
const char* xmlFile = ("../Levels/ObjectSetups/Level" + levelNum + ".xml").c_str();
|
const char* xmlFile = ("../Levels/ObjectSetups/Level" + levelNum + ".xml").c_str();
|
||||||
doc->LoadFile(xmlFile);
|
doc->LoadFile(xmlFile);
|
||||||
@ -68,6 +68,36 @@ void Level::load() {
|
|||||||
printf("Could not open ObjectSetupXml!\n");
|
printf("Could not open ObjectSetupXml!\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
//load the skydome
|
||||||
|
XMLElement* skydomeElement = doc->FirstChildElement("skydome");
|
||||||
|
const char* charSkydomeTexture = skydomeElement->FirstChildElement("texture")->GetText();
|
||||||
|
if(charSkydomeTexture == NULL){
|
||||||
|
printf("XMLError: No skydomeTexture found.\n");
|
||||||
|
}
|
||||||
|
std::string skydomeTexture = charSkydomeTexture;
|
||||||
|
Model skydomeModel = Model("skydome.obj", skydomeSize);
|
||||||
|
Material skydomeMaterial = Material(skydomeTexture, 0.7f, 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));
|
||||||
|
objects.push_back(skydomeObject);
|
||||||
|
skydome = skydomeObject;
|
||||||
|
//load lighting parameters
|
||||||
|
float rColour, gColour, bColour, alpha, xOffset, yOffset, zOffset;
|
||||||
|
XMLElement* ambientElement = doc->FirstChildElement("ambientLight");
|
||||||
|
errorCheck(ambientElement->FirstChildElement("rColour")->QueryFloatText(&rColour));
|
||||||
|
errorCheck(ambientElement->FirstChildElement("gColour")->QueryFloatText(&gColour));
|
||||||
|
errorCheck(ambientElement->FirstChildElement("bColour")->QueryFloatText(&bColour));
|
||||||
|
ambientLight = glm::vec3(rColour,gColour,bColour);
|
||||||
|
XMLElement* fogElement = doc->FirstChildElement("ambientLight");
|
||||||
|
errorCheck(fogElement->FirstChildElement("rColour")->QueryFloatText(&rColour));
|
||||||
|
errorCheck(fogElement->FirstChildElement("gColour")->QueryFloatText(&gColour));
|
||||||
|
errorCheck(fogElement->FirstChildElement("bColour")->QueryFloatText(&bColour));
|
||||||
|
errorCheck(fogElement->FirstChildElement("alpha")->QueryFloatText(&alpha));
|
||||||
|
fogColour = glm::vec4(rColour,gColour,bColour, alpha);
|
||||||
|
directionalLight = Light(glm::vec3(-1.0f, 1.5f, 1.0f), glm::vec3(1.0f, 1.0f, 0.9f), 0.2f);
|
||||||
|
|
||||||
|
|
||||||
|
//load Objects
|
||||||
XMLDocument* compositions = new XMLDocument();
|
XMLDocument* compositions = new XMLDocument();
|
||||||
const char* compositionsFile = "../Levels/ObjectSetups/Compositions.xml";
|
const char* compositionsFile = "../Levels/ObjectSetups/Compositions.xml";
|
||||||
compositions->LoadFile(compositionsFile);
|
compositions->LoadFile(compositionsFile);
|
||||||
@ -193,13 +223,6 @@ void Level::load() {
|
|||||||
this->physics.addPlayer(1.25f,*object,8.0f,physicObjects.size());
|
this->physics.addPlayer(1.25f,*object,8.0f,physicObjects.size());
|
||||||
cameraCenter = object;
|
cameraCenter = object;
|
||||||
|
|
||||||
Model skydomeModel = Model("skydome.obj", skydomeSize);
|
|
||||||
Material skydomeMaterial = Material("skydome.png", 0.7f, 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));
|
|
||||||
objects.push_back(skydomeObject);
|
|
||||||
skydome = skydomeObject;
|
|
||||||
|
|
||||||
Model torchModel = Model("torch.obj", 0.75f);
|
Model torchModel = Model("torch.obj", 0.75f);
|
||||||
Material torchMaterial = Material("torchTexture.png", 0.1f, 0.3f, 0.7f, 10.0f);
|
Material torchMaterial = Material("torchTexture.png", 0.1f, 0.3f, 0.7f, 10.0f);
|
||||||
//Create object
|
//Create object
|
||||||
@ -227,17 +250,6 @@ void Level::load() {
|
|||||||
glm::vec3(0.0f, 0.0f, 0.0f));
|
glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
objects.push_back(columnObject);
|
objects.push_back(columnObject);
|
||||||
|
|
||||||
//make non physics objects
|
|
||||||
|
|
||||||
|
|
||||||
//set lighting parameters
|
|
||||||
ambientLight = glm::vec3(1.0f, 1.0f, 1.0f);
|
|
||||||
fogColor = glm::vec4(0.10f, 0.14f, 0.14f, 1.0f);
|
|
||||||
directionalLight = Light(glm::vec3(-1.0f, 1.5f, 1.0f), glm::vec3(1.0f, 1.0f, 0.9f), 0.2f);
|
|
||||||
Light light = Light(glm::vec3(-3.0f, 7.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f), 5.0f);
|
|
||||||
//lights.push_back(light);
|
|
||||||
Light light2 = Light(glm::vec3(3.0f, 7.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f), 10.0f);
|
|
||||||
//lights.push_back(light2);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -313,8 +325,8 @@ Light* Level::getDirectionalLight() {
|
|||||||
return &directionalLight;
|
return &directionalLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec4 Level::getFogColor() {
|
glm::vec4 Level::getFogColour() {
|
||||||
return fogColor;
|
return fogColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Level::getCameraPosition() {
|
glm::vec3 Level::getCameraPosition() {
|
||||||
|
4
level.hh
4
level.hh
@ -25,7 +25,7 @@ class Level {
|
|||||||
Object* getCameraCenter();
|
Object* getCameraCenter();
|
||||||
Camera* getCamera();
|
Camera* getCamera();
|
||||||
glm::vec3 getCameraPosition();
|
glm::vec3 getCameraPosition();
|
||||||
glm::vec4 getFogColor();
|
glm::vec4 getFogColour();
|
||||||
void setSkydomeSize(float size);
|
void setSkydomeSize(float size);
|
||||||
private:
|
private:
|
||||||
void errorCheck(tinyxml2::XMLError error);
|
void errorCheck(tinyxml2::XMLError error);
|
||||||
@ -34,7 +34,7 @@ class Level {
|
|||||||
std::vector<Object*> physicObjects;
|
std::vector<Object*> physicObjects;
|
||||||
std::vector<Light> lights;
|
std::vector<Light> lights;
|
||||||
glm::vec3 ambientLight;
|
glm::vec3 ambientLight;
|
||||||
glm::vec4 fogColor;
|
glm::vec4 fogColour;
|
||||||
Light directionalLight;
|
Light directionalLight;
|
||||||
Object* cameraCenter;
|
Object* cameraCenter;
|
||||||
Object* skydome;
|
Object* skydome;
|
||||||
|
Loading…
Reference in New Issue
Block a user