This commit is contained in:
Lendemor 2016-12-13 00:42:20 +01:00
commit 2a32596873
3 changed files with 16 additions and 8 deletions

View File

@ -51,7 +51,7 @@ void FirstPersonCamera::setUpVector(const glm::vec3 &up)
computeView();
}
const float WALK_SPEED = 0.5f;
const float WALK_SPEED = 12.f;
const float PLAYER_RADIUS = 0.30f;
const float PLAYER_HEIGHT = 1.75f;
const float EYES_OFFSET = 0.775f;
@ -133,13 +133,14 @@ void PlayerCharacterNode::update()
if (m_noclipMode)
{
btVector3 dir(moveDir.x, moveDir.y, moveDir.z);
m_noclip_pos += dir*WALK_SPEED*2.f;
m_noclip_pos += dir*WALK_SPEED*getEngine().getDeltaTime()*0.004f;
}
else
{
//TODO: if on ground + space pressed -> jump
glm::vec2 hPos = glm::normalize(glm::vec2(moveDir.x, moveDir.y));
m_rigidBody->setLinearVelocity((m_rigidBody->getLinearVelocity() + btVector3(hPos.x, m_rigidBody->getLinearVelocity().getY(), hPos.y)) / 2.f); // smooth movements
glm::vec2 hPos = glm::normalize(glm::vec2(moveDir.x, moveDir.z))*WALK_SPEED;
const btVector3 &velocity = m_rigidBody->getLinearVelocity();
m_rigidBody->setLinearVelocity((velocity + btVector3(hPos.x, velocity.getY(), hPos.y)) / 2.f); // smooth movements
}
}
if(m_noclipMode)

View File

@ -97,6 +97,10 @@ void generateTerrain(SceneTree *scene, btDiscreteDynamicsWorld *world)
scene->getRootObject()->addChild(terrainContainer);
TestGen gen;
PhongMaterial *mat = new PhongMaterial();
mat->shininess = 5.f;
mat->diffuse = glm::vec3(0.1f, 0.4f, 0.2f);
mat->specular = glm::vec3(0.1f);
mat->emission = glm::vec3(0.5f, 0.1f, 0.1f);
for(int x=-6; x<6; ++x)
for(int y=-3; y<3; ++y)

View File

@ -6,6 +6,8 @@
#include "parametricmesh.h"
#include "phongmaterial.h"
#include "scene/meshnode.h"
#include "tools/loader.h"
#include "texture.h"
#define PHYSICS_OFFSET 0.05f
@ -61,8 +63,9 @@ Potator::Potator(PlayerCharacterNode * player,
m_cubeMesh->addTriangle(id+7, id+5, id+6);
}
Image* wood = Loader::loadImage("../data/woodbox.jpg", false);
PhongMaterial *mat = new PhongMaterial();
mat->diffuse = glm::vec3(0.6f, 0.2f, 0.3f);
mat->setTexture(PhongMaterial::DIFFUSE_SLOT, new Texture(wood), "wood_texture");
mat->specular = glm::vec3(0.3f);
mat->shininess = 5.f;
mat->emission = glm::vec3(0.0f);
@ -78,9 +81,9 @@ Potator::Potator(PlayerCharacterNode * player,
// creating sphere
mat = new PhongMaterial();
mat->diffuse = glm::vec3(0.1f, 0.6f, 0.3f);
mat->specular = glm::vec3(0.7f);
mat->shininess = 35.f;
mat->diffuse = glm::vec3(0.1f);
mat->specular = glm::vec3(0.9f);
mat->shininess = 150.f;
mat->emission = glm::vec3(0.0f);
SphereGenerator sphereGen;