objectData now has a new value called renderable, if it is false the object will not get rendered.
This commit is contained in:
parent
21d94a420f
commit
7647c5f1c0
@ -460,6 +460,7 @@
|
||||
<radius>1.0</radius>
|
||||
<dampningL>0.15 </dampningL>
|
||||
<dampningA>0.7</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<!-- Do not change width height or length, they have to match the .obj -->
|
||||
@ -476,7 +477,7 @@
|
||||
<length>1.99</length>
|
||||
<dampningL>0.8</dampningL>
|
||||
<dampningA>0.9</dampningA>
|
||||
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<objectData>
|
||||
@ -489,6 +490,7 @@
|
||||
<physicType>TriangleMesh</physicType>
|
||||
<dampningL>0.8</dampningL>
|
||||
<dampningA>0.9</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<objectData>
|
||||
@ -501,6 +503,7 @@
|
||||
<physicType>TriangleMesh</physicType>
|
||||
<dampningL>0.8</dampningL>
|
||||
<dampningA>0.9</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<!-- Do not change width height or length, they have to match the .obj -->
|
||||
@ -517,6 +520,7 @@
|
||||
<length>1.8</length>
|
||||
<dampningL>0.5</dampningL>
|
||||
<dampningA>1.0</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<!-- Do not change width height or length, they have to match the .obj -->
|
||||
@ -533,6 +537,7 @@
|
||||
<length>0.33</length>
|
||||
<dampningL>0.555</dampningL>
|
||||
<dampningA>0.5</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<!-- lengh may not be exact -->
|
||||
@ -549,6 +554,7 @@
|
||||
<length>6</length>
|
||||
<dampningL>0.555</dampningL>
|
||||
<dampningA>0.5</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<objectData>
|
||||
@ -564,6 +570,7 @@
|
||||
<length>6</length>
|
||||
<dampningL>0.555</dampningL>
|
||||
<dampningA>0.5</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
||||
<objectData>
|
||||
@ -579,4 +586,5 @@
|
||||
<length>1.99</length>
|
||||
<dampningL>0.555</dampningL>
|
||||
<dampningA>0.5</dampningA>
|
||||
<renderable>true</renderable>
|
||||
</objectData>
|
||||
|
38
loader.cc
38
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){
|
||||
|
@ -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<glm::mat4>* shadowVPs) {
|
||||
if (!renderable) {
|
||||
return;
|
||||
}
|
||||
glm::mat4 modelMatrix = glm::translate(getPosition()) * getRotation() * glm::scale<float>(glm::vec3(model.getScale()));
|
||||
if (lightingPass) {
|
||||
// set lightning parameters for this object
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user