Lord and Savior Johan

This commit is contained in:
2016-05-26 12:53:22 +02:00
parent 908786897f
commit 56e174ae2f
8 changed files with 642 additions and 24 deletions
+5 -2
View File
@@ -21,15 +21,18 @@ Entity::~Entity()
void Entity::draw()
{
rotation.y += 1;
if (model)
{
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glRotatef(rotation.x, 1, 0, 0);
glRotatef(rotation.y, 0, 1, 0);
glRotatef(rotation.z, 0, 0, 1);
glScalef(scale, scale, scale);
glTranslatef(-model->center.x, 0, -model->center.z);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -48,8 +51,8 @@ bool Entity::inObject(const Vec3f & point)
if (!model)
return false;
Vec3f center = position + model->center;
float distance = sqrt((point.x - center.x) * (point.x - center.x) + (point.z - center.z)*(point.z - center.z));
if (distance < model->radius*scale)
float distance = ((point.x - center.x) * (point.x - center.x) + (point.z - center.z)*(point.z - center.z));
if (distance < model->radius*scale*model->radius*scale)
return true;
return false;
}