This commit is contained in:
sfroitzheim 2015-03-04 15:42:51 +01:00
commit 11322c0446
6 changed files with 27 additions and 14 deletions

View File

@ -76,6 +76,8 @@
<bColour>0.3</bColour>
<intensity>4.0</intensity>
<flameOffset>-1.5</flameOffset>
<flameHeight>3.0</flameHeight>
<flameWidth>0.8</flameWidth>
</light>
</composition>

View File

@ -61,23 +61,28 @@ void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseD
// Ignore first two mouse updates, because they are incorrect
// DON'T try to move this functionallity elsewhere
static int i = 0;
if (i <2) {
if (i <20) {
i++;
mouseDelta.x=mouseDelta.y=0;
}
int runs = 2;
if(i>=20)
{
mouseDelta.x = -mouseDelta.x;
}
for(int j = runs; j > 0; j--)
{
physics.takeUpdateStep(runTimeSinceLastUpdate/runs);
if(i>=2)
{
mouseDelta.x = -mouseDelta.x;
camera.updateRotation(mouseDelta/100.0f/(float)runs);
physics.updateCameraPos(mouseDelta, 50/runs, camera.getDistance());
camera.setPosition(physics.getCameraPosition());
camera.setDirection(physics.getCameraToPlayer());
}
if(wPressed){
physics.rollForward(camera.getVector(),strength/runs);
}

View File

@ -1,10 +1,12 @@
#include "light.hh"
Light::Light(glm::vec3 position, glm::vec3 colour, float intensity, float flameYOffset)
Light::Light(glm::vec3 position, glm::vec3 colour, float intensity, float flameYOffset, float flameHeight, float flameWidth)
: Entity(position, glm::vec3(0.0f, 0.0f, 0.0f)) {
this->colour = colour;
this->intensity = intensity;
this->flameYOffset = flameYOffset;
this->flameHeight = flameHeight;
this->flameWidth = flameWidth;
}
Light::Light() {

View File

@ -6,7 +6,7 @@
class Light : public Entity {
public:
Light(glm::vec3 position, glm::vec3 colour, float intensity, float flameYOffset = 0.0f);
Light(glm::vec3 position, glm::vec3 colour, float intensity, float flameYOffset = 0.0f, float flameHeight = 0.0f, float flameWidth = 0.0f);
Light();
glm::vec3 getColour();
float getIntensity();
@ -14,6 +14,8 @@ class Light : public Entity {
~Light();
private:
float flameYOffset;
float flameHeight;
float flameWidth;
float intensity;
glm::vec3 colour;
};

View File

@ -299,7 +299,9 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
if (flameOffset != NULL){
float offset = 0;
errorCheck(flameOffset->QueryFloatText(&offset));
Light light = Light(lightPosition, lightColour, lightIntensity, offset);
float flameHeight = queryBool(xmlLight, "flameHeight");
float flameWidth = queryBool(xmlLight, "flameWidth");
Light light = Light(lightPosition, lightColour, lightIntensity, offset, flameHeight, flameWidth);
level->addLight(light);
}
else {

View File

@ -416,7 +416,7 @@ void Physics::addSphere(float rad, Entity entity, float mass, float dampningL, f
void Physics::addCamera() //Camera Creator automatically called when player is created
{
btSphereShape* sphere = new btSphereShape(0.5f); //we use this to make a more interesting camera, that does not interpenetrate with the terrain/objects
btSphereShape* sphere = new btSphereShape(0.2f); //we use this to make a more interesting camera, that does not interpenetrate with the terrain/objects
btVector3 inertia(0,0,0); //rotation handled elsewhere (as it always has to look at the player)
@ -481,7 +481,7 @@ void Physics::updateCameraPos(glm::vec2 mouseMovement, float strength, float dis
this->cameraDistance = distance;
//note: in mouseMovement x and y are flipped in contrast to bullet
btVector3 dodo = btVector3(0,1,0).cross(btVector3(currentDirection.x(),0,currentDirection.z()));
currentDirection = currentDirection.rotate(dodo,-mouseMovement.x / 100);//mathhelper 3.14159265359
currentDirection = currentDirection.rotate(dodo,-mouseMovement.x / 50);//mathhelper 3.14159265359
btVector3 compare = currentDirection;
compare.setY(0);