Added error checking for all XML Queries, fixed bugs and continued to implement loading from xml.
This commit is contained in:
parent
dbaa4f639f
commit
db1092be44
@ -3,6 +3,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>3.500000</xPos>
|
<xPos>3.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>3.500000</zPos>
|
<zPos>3.500000</zPos>
|
||||||
@ -16,6 +17,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>3.500000</xPos>
|
<xPos>3.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-0.500000</zPos>
|
<zPos>-0.500000</zPos>
|
||||||
@ -29,6 +31,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>2.500000</xPos>
|
<xPos>2.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-2.500000</zPos>
|
<zPos>-2.500000</zPos>
|
||||||
@ -42,6 +45,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>1.500000</xPos>
|
<xPos>1.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>0.500000</zPos>
|
<zPos>0.500000</zPos>
|
||||||
@ -55,6 +59,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>-0.500000</xPos>
|
<xPos>-0.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>1.500000</zPos>
|
<zPos>1.500000</zPos>
|
||||||
@ -68,6 +73,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>-0.500000</xPos>
|
<xPos>-0.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-1.500000</zPos>
|
<zPos>-1.500000</zPos>
|
||||||
@ -81,6 +87,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>-2.500000</xPos>
|
<xPos>-2.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-1.500000</zPos>
|
<zPos>-1.500000</zPos>
|
||||||
@ -94,6 +101,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>-3.500000</xPos>
|
<xPos>-3.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-3.500000</zPos>
|
<zPos>-3.500000</zPos>
|
||||||
@ -107,6 +115,7 @@
|
|||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
<yRot>0.0</yRot>
|
<yRot>0.0</yRot>
|
||||||
<zRot>0.0</zRot>
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
<xPos>-4.500000</xPos>
|
<xPos>-4.500000</xPos>
|
||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-4.500000</zPos>
|
<zPos>-4.500000</zPos>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
|
|
||||||
@ -41,9 +42,12 @@ Converter::Converter(std::string level){
|
|||||||
}else{
|
}else{
|
||||||
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
||||||
int idGreen, idBlue;
|
int idGreen, idBlue;
|
||||||
|
XMLError error=XML_NO_ERROR;
|
||||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
||||||
thisComposition->QueryIntAttribute("idGreen", &idGreen);
|
error = thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen);
|
||||||
thisComposition->QueryIntAttribute("idBlue", &idBlue);
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue);
|
||||||
|
errorCheck(error);
|
||||||
if(idGreen > nextID[0] || (idGreen == nextID[0] && idBlue > nextID[1])){
|
if(idGreen > nextID[0] || (idGreen == nextID[0] && idBlue > nextID[1])){
|
||||||
nextID[0] = idGreen;
|
nextID[0] = idGreen;
|
||||||
nextID[1] = idBlue;
|
nextID[1] = idBlue;
|
||||||
@ -68,6 +72,7 @@ std::vector<unsigned int> Converter::newComposition(unsigned int type, float pos
|
|||||||
XMLElement* zPos = doc->NewElement("zPos");
|
XMLElement* zPos = doc->NewElement("zPos");
|
||||||
XMLElement* yOffset = doc->NewElement("yOffset");
|
XMLElement* yOffset = doc->NewElement("yOffset");
|
||||||
XMLElement* xPos = doc->NewElement("xPos");
|
XMLElement* xPos = doc->NewElement("xPos");
|
||||||
|
XMLElement* manualPos = doc->NewElement("manualPos");
|
||||||
XMLElement* zRot = doc->NewElement("zRot");
|
XMLElement* zRot = doc->NewElement("zRot");
|
||||||
XMLElement* yRot = doc->NewElement("yRot");
|
XMLElement* yRot = doc->NewElement("yRot");
|
||||||
XMLElement* xRot = doc->NewElement("xRot");
|
XMLElement* xRot = doc->NewElement("xRot");
|
||||||
@ -79,6 +84,7 @@ std::vector<unsigned int> Converter::newComposition(unsigned int type, float pos
|
|||||||
zPos->SetText(std::to_string(posZ).c_str());
|
zPos->SetText(std::to_string(posZ).c_str());
|
||||||
yOffset->SetText("0.0");
|
yOffset->SetText("0.0");
|
||||||
xPos->SetText(std::to_string(posX).c_str());
|
xPos->SetText(std::to_string(posX).c_str());
|
||||||
|
manualPos->SetText("false");
|
||||||
zRot->SetText("0.0");
|
zRot->SetText("0.0");
|
||||||
yRot->SetText("0.0");
|
yRot->SetText("0.0");
|
||||||
xRot->SetText("0.0");
|
xRot->SetText("0.0");
|
||||||
@ -90,6 +96,7 @@ std::vector<unsigned int> Converter::newComposition(unsigned int type, float pos
|
|||||||
newComposition->InsertFirstChild(zPos);
|
newComposition->InsertFirstChild(zPos);
|
||||||
newComposition->InsertFirstChild(yOffset);
|
newComposition->InsertFirstChild(yOffset);
|
||||||
newComposition->InsertFirstChild(xPos);
|
newComposition->InsertFirstChild(xPos);
|
||||||
|
newComposition->InsertFirstChild(manualPos);
|
||||||
newComposition->InsertFirstChild(zRot);
|
newComposition->InsertFirstChild(zRot);
|
||||||
newComposition->InsertFirstChild(yRot);
|
newComposition->InsertFirstChild(yRot);
|
||||||
newComposition->InsertFirstChild(xRot);
|
newComposition->InsertFirstChild(xRot);
|
||||||
@ -106,23 +113,40 @@ std::vector<unsigned int> Converter::newComposition(unsigned int type, float pos
|
|||||||
|
|
||||||
void Converter::updateComposition(unsigned int idG, unsigned int idB, float posX, float posZ){
|
void Converter::updateComposition(unsigned int idG, unsigned int idB, float posX, float posZ){
|
||||||
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
||||||
int idGreen, idBlue;
|
int idGreen = 0, idBlue = 0;
|
||||||
|
bool compositionExists = false;
|
||||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
||||||
thisComposition->QueryIntAttribute("idGreen", &idGreen);
|
XMLError error=XML_NO_ERROR;
|
||||||
thisComposition->QueryIntAttribute("idBlue", &idBlue);
|
error = thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen);
|
||||||
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue);
|
||||||
|
errorCheck(error);
|
||||||
if(idGreen == idG && idBlue == idB){
|
if(idGreen == idG && idBlue == idB){
|
||||||
|
bool manualPos;
|
||||||
|
error=thisComposition->FirstChildElement("manualPos")->QueryBoolText(&manualPos);
|
||||||
|
errorCheck(error);
|
||||||
|
if(!manualPos){
|
||||||
thisComposition->FirstChildElement("xPos")->SetText(std::to_string(posX).c_str());
|
thisComposition->FirstChildElement("xPos")->SetText(std::to_string(posX).c_str());
|
||||||
thisComposition->FirstChildElement("zPos")->SetText(std::to_string(posZ).c_str());
|
thisComposition->FirstChildElement("zPos")->SetText(std::to_string(posZ).c_str());
|
||||||
}
|
}
|
||||||
|
compositionExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!compositionExists){
|
||||||
|
std::cout << "A composition has an ID in the png, but does'nt exist in the xml." << std::endl;
|
||||||
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Converter::deleteComposition(unsigned int idG, unsigned int idB){
|
void Converter::deleteComposition(unsigned int idG, unsigned int idB){
|
||||||
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
XMLElement* thisComposition = doc->FirstChildElement("composition");
|
||||||
int idGreen, idBlue;
|
int idGreen, idBlue;
|
||||||
|
XMLError error=XML_NO_ERROR;
|
||||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
||||||
thisComposition->QueryIntAttribute("idGreen", &idGreen);
|
error = thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen);
|
||||||
thisComposition->QueryIntAttribute("idBlue", &idBlue);
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue);
|
||||||
|
errorCheck(error);
|
||||||
if(idGreen == idG && idBlue == idB){
|
if(idGreen == idG && idBlue == idB){
|
||||||
doc->DeleteChild(thisComposition);
|
doc->DeleteChild(thisComposition);
|
||||||
}
|
}
|
||||||
@ -138,13 +162,23 @@ std::vector<unsigned int> Converter::getNextID(){
|
|||||||
return nextID;
|
return nextID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finding a typeID in compositions:
|
void Converter::errorCheck(XMLError error){
|
||||||
XMLElement* thisComposition = compositions->FirstChildElement("composition");
|
if (error) {
|
||||||
for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){
|
printf("XMLError: ");
|
||||||
int thisType;
|
if (error == XML_WRONG_ATTRIBUTE_TYPE) {
|
||||||
thisComposition->QueryIntAttribute("typeID", &thisType);
|
printf("Wrong attribute type.\n");
|
||||||
if(thisType == type){
|
}
|
||||||
...
|
else if (error == XML_NO_ATTRIBUTE) {
|
||||||
|
printf("No attribute.\n");
|
||||||
|
}
|
||||||
|
else if (error == XML_CAN_NOT_CONVERT_TEXT) {
|
||||||
|
printf("Can not convert text.\n");
|
||||||
|
}
|
||||||
|
else if (error == XML_NO_TEXT_NODE) {
|
||||||
|
printf("No text.\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Unknown error.\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -19,6 +19,7 @@ class Converter {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<unsigned int> nextID;
|
std::vector<unsigned int> nextID;
|
||||||
|
void errorCheck(XMLError error);
|
||||||
std::string xmlFile;
|
std::string xmlFile;
|
||||||
XMLDocument* doc = new XMLDocument();
|
XMLDocument* doc = new XMLDocument();
|
||||||
XMLDocument* compositions = new XMLDocument();
|
XMLDocument* compositions = new XMLDocument();
|
||||||
|
83
level.cc
83
level.cc
@ -47,7 +47,22 @@ void Level::load() {
|
|||||||
// currently hard coded should later read this stuff out of a file
|
// currently hard coded should later read this stuff out of a file
|
||||||
this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f);
|
this->camera = Camera(glm::vec2(-0.8f, 0.0f), 3.0f);
|
||||||
|
|
||||||
//Loading Objects via xml:
|
// load terrain
|
||||||
|
this->terrain.load();
|
||||||
|
Model terrainModel = Model(this->terrain.getModel());
|
||||||
|
// load a texture:
|
||||||
|
Material terrainMaterial = Material("seamlessTerrain.png", 0.1f, 0.8f, 0.2f, 3.0f);
|
||||||
|
//Create object
|
||||||
|
Object* terrainObject = new Object(terrainModel, terrainMaterial,
|
||||||
|
glm::vec3(-0.5f*(float)this->terrain.getHeightmapHeight(), 0.0f, -0.5f*(float)this->terrain.getHeightmapWidth()),
|
||||||
|
glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
|
objects.push_back(terrainObject);
|
||||||
|
|
||||||
|
//addTerrainPhysic
|
||||||
|
physics.addTerrain(terrain.getHeightmapWidth(), terrain.getHeightmapHeight(), terrain.getHeightmap());
|
||||||
|
|
||||||
|
|
||||||
|
//Loading Objects via 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);
|
||||||
@ -80,10 +95,13 @@ void Level::load() {
|
|||||||
printf("XMLError: No modelPath found in object.\n");
|
printf("XMLError: No modelPath found in object.\n");
|
||||||
}
|
}
|
||||||
std::string modelPath = charModelPath;
|
std::string modelPath = charModelPath;
|
||||||
float scaleObj, scaleComp;
|
float objectScale, compScale;
|
||||||
object->FirstChildElement("scale")->QueryFloatText(&scaleObj);
|
error = object->FirstChildElement("scale")->QueryFloatText(&objectScale);
|
||||||
thisComposition->FirstChildElement("scale")->QueryFloatText(&scaleComp);
|
errorCheck(error);
|
||||||
//Model model = Model(modelPath, scaleObj * scaleComp);
|
error = thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale);
|
||||||
|
errorCheck(error);
|
||||||
|
//Model model = Model(modelPath, objectScale * compScale);
|
||||||
|
//Material material;
|
||||||
XMLElement* objectData = compositions->FirstChildElement("objectData");
|
XMLElement* objectData = compositions->FirstChildElement("objectData");
|
||||||
for(; objectData; objectData=objectData->NextSiblingElement("objectData")){
|
for(; objectData; objectData=objectData->NextSiblingElement("objectData")){
|
||||||
const char* charDataModelPath = objectData->FirstChildElement("modelPath")->GetText();
|
const char* charDataModelPath = objectData->FirstChildElement("modelPath")->GetText();
|
||||||
@ -93,20 +111,49 @@ void Level::load() {
|
|||||||
std::string dataModelPath = charDataModelPath;
|
std::string dataModelPath = charDataModelPath;
|
||||||
if(dataModelPath == modelPath){
|
if(dataModelPath == modelPath){
|
||||||
float ambientFactor, diffuseFactor, specularFactor, shininess;
|
float ambientFactor, diffuseFactor, specularFactor, shininess;
|
||||||
objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor);
|
error = objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor);
|
||||||
objectData->FirstChildElement("diffuseFactor")->QueryFloatText(&diffuseFactor);
|
errorCheck(error);
|
||||||
objectData->FirstChildElement("specularFactor")->QueryFloatText(&specularFactor);
|
error = objectData->FirstChildElement("diffuseFactor")->QueryFloatText(&diffuseFactor);
|
||||||
objectData->FirstChildElement("shininess")->QueryFloatText(&shininess);
|
errorCheck(error);
|
||||||
|
error = objectData->FirstChildElement("specularFactor")->QueryFloatText(&specularFactor);
|
||||||
|
errorCheck(error);
|
||||||
|
error = objectData->FirstChildElement("shininess")->QueryFloatText(&shininess);
|
||||||
|
errorCheck(error);
|
||||||
const char* charTexturePath = objectData->FirstChildElement("texturePath")->GetText();
|
const char* charTexturePath = objectData->FirstChildElement("texturePath")->GetText();
|
||||||
if(charTexturePath == NULL){
|
if(charTexturePath == NULL){
|
||||||
printf("XMLError: No texturePath found in objectData.\n");
|
printf("XMLError: No texturePath found in objectData.\n");
|
||||||
}
|
}
|
||||||
std::string texturePath = charTexturePath;
|
std::string texturePath = charTexturePath;
|
||||||
//Material material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
|
//material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO calculate position and rotation
|
float compXPos, compYOffset, compZPos;
|
||||||
//Object* object = new Object(model, material, position, rotation);
|
glm::vec3 objectOffset, compRot, compPos;
|
||||||
|
error = object->FirstChildElement("xOffset")->QueryFloatText(&objectOffset[0]);
|
||||||
|
errorCheck(error);
|
||||||
|
error = object->FirstChildElement("yOffset")->QueryFloatText(&objectOffset[1]);
|
||||||
|
errorCheck(error);
|
||||||
|
error = object->FirstChildElement("zOffset")->QueryFloatText(&objectOffset[2]);
|
||||||
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("xPos")->QueryFloatText(&compXPos);
|
||||||
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("yOffset")->QueryFloatText(&compYOffset);
|
||||||
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("zPos")->QueryFloatText(&compZPos);
|
||||||
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("xRot")->QueryFloatText(&compRot[0]);
|
||||||
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("yRot")->QueryFloatText(&compRot[1]);
|
||||||
|
errorCheck(error);
|
||||||
|
error = thisComposition->FirstChildElement("zRot")->QueryFloatText(&compRot[2]);
|
||||||
|
errorCheck(error);
|
||||||
|
compPos = glm::vec3(compXPos,
|
||||||
|
compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())]
|
||||||
|
[int(compZPos-0.5+0.5*terrain.getHeightmapWidth())],
|
||||||
|
compZPos);
|
||||||
|
objectOffset = objectOffset * compScale;
|
||||||
|
//TODO calculate position from objectOffset, compRot and compPos
|
||||||
|
//Object* object = new Object(model, material, position, compRot);
|
||||||
//objects.push_back(object);
|
//objects.push_back(object);
|
||||||
//TODO if object has physics: physicObjects.push_back(object);
|
//TODO if object has physics: physicObjects.push_back(object);
|
||||||
//TODO add object to physics
|
//TODO add object to physics
|
||||||
@ -179,19 +226,7 @@ void Level::load() {
|
|||||||
Light light2 = Light(glm::vec3(3.0f, 7.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f), 10.0f);
|
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);
|
lights.push_back(light2);
|
||||||
|
|
||||||
// load terrain
|
|
||||||
this->terrain.load();
|
|
||||||
Model terrainModel = Model(this->terrain.getModel());
|
|
||||||
// load a texture:
|
|
||||||
Material terrainMaterial = Material("seamlessTerrain.png", 0.1f, 0.8f, 0.2f, 3.0f);
|
|
||||||
//Create object
|
|
||||||
Object* terrainObject = new Object(terrainModel, terrainMaterial,
|
|
||||||
glm::vec3(-0.5f*(float)this->terrain.getHeightmapHeight(), 0.0f, -0.5f*(float)this->terrain.getHeightmapWidth()),
|
|
||||||
glm::vec3(0.0f, 0.0f, 0.0f));
|
|
||||||
objects.push_back(terrainObject);
|
|
||||||
|
|
||||||
//addTerrainPhysic
|
|
||||||
physics.addTerrain(terrain.getHeightmapWidth(), terrain.getHeightmapHeight(), terrain.getHeightmap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass) {
|
void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass) {
|
||||||
|
Loading…
Reference in New Issue
Block a user