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>
|
<radius>1.0</radius>
|
||||||
<dampningL>0.15 </dampningL>
|
<dampningL>0.15 </dampningL>
|
||||||
<dampningA>0.7</dampningA>
|
<dampningA>0.7</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<!-- Do not change width height or length, they have to match the .obj -->
|
<!-- Do not change width height or length, they have to match the .obj -->
|
||||||
@ -476,7 +477,7 @@
|
|||||||
<length>1.99</length>
|
<length>1.99</length>
|
||||||
<dampningL>0.8</dampningL>
|
<dampningL>0.8</dampningL>
|
||||||
<dampningA>0.9</dampningA>
|
<dampningA>0.9</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<objectData>
|
<objectData>
|
||||||
@ -489,6 +490,7 @@
|
|||||||
<physicType>TriangleMesh</physicType>
|
<physicType>TriangleMesh</physicType>
|
||||||
<dampningL>0.8</dampningL>
|
<dampningL>0.8</dampningL>
|
||||||
<dampningA>0.9</dampningA>
|
<dampningA>0.9</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<objectData>
|
<objectData>
|
||||||
@ -501,6 +503,7 @@
|
|||||||
<physicType>TriangleMesh</physicType>
|
<physicType>TriangleMesh</physicType>
|
||||||
<dampningL>0.8</dampningL>
|
<dampningL>0.8</dampningL>
|
||||||
<dampningA>0.9</dampningA>
|
<dampningA>0.9</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<!-- Do not change width height or length, they have to match the .obj -->
|
<!-- Do not change width height or length, they have to match the .obj -->
|
||||||
@ -517,6 +520,7 @@
|
|||||||
<length>1.8</length>
|
<length>1.8</length>
|
||||||
<dampningL>0.5</dampningL>
|
<dampningL>0.5</dampningL>
|
||||||
<dampningA>1.0</dampningA>
|
<dampningA>1.0</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<!-- Do not change width height or length, they have to match the .obj -->
|
<!-- Do not change width height or length, they have to match the .obj -->
|
||||||
@ -533,6 +537,7 @@
|
|||||||
<length>0.33</length>
|
<length>0.33</length>
|
||||||
<dampningL>0.555</dampningL>
|
<dampningL>0.555</dampningL>
|
||||||
<dampningA>0.5</dampningA>
|
<dampningA>0.5</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<!-- lengh may not be exact -->
|
<!-- lengh may not be exact -->
|
||||||
@ -549,6 +554,7 @@
|
|||||||
<length>6</length>
|
<length>6</length>
|
||||||
<dampningL>0.555</dampningL>
|
<dampningL>0.555</dampningL>
|
||||||
<dampningA>0.5</dampningA>
|
<dampningA>0.5</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<objectData>
|
<objectData>
|
||||||
@ -564,6 +570,7 @@
|
|||||||
<length>6</length>
|
<length>6</length>
|
||||||
<dampningL>0.555</dampningL>
|
<dampningL>0.555</dampningL>
|
||||||
<dampningA>0.5</dampningA>
|
<dampningA>0.5</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
|
||||||
<objectData>
|
<objectData>
|
||||||
@ -579,4 +586,5 @@
|
|||||||
<length>1.99</length>
|
<length>1.99</length>
|
||||||
<dampningL>0.555</dampningL>
|
<dampningL>0.555</dampningL>
|
||||||
<dampningA>0.5</dampningA>
|
<dampningA>0.5</dampningA>
|
||||||
|
<renderable>true</renderable>
|
||||||
</objectData>
|
</objectData>
|
||||||
|
18
loader.cc
18
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);
|
Material terrainMaterial = Material(terrainTexture, terrainAmbientFactor, terrainDiffuseFactor, terrainSpecularFactor, terrainShininess);
|
||||||
Object* terrainObject = new Object(terrainModel, terrainMaterial,
|
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.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->addObject(terrainObject);
|
||||||
level->getPhysics()->addTerrain(level->getTerrain()->getHeightmapWidth(), level->getTerrain()->getHeightmapHeight(), level->getTerrain()->getHeightmap());
|
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());
|
Model skydomeModel = Model("skydome.obj", level->getSkydomeSize());
|
||||||
Material skydomeMaterial = Material(skydomeTexture, 0.7f, 0.0f, 0.0f, 0.0f);
|
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),
|
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->addObject(skydomeObject);
|
||||||
level->setSkydomeObject(skydomeObject);
|
level->setSkydomeObject(skydomeObject);
|
||||||
|
|
||||||
@ -117,7 +117,6 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
float objectScale, compScale;
|
float objectScale, compScale;
|
||||||
errorCheck(xmlObject->FirstChildElement("scale")->QueryFloatText(&objectScale));
|
errorCheck(xmlObject->FirstChildElement("scale")->QueryFloatText(&objectScale));
|
||||||
errorCheck(thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale));
|
errorCheck(thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale));
|
||||||
Model model = Model(modelPath, objectScale * compScale);
|
|
||||||
//find the objectData for the current object
|
//find the objectData for the current object
|
||||||
XMLElement* objectData = compositions->FirstChildElement("objectData");
|
XMLElement* objectData = compositions->FirstChildElement("objectData");
|
||||||
for(; objectData; objectData=objectData->NextSiblingElement("objectData")){
|
for(; objectData; objectData=objectData->NextSiblingElement("objectData")){
|
||||||
@ -129,7 +128,12 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
std::string dataModelPath = charDataModelPath;
|
std::string dataModelPath = charDataModelPath;
|
||||||
//objectData found
|
//objectData found
|
||||||
if(dataModelPath.compare(modelPath) == 0){
|
if(dataModelPath.compare(modelPath) == 0){
|
||||||
|
bool renderable;
|
||||||
|
errorCheck(objectData->FirstChildElement("renderable")->QueryBoolText(&renderable));
|
||||||
//create the object
|
//create the object
|
||||||
|
Material material;
|
||||||
|
Model model;
|
||||||
|
if (renderable) {
|
||||||
float ambientFactor, diffuseFactor, specularFactor, shininess;
|
float ambientFactor, diffuseFactor, specularFactor, shininess;
|
||||||
errorCheck(objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor));
|
errorCheck(objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor));
|
||||||
errorCheck(objectData->FirstChildElement("diffuseFactor")->QueryFloatText(&diffuseFactor));
|
errorCheck(objectData->FirstChildElement("diffuseFactor")->QueryFloatText(&diffuseFactor));
|
||||||
@ -141,7 +145,9 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
std::string texturePath = charTexturePath;
|
std::string texturePath = charTexturePath;
|
||||||
Material material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
|
material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
|
||||||
|
model = Model(modelPath, objectScale * compScale);
|
||||||
|
}
|
||||||
float compXPos, compYOffset, compZPos;
|
float compXPos, compYOffset, compZPos;
|
||||||
glm::vec3 objectOffset, compRot;
|
glm::vec3 objectOffset, compRot;
|
||||||
errorCheck(xmlObject->FirstChildElement("xOffset")->QueryFloatText(&objectOffset[0]));
|
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("yRot")->QueryFloatText(&objectRot[1]));
|
||||||
errorCheck(xmlObject->FirstChildElement("zRot")->QueryFloatText(&objectRot[2]));
|
errorCheck(xmlObject->FirstChildElement("zRot")->QueryFloatText(&objectRot[2]));
|
||||||
objectRot *= 0.0174532925; //transform degrees to radians
|
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->addObject(object);
|
||||||
level->addPhysicsObject(object);
|
level->addPhysicsObject(object);
|
||||||
|
|
||||||
@ -197,9 +203,9 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
std::string physicType = charPhysicType;
|
std::string physicType = charPhysicType;
|
||||||
float mass;
|
float mass;
|
||||||
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
|
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
|
||||||
float dampningL, dampningA;
|
|
||||||
XMLElement* constraint = thisComposition->FirstChildElement("positionConstraint");
|
XMLElement* constraint = thisComposition->FirstChildElement("positionConstraint");
|
||||||
bool rotate = (constraint == NULL);
|
bool rotate = (constraint == NULL);
|
||||||
|
float dampningL, dampningA;
|
||||||
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
|
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
|
||||||
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
|
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
|
||||||
if (physicType.compare("Player") == 0){
|
if (physicType.compare("Player") == 0){
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "object.hh"
|
#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) {
|
Entity(position, rotation) {
|
||||||
this->model = model;
|
this->model = model;
|
||||||
this->material = material;
|
this->material = material;
|
||||||
|
this->renderable = renderable;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::Object() {
|
Object::Object() {
|
||||||
@ -14,6 +15,9 @@ Object::~Object() {
|
|||||||
|
|
||||||
void Object::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
void Object::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
||||||
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs) {
|
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()));
|
glm::mat4 modelMatrix = glm::translate(getPosition()) * getRotation() * glm::scale<float>(glm::vec3(model.getScale()));
|
||||||
if (lightingPass) {
|
if (lightingPass) {
|
||||||
// set lightning parameters for this object
|
// set lightning parameters for this object
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
class Object : public Entity {
|
class Object : public Entity {
|
||||||
public:
|
public:
|
||||||
Object(Model model, Material material,
|
Object(Model model, Material material,
|
||||||
glm::vec3 position, glm::vec3 rotation);
|
glm::vec3 position, glm::vec3 rotation, bool renderable);
|
||||||
Object();
|
Object();
|
||||||
~Object();
|
~Object();
|
||||||
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
||||||
@ -20,6 +20,7 @@ class Object : public Entity {
|
|||||||
private:
|
private:
|
||||||
Model model;
|
Model model;
|
||||||
Material material;
|
Material material;
|
||||||
|
bool renderable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user