Merge branch 'master' of github.com:Faerbit/swp

This commit is contained in:
Faerbit 2014-12-15 15:59:12 +01:00
commit a3cc265927
6 changed files with 55 additions and 21 deletions

View File

@ -162,9 +162,10 @@
<diffuseFactor>0.6</diffuseFactor> <diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor> <specularFactor>0.4</specularFactor>
<shininess>2.0</shininess> <shininess>2.0</shininess>
<physicType>TriangleMesh</physicType> <physicType>Box</physicType>
<dampningL>0.5</dampningL> <width>0.5</width>
<dampningA>0.5</dampningA> <height>0.5</height>
<length>0.5</length>
</objectData> </objectData>
<objectData> <objectData>

BIN
Levels/heightmapLvl1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -149,7 +149,7 @@ void Level::load() {
} }
std::string dataModelPath = charDataModelPath; std::string dataModelPath = charDataModelPath;
//objectData found //objectData found
if(dataModelPath == modelPath){ if(dataModelPath.compare(modelPath) == 0){
//create the object //create the object
float ambientFactor, diffuseFactor, specularFactor, shininess; float ambientFactor, diffuseFactor, specularFactor, shininess;
errorCheck(objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor)); errorCheck(objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor));
@ -237,24 +237,24 @@ void Level::load() {
}//iterating over all objects of the composition }//iterating over all objects of the composition
//iterate over all lights of the composition //iterate over all lights of the composition
XMLElement* light = composition->FirstChildElement("light"); XMLElement* xmlLight = composition->FirstChildElement("light");
for(; light; light=light->NextSiblingElement("light")){ for(; xmlLight; xmlLight=xmlLight->NextSiblingElement("light")){
glm::vec3 compRot, lightOffset, lightColour; glm::vec3 compRot, lightOffset, lightColour;
float compScale, compXPos, compYOffset, compZPos, lightIntensity; float compScale, compXPos, compYOffset, compZPos, lightIntensity;
errorCheck(thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale)); errorCheck(thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale));
errorCheck(light->FirstChildElement("xOffset")->QueryFloatText(&lightOffset[0])); errorCheck(xmlLight->FirstChildElement("xOffset")->QueryFloatText(&lightOffset[0]));
errorCheck(light->FirstChildElement("yOffset")->QueryFloatText(&lightOffset[1])); errorCheck(xmlLight->FirstChildElement("yOffset")->QueryFloatText(&lightOffset[1]));
errorCheck(light->FirstChildElement("zOffset")->QueryFloatText(&lightOffset[2])); errorCheck(xmlLight->FirstChildElement("zOffset")->QueryFloatText(&lightOffset[2]));
errorCheck(thisComposition->FirstChildElement("xPos")->QueryFloatText(&compXPos)); errorCheck(thisComposition->FirstChildElement("xPos")->QueryFloatText(&compXPos));
errorCheck(thisComposition->FirstChildElement("yOffset")->QueryFloatText(&compYOffset)); errorCheck(thisComposition->FirstChildElement("yOffset")->QueryFloatText(&compYOffset));
errorCheck(thisComposition->FirstChildElement("zPos")->QueryFloatText(&compZPos)); errorCheck(thisComposition->FirstChildElement("zPos")->QueryFloatText(&compZPos));
errorCheck(thisComposition->FirstChildElement("xRot")->QueryFloatText(&compRot[0])); errorCheck(thisComposition->FirstChildElement("xRot")->QueryFloatText(&compRot[0]));
errorCheck(thisComposition->FirstChildElement("yRot")->QueryFloatText(&compRot[1])); errorCheck(thisComposition->FirstChildElement("yRot")->QueryFloatText(&compRot[1]));
errorCheck(thisComposition->FirstChildElement("zRot")->QueryFloatText(&compRot[2])); errorCheck(thisComposition->FirstChildElement("zRot")->QueryFloatText(&compRot[2]));
errorCheck(light->FirstChildElement("rColour")->QueryFloatText(&lightColour[0])); errorCheck(xmlLight->FirstChildElement("rColour")->QueryFloatText(&lightColour[0]));
errorCheck(light->FirstChildElement("gColour")->QueryFloatText(&lightColour[1])); errorCheck(xmlLight->FirstChildElement("gColour")->QueryFloatText(&lightColour[1]));
errorCheck(light->FirstChildElement("bColour")->QueryFloatText(&lightColour[2])); errorCheck(xmlLight->FirstChildElement("bColour")->QueryFloatText(&lightColour[2]));
errorCheck(light->FirstChildElement("intensity")->QueryFloatText(&lightIntensity)); errorCheck(xmlLight->FirstChildElement("intensity")->QueryFloatText(&lightIntensity));
glm::vec3 compPos = glm::vec3(compXPos, glm::vec3 compPos = glm::vec3(compXPos,
compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())] compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())]
[int(compZPos-0.5+0.5*terrain.getHeightmapWidth())], [int(compZPos-0.5+0.5*terrain.getHeightmapWidth())],
@ -273,15 +273,32 @@ void Level::load() {
}//iterating over all compositions in Level.xml }//iterating over all compositions in Level.xml
//load triggers //load triggers
XMLElement* trigger = doc->FirstChildElement("trigger"); XMLElement* xmlTrigger = doc->FirstChildElement("trigger");
for(; trigger; trigger=trigger->NextSiblingElement("trigger")){ for(; xmlTrigger; xmlTrigger=xmlTrigger->NextSiblingElement("trigger")){
const char* charName = trigger->FirstChildElement("name")->GetText(); const char* charName = xmlTrigger->FirstChildElement("name")->GetText();
if(charName == NULL){ if(charName == NULL){
printf("XMLError: No name found for a trigger.\n"); printf("XMLError: No name found for a trigger.\n");
} }
std::string name = charName; std::string name = charName;
if (name.compare("-") != 0){ if (name.compare("-") != 0){
//TODO add triggers float xPos, yPos, zPos, distance;
std::vector<float> position;
bool isBigger;
int idGreen, idBlue, objectNum;
errorCheck(xmlTrigger->FirstChildElement("xPosition")->QueryFloatText(&xPos));
errorCheck(xmlTrigger->FirstChildElement("yPosition")->QueryFloatText(&yPos));
errorCheck(xmlTrigger->FirstChildElement("zPosition")->QueryFloatText(&zPos));
errorCheck(xmlTrigger->FirstChildElement("distance")->QueryFloatText(&distance));
position.push_back(xPos);
position.push_back(yPos);
position.push_back(zPos);
errorCheck(xmlTrigger->FirstChildElement("isBiggerThan")->QueryBoolText(&isBigger));
errorCheck(xmlTrigger->FirstChildElement("idGreen")->QueryIntText(&idGreen));
errorCheck(xmlTrigger->FirstChildElement("idBlue")->QueryIntText(&idBlue));
errorCheck(xmlTrigger->FirstChildElement("objectNum")->QueryIntText(&objectNum));
//TODO find the object
//Trigger trigger = Trigger::Trigger(position, distance, isBigger, Object* object, void (*functionPointer)());
//triggers.push_back(trigger);
} }
} }

View File

@ -10,6 +10,7 @@
#include "camera.hh" #include "camera.hh"
#include "physics.hh" #include "physics.hh"
#include "tinyxml2.hh" #include "tinyxml2.hh"
#include "trigger.hh"
class Level { class Level {
public: public:
@ -34,6 +35,7 @@ class Level {
std::vector<Object*> objects; std::vector<Object*> objects;
std::vector<Object*> physicObjects; std::vector<Object*> physicObjects;
std::vector<Light> lights; std::vector<Light> lights;
std::vector<Trigger> triggers;
glm::vec3 ambientLight; glm::vec3 ambientLight;
glm::vec4 fogColour; glm::vec4 fogColour;
Light directionalLight; Light directionalLight;

View File

@ -1,7 +1,11 @@
#include "trigger.hh" #include "trigger.hh"
Trigger::Trigger(std::vector<float> position, float distance, bool isBigger, int objectIndex, int functionPointer) { Trigger::Trigger(std::vector<float> position, float distance, bool isBigger, Object* object, void (*functionPointer)()) {
this->position=position;
this->distance=distance;
this->isBigger=isBigger;
this->object=object;
this->functionPointer=functionPointer;
} }
Trigger::Trigger(){ Trigger::Trigger(){
@ -9,3 +13,7 @@ Trigger::Trigger(){
Trigger::~Trigger(){ Trigger::~Trigger(){
} }
void Trigger::triggerUpdate(){
}

View File

@ -2,14 +2,20 @@
#define TRIGGER_HH_INCLUDED #define TRIGGER_HH_INCLUDED
#include <vector> #include <vector>
#include "object.hh"
class Trigger { class Trigger {
public: public:
Trigger(std::vector<float> position, float distance, bool isBigger, int objectIndex, int functionPointer); Trigger(std::vector<float> position, float distance, bool isBigger, Object* object, void (*functionPointer)());
Trigger(); Trigger();
~Trigger(); ~Trigger();
void triggerUpdate();
private: private:
std::vector<float> position;
float distance;
bool isBigger;
Object* object;
void (*functionPointer)();
}; };
#endif #endif