Merge branch 'master' of github.com:Faerbit/swp
This commit is contained in:
commit
15f91a19b9
@ -162,9 +162,10 @@
|
||||
<diffuseFactor>0.6</diffuseFactor>
|
||||
<specularFactor>0.4</specularFactor>
|
||||
<shininess>2.0</shininess>
|
||||
<physicType>TriangleMesh</physicType>
|
||||
<dampningL>0.5</dampningL>
|
||||
<dampningA>0.5</dampningA>
|
||||
<physicType>Box</physicType>
|
||||
<width>0.5</width>
|
||||
<height>0.5</height>
|
||||
<length>0.5</length>
|
||||
</objectData>
|
||||
|
||||
<objectData>
|
||||
|
BIN
Levels/heightmapLvl1.png
Normal file
BIN
Levels/heightmapLvl1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
45
level.cc
45
level.cc
@ -149,7 +149,7 @@ void Level::load() {
|
||||
}
|
||||
std::string dataModelPath = charDataModelPath;
|
||||
//objectData found
|
||||
if(dataModelPath == modelPath){
|
||||
if(dataModelPath.compare(modelPath) == 0){
|
||||
//create the object
|
||||
float ambientFactor, diffuseFactor, specularFactor, shininess;
|
||||
errorCheck(objectData->FirstChildElement("ambientFactor")->QueryFloatText(&ambientFactor));
|
||||
@ -237,24 +237,24 @@ void Level::load() {
|
||||
}//iterating over all objects of the composition
|
||||
|
||||
//iterate over all lights of the composition
|
||||
XMLElement* light = composition->FirstChildElement("light");
|
||||
for(; light; light=light->NextSiblingElement("light")){
|
||||
XMLElement* xmlLight = composition->FirstChildElement("light");
|
||||
for(; xmlLight; xmlLight=xmlLight->NextSiblingElement("light")){
|
||||
glm::vec3 compRot, lightOffset, lightColour;
|
||||
float compScale, compXPos, compYOffset, compZPos, lightIntensity;
|
||||
errorCheck(thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale));
|
||||
errorCheck(light->FirstChildElement("xOffset")->QueryFloatText(&lightOffset[0]));
|
||||
errorCheck(light->FirstChildElement("yOffset")->QueryFloatText(&lightOffset[1]));
|
||||
errorCheck(light->FirstChildElement("zOffset")->QueryFloatText(&lightOffset[2]));
|
||||
errorCheck(xmlLight->FirstChildElement("xOffset")->QueryFloatText(&lightOffset[0]));
|
||||
errorCheck(xmlLight->FirstChildElement("yOffset")->QueryFloatText(&lightOffset[1]));
|
||||
errorCheck(xmlLight->FirstChildElement("zOffset")->QueryFloatText(&lightOffset[2]));
|
||||
errorCheck(thisComposition->FirstChildElement("xPos")->QueryFloatText(&compXPos));
|
||||
errorCheck(thisComposition->FirstChildElement("yOffset")->QueryFloatText(&compYOffset));
|
||||
errorCheck(thisComposition->FirstChildElement("zPos")->QueryFloatText(&compZPos));
|
||||
errorCheck(thisComposition->FirstChildElement("xRot")->QueryFloatText(&compRot[0]));
|
||||
errorCheck(thisComposition->FirstChildElement("yRot")->QueryFloatText(&compRot[1]));
|
||||
errorCheck(thisComposition->FirstChildElement("zRot")->QueryFloatText(&compRot[2]));
|
||||
errorCheck(light->FirstChildElement("rColour")->QueryFloatText(&lightColour[0]));
|
||||
errorCheck(light->FirstChildElement("gColour")->QueryFloatText(&lightColour[1]));
|
||||
errorCheck(light->FirstChildElement("bColour")->QueryFloatText(&lightColour[2]));
|
||||
errorCheck(light->FirstChildElement("intensity")->QueryFloatText(&lightIntensity));
|
||||
errorCheck(xmlLight->FirstChildElement("rColour")->QueryFloatText(&lightColour[0]));
|
||||
errorCheck(xmlLight->FirstChildElement("gColour")->QueryFloatText(&lightColour[1]));
|
||||
errorCheck(xmlLight->FirstChildElement("bColour")->QueryFloatText(&lightColour[2]));
|
||||
errorCheck(xmlLight->FirstChildElement("intensity")->QueryFloatText(&lightIntensity));
|
||||
glm::vec3 compPos = glm::vec3(compXPos,
|
||||
compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())]
|
||||
[int(compZPos-0.5+0.5*terrain.getHeightmapWidth())],
|
||||
@ -273,15 +273,32 @@ void Level::load() {
|
||||
}//iterating over all compositions in Level.xml
|
||||
|
||||
//load triggers
|
||||
XMLElement* trigger = doc->FirstChildElement("trigger");
|
||||
for(; trigger; trigger=trigger->NextSiblingElement("trigger")){
|
||||
const char* charName = trigger->FirstChildElement("name")->GetText();
|
||||
XMLElement* xmlTrigger = doc->FirstChildElement("trigger");
|
||||
for(; xmlTrigger; xmlTrigger=xmlTrigger->NextSiblingElement("trigger")){
|
||||
const char* charName = xmlTrigger->FirstChildElement("name")->GetText();
|
||||
if(charName == NULL){
|
||||
printf("XMLError: No name found for a trigger.\n");
|
||||
}
|
||||
std::string name = charName;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
2
level.hh
2
level.hh
@ -10,6 +10,7 @@
|
||||
#include "camera.hh"
|
||||
#include "physics.hh"
|
||||
#include "tinyxml2.hh"
|
||||
#include "trigger.hh"
|
||||
|
||||
class Level {
|
||||
public:
|
||||
@ -34,6 +35,7 @@ class Level {
|
||||
std::vector<Object*> objects;
|
||||
std::vector<Object*> physicObjects;
|
||||
std::vector<Light> lights;
|
||||
std::vector<Trigger> triggers;
|
||||
glm::vec3 ambientLight;
|
||||
glm::vec4 fogColour;
|
||||
Light directionalLight;
|
||||
|
12
trigger.cc
12
trigger.cc
@ -1,7 +1,11 @@
|
||||
#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(){
|
||||
@ -9,3 +13,7 @@ Trigger::Trigger(){
|
||||
|
||||
Trigger::~Trigger(){
|
||||
}
|
||||
|
||||
void Trigger::triggerUpdate(){
|
||||
|
||||
}
|
||||
|
10
trigger.hh
10
trigger.hh
@ -2,14 +2,20 @@
|
||||
#define TRIGGER_HH_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
#include "object.hh"
|
||||
|
||||
class Trigger {
|
||||
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();
|
||||
void triggerUpdate();
|
||||
private:
|
||||
|
||||
std::vector<float> position;
|
||||
float distance;
|
||||
bool isBigger;
|
||||
Object* object;
|
||||
void (*functionPointer)();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user