diff --git a/Levels/ObjectSetups/Compositions.xml b/Levels/ObjectSetups/Compositions.xml
index 767f1aa..cbba8a3 100644
--- a/Levels/ObjectSetups/Compositions.xml
+++ b/Levels/ObjectSetups/Compositions.xml
@@ -460,6 +460,7 @@
1.0
0.15
0.7
+ true
@@ -476,7 +477,7 @@
1.99
0.8
0.9
-
+ true
@@ -489,6 +490,7 @@
TriangleMesh
0.8
0.9
+ true
@@ -501,6 +503,7 @@
TriangleMesh
0.8
0.9
+ true
@@ -517,6 +520,7 @@
1.8
0.5
1.0
+ true
@@ -533,6 +537,7 @@
0.33
0.555
0.5
+ true
@@ -549,6 +554,7 @@
6
0.555
0.5
+ true
@@ -564,6 +570,7 @@
6
0.555
0.5
+ true
@@ -579,4 +586,5 @@
1.99
0.555
0.5
+ true
diff --git a/loader.cc b/loader.cc
index 0f3b144..1f8b15a 100644
--- a/loader.cc
+++ b/loader.cc
@@ -38,7 +38,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
Material terrainMaterial = Material(terrainTexture, terrainAmbientFactor, terrainDiffuseFactor, terrainSpecularFactor, terrainShininess);
Object* terrainObject = new Object(terrainModel, terrainMaterial,
glm::vec3(-0.5*(float)level->getTerrain()->getHeightmapHeight(), 0.0f, -0.5f*(float)level->getTerrain()->getHeightmapWidth()),
- glm::vec3(0.0f, 0.0f, 0.0f));
+ glm::vec3(0.0f, 0.0f, 0.0f), true);
level->addObject(terrainObject);
level->getPhysics()->addTerrain(level->getTerrain()->getHeightmapWidth(), level->getTerrain()->getHeightmapHeight(), level->getTerrain()->getHeightmap());
@@ -53,7 +53,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
Model skydomeModel = Model("skydome.obj", level->getSkydomeSize());
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));
+ glm::vec3(0.0f, 0.0f, 0.0f), true);
level->addObject(skydomeObject);
level->setSkydomeObject(skydomeObject);
@@ -117,7 +117,6 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
float objectScale, compScale;
errorCheck(xmlObject->FirstChildElement("scale")->QueryFloatText(&objectScale));
errorCheck(thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale));
- Model model = Model(modelPath, objectScale * compScale);
//find the objectData for the current object
XMLElement* objectData = compositions->FirstChildElement("objectData");
for(; objectData; objectData=objectData->NextSiblingElement("objectData")){
@@ -129,19 +128,26 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
std::string dataModelPath = charDataModelPath;
//objectData found
if(dataModelPath.compare(modelPath) == 0){
+ bool renderable;
+ errorCheck(objectData->FirstChildElement("renderable")->QueryBoolText(&renderable));
//create the object
- float ambientFactor, diffuseFactor, specularFactor, shininess;
- errorCheck(objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor));
- errorCheck(objectData->FirstChildElement("diffuseFactor")->QueryFloatText(&diffuseFactor));
- errorCheck(objectData->FirstChildElement("specularFactor")->QueryFloatText(&specularFactor));
- errorCheck(objectData->FirstChildElement("shininess")->QueryFloatText(&shininess));
- const char* charTexturePath = objectData->FirstChildElement("texturePath")->GetText();
- if(charTexturePath == NULL){
- printf("XMLError: No texturePath found in objectData.\n");
- exit(-1);
+ Material material;
+ Model model;
+ if (renderable) {
+ float ambientFactor, diffuseFactor, specularFactor, shininess;
+ errorCheck(objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor));
+ errorCheck(objectData->FirstChildElement("diffuseFactor")->QueryFloatText(&diffuseFactor));
+ errorCheck(objectData->FirstChildElement("specularFactor")->QueryFloatText(&specularFactor));
+ errorCheck(objectData->FirstChildElement("shininess")->QueryFloatText(&shininess));
+ const char* charTexturePath = objectData->FirstChildElement("texturePath")->GetText();
+ if(charTexturePath == NULL){
+ printf("XMLError: No texturePath found in objectData.\n");
+ exit(-1);
+ }
+ std::string texturePath = charTexturePath;
+ material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
+ model = Model(modelPath, objectScale * compScale);
}
- std::string texturePath = charTexturePath;
- Material material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
float compXPos, compYOffset, compZPos;
glm::vec3 objectOffset, compRot;
errorCheck(xmlObject->FirstChildElement("xOffset")->QueryFloatText(&objectOffset[0]));
@@ -172,7 +178,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
errorCheck(xmlObject->FirstChildElement("yRot")->QueryFloatText(&objectRot[1]));
errorCheck(xmlObject->FirstChildElement("zRot")->QueryFloatText(&objectRot[2]));
objectRot *= 0.0174532925; //transform degrees to radians
- Object* object = new Object(model, material, objectPosition, compRot+objectRot);
+ Object* object = new Object(model, material, objectPosition, compRot+objectRot, renderable);
level->addObject(object);
level->addPhysicsObject(object);
@@ -197,9 +203,9 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
std::string physicType = charPhysicType;
float mass;
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
- float dampningL, dampningA;
XMLElement* constraint = thisComposition->FirstChildElement("positionConstraint");
bool rotate = (constraint == NULL);
+ float dampningL, dampningA;
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
if (physicType.compare("Player") == 0){
diff --git a/object.cc b/object.cc
index 9d1f339..70acd47 100644
--- a/object.cc
+++ b/object.cc
@@ -1,9 +1,10 @@
#include "object.hh"
-Object::Object(Model model, Material material, glm::vec3 position, glm::vec3 rotation) :
+Object::Object(Model model, Material material, glm::vec3 position, glm::vec3 rotation, bool renderable) :
Entity(position, rotation) {
this->model = model;
this->material = material;
+ this->renderable = renderable;
}
Object::Object() {
@@ -14,6 +15,9 @@ Object::~Object() {
void Object::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::mat4* viewProjectionMatrix, std::vector* shadowVPs) {
+ if (!renderable) {
+ return;
+ }
glm::mat4 modelMatrix = glm::translate(getPosition()) * getRotation() * glm::scale(glm::vec3(model.getScale()));
if (lightingPass) {
// set lightning parameters for this object
diff --git a/object.hh b/object.hh
index 321e9a0..7d21956 100644
--- a/object.hh
+++ b/object.hh
@@ -12,7 +12,7 @@
class Object : public Entity {
public:
Object(Model model, Material material,
- glm::vec3 position, glm::vec3 rotation);
+ glm::vec3 position, glm::vec3 rotation, bool renderable);
Object();
~Object();
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
@@ -20,6 +20,7 @@ class Object : public Entity {
private:
Model model;
Material material;
+ bool renderable;
};
#endif