Merge branch 'master' of https://github.com/Faerbit/swp
This commit is contained in:
commit
49f041341a
@ -3913,7 +3913,7 @@
|
|||||||
<positionConstraint>
|
<positionConstraint>
|
||||||
<objectNum>0</objectNum>
|
<objectNum>0</objectNum>
|
||||||
<xPosition>-161.5</xPosition>
|
<xPosition>-161.5</xPosition>
|
||||||
<yPosition>21.7</yPosition>
|
<yPosition>20.9</yPosition>
|
||||||
<zPosition>67.5</zPosition>
|
<zPosition>67.5</zPosition>
|
||||||
<strength>12.0</strength>
|
<strength>12.0</strength>
|
||||||
</positionConstraint>
|
</positionConstraint>
|
||||||
@ -3921,7 +3921,7 @@
|
|||||||
<name>openThirdDoor</name>
|
<name>openThirdDoor</name>
|
||||||
<undo>false</undo>
|
<undo>false</undo>
|
||||||
<xPosition>-161.5</xPosition>
|
<xPosition>-161.5</xPosition>
|
||||||
<yPosition>21.7</yPosition>
|
<yPosition>20.9</yPosition>
|
||||||
<zPosition>67.5</zPosition>
|
<zPosition>67.5</zPosition>
|
||||||
<targetIdGreen>-</targetIdGreen>
|
<targetIdGreen>-</targetIdGreen>
|
||||||
<targetIdBlue>-</targetIdBlue>
|
<targetIdBlue>-</targetIdBlue>
|
||||||
@ -3937,7 +3937,7 @@
|
|||||||
<name>openThirdDoorUndo</name>
|
<name>openThirdDoorUndo</name>
|
||||||
<undo>true</undo>
|
<undo>true</undo>
|
||||||
<xPosition>-161.5</xPosition>
|
<xPosition>-161.5</xPosition>
|
||||||
<yPosition>21.7</yPosition>
|
<yPosition>20.9</yPosition>
|
||||||
<zPosition>67.5</zPosition>
|
<zPosition>67.5</zPosition>
|
||||||
<targetIdGreen>-</targetIdGreen>
|
<targetIdGreen>-</targetIdGreen>
|
||||||
<targetIdBlue>-</targetIdBlue>
|
<targetIdBlue>-</targetIdBlue>
|
||||||
@ -6402,7 +6402,7 @@
|
|||||||
<positionConstraint>
|
<positionConstraint>
|
||||||
<objectNum>0</objectNum>
|
<objectNum>0</objectNum>
|
||||||
<xPosition>17.5</xPosition>
|
<xPosition>17.5</xPosition>
|
||||||
<yPosition>21.8</yPosition>
|
<yPosition>21.0</yPosition>
|
||||||
<zPosition>159.5</zPosition>
|
<zPosition>159.5</zPosition>
|
||||||
<strength>12.0</strength>
|
<strength>12.0</strength>
|
||||||
</positionConstraint>
|
</positionConstraint>
|
||||||
@ -6410,7 +6410,7 @@
|
|||||||
<name>openFirstDoor</name>
|
<name>openFirstDoor</name>
|
||||||
<undo>false</undo>
|
<undo>false</undo>
|
||||||
<xPosition>17.5</xPosition>
|
<xPosition>17.5</xPosition>
|
||||||
<yPosition>21.8</yPosition>
|
<yPosition>21.0</yPosition>
|
||||||
<zPosition>159.5</zPosition>
|
<zPosition>159.5</zPosition>
|
||||||
<targetIdGreen>-</targetIdGreen>
|
<targetIdGreen>-</targetIdGreen>
|
||||||
<targetIdBlue>-</targetIdBlue>
|
<targetIdBlue>-</targetIdBlue>
|
||||||
@ -6426,7 +6426,7 @@
|
|||||||
<name>openFirstDoorUndo</name>
|
<name>openFirstDoorUndo</name>
|
||||||
<undo>true</undo>
|
<undo>true</undo>
|
||||||
<xPosition>17.5</xPosition>
|
<xPosition>17.5</xPosition>
|
||||||
<yPosition>21.8</yPosition>
|
<yPosition>21.0</yPosition>
|
||||||
<zPosition>159.5</zPosition>
|
<zPosition>159.5</zPosition>
|
||||||
<targetIdGreen>-</targetIdGreen>
|
<targetIdGreen>-</targetIdGreen>
|
||||||
<targetIdBlue>-</targetIdBlue>
|
<targetIdBlue>-</targetIdBlue>
|
||||||
@ -12186,6 +12186,11 @@
|
|||||||
<nightTexture>nightskydome.png</nightTexture>
|
<nightTexture>nightskydome.png</nightTexture>
|
||||||
</skydome>
|
</skydome>
|
||||||
|
|
||||||
|
<waterPlane>
|
||||||
|
<yPosition>15</yPosition>
|
||||||
|
<texture>skydomeNew.png</texture>
|
||||||
|
</waterPlane>
|
||||||
|
|
||||||
<physics>
|
<physics>
|
||||||
<friction>0.9</friction>
|
<friction>0.9</friction>
|
||||||
<strength>200.0</strength>
|
<strength>200.0</strength>
|
||||||
|
36
loader.cc
36
loader.cc
@ -1,4 +1,5 @@
|
|||||||
#include "loader.hh"
|
#include "loader.hh"
|
||||||
|
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
|
|
||||||
Loader::Loader() {
|
Loader::Loader() {
|
||||||
@ -94,6 +95,41 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
Skydome skydomeObject = Skydome(skydomeModel, skydomeMaterial, nightMaterial);
|
Skydome skydomeObject = Skydome(skydomeModel, skydomeMaterial, nightMaterial);
|
||||||
level->setSkydomeObject(skydomeObject);
|
level->setSkydomeObject(skydomeObject);
|
||||||
|
|
||||||
|
//load the waterPlane
|
||||||
|
XMLElement* waterElement = doc->FirstChildElement("waterPlane");
|
||||||
|
if (waterElement != NULL){
|
||||||
|
float waterHeight = queryFloat(waterElement, "yPosition");
|
||||||
|
std::string waterTexture = queryString(waterElement, "texture");
|
||||||
|
std::string waterTexturePath = "../" + globalTexturePath + waterTexture;
|
||||||
|
if(stat(waterTexturePath.c_str(), &buf) != 0){
|
||||||
|
std::cout << "The texture file " << waterTexturePath << " does not exist." << std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
float heightmapHeight = level->getTerrain()->getHeightmapHeight();
|
||||||
|
float heightmapWidth = level->getTerrain()->getHeightmapWidth();
|
||||||
|
float planeData[] = {
|
||||||
|
-heightmapWidth/2.0f, waterHeight, -heightmapHeight/2.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
-heightmapWidth/2.0f, waterHeight, heightmapHeight/2.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
heightmapWidth/2.0f, waterHeight, -heightmapHeight/2.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
|
||||||
|
heightmapWidth/2.0f, waterHeight, heightmapHeight/2.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
-heightmapWidth/2.0f, waterHeight, heightmapHeight/2.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
heightmapWidth/2.0f, waterHeight, -heightmapHeight/2.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f
|
||||||
|
};
|
||||||
|
ACGL::OpenGL::SharedArrayBuffer water_ab = ACGL::OpenGL::SharedArrayBuffer(new ACGL::OpenGL::ArrayBuffer());
|
||||||
|
water_ab->defineAttribute("aPosition", GL_FLOAT, 3);
|
||||||
|
water_ab->defineAttribute("aTexCoord", GL_FLOAT, 2);
|
||||||
|
water_ab->defineAttribute("aNormal", GL_FLOAT, 3);
|
||||||
|
water_ab->setDataElements(6, planeData);
|
||||||
|
ACGL::OpenGL::SharedVertexArrayObject water_vao = ACGL::OpenGL::SharedVertexArrayObject(new ACGL::OpenGL::VertexArrayObject());
|
||||||
|
water_vao->bind();
|
||||||
|
water_vao->setMode(GL_TRIANGLES);
|
||||||
|
water_vao->attachAllAttributes(water_ab);
|
||||||
|
Material water_material = Material(waterTexture, 0.1f, 0.2f, 0.8f, 5.0f, true);
|
||||||
|
Object* water_object = new Object(water_vao, water_material, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), true);
|
||||||
|
level->addObject(water_object);
|
||||||
|
}
|
||||||
|
|
||||||
//load lighting parameters
|
//load lighting parameters
|
||||||
float rColour, gColour, bColour, alpha, xOffset, yOffset, zOffset, intensity;
|
float rColour, gColour, bColour, alpha, xOffset, yOffset, zOffset, intensity;
|
||||||
XMLElement* ambientElement = doc->FirstChildElement("ambientLight");
|
XMLElement* ambientElement = doc->FirstChildElement("ambientLight");
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
#include "material.hh"
|
#include "material.hh"
|
||||||
|
|
||||||
Material::Material(std::string filePath, float ambientFactor, float diffuseFactor,
|
Material::Material(std::string filePath, float ambientFactor, float diffuseFactor,
|
||||||
float specularFactor, float shininess) {
|
float specularFactor, float shininess, bool movingTexture) {
|
||||||
reference = ACGL::OpenGL::Texture2DFileManager::the()->get(ACGL::OpenGL::Texture2DCreator(filePath));
|
reference = ACGL::OpenGL::Texture2DFileManager::the()->get(ACGL::OpenGL::Texture2DCreator(filePath));
|
||||||
reference->generateMipmaps();
|
reference->generateMipmaps();
|
||||||
this->ambientFactor = ambientFactor;
|
this->ambientFactor = ambientFactor;
|
||||||
this->diffuseFactor = diffuseFactor;
|
this->diffuseFactor = diffuseFactor;
|
||||||
this->specularFactor = specularFactor;
|
this->specularFactor = specularFactor;
|
||||||
this->shininess = shininess;
|
this->shininess = shininess;
|
||||||
|
this->movingTexture = movingTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
Material::Material() {
|
Material::Material() {
|
||||||
@ -35,3 +36,7 @@ float Material::getSpecularFactor() {
|
|||||||
float Material::getShininess() {
|
float Material::getShininess() {
|
||||||
return shininess;
|
return shininess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Material::isMoving(){
|
||||||
|
return movingTexture;
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
class Material{
|
class Material{
|
||||||
public:
|
public:
|
||||||
Material(std::string filePath, float ambientFactor,
|
Material(std::string filePath, float ambientFactor,
|
||||||
float diffuseFactor, float specularFactor, float shininess);
|
float diffuseFactor, float specularFactor, float shininess, bool movingTexture = false);
|
||||||
Material();
|
Material();
|
||||||
ACGL::OpenGL::SharedTexture2D getReference();
|
ACGL::OpenGL::SharedTexture2D getReference();
|
||||||
~Material();
|
~Material();
|
||||||
@ -17,12 +17,15 @@ class Material{
|
|||||||
float getDiffuseFactor();
|
float getDiffuseFactor();
|
||||||
float getSpecularFactor();
|
float getSpecularFactor();
|
||||||
float getShininess();
|
float getShininess();
|
||||||
|
bool isMoving();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ACGL::OpenGL::SharedTexture2D reference;
|
ACGL::OpenGL::SharedTexture2D reference;
|
||||||
float ambientFactor;
|
float ambientFactor;
|
||||||
float diffuseFactor;
|
float diffuseFactor;
|
||||||
float specularFactor;
|
float specularFactor;
|
||||||
float shininess;
|
float shininess;
|
||||||
|
bool movingTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,6 +21,12 @@ void Object::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
|
|||||||
}
|
}
|
||||||
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(texturePass) {
|
if(texturePass) {
|
||||||
|
if (material.isMoving()) {
|
||||||
|
shader->setUniform("movingTexture", true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
shader->setUniform("movingTexture", false);
|
||||||
|
}
|
||||||
shader->setTexture("uTexture", material.getReference(), 0);
|
shader->setTexture("uTexture", material.getReference(), 0);
|
||||||
shader->setUniform("modelMatrix", modelMatrix);
|
shader->setUniform("modelMatrix", modelMatrix);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user