Working on cube selection.

This commit is contained in:
Quentin BAZIN 2013-02-17 20:53:53 +01:00
parent d5533d2137
commit 3236c3e9ec
4 changed files with 13 additions and 8 deletions

View File

@ -25,6 +25,9 @@ class Scene {
void lockMouse();
void unlockMouse();
static bool intersectionSphereLine(vect3D center, float radius, vect3D linePoint, vect3D directionVector);
static void testCubes(std::vector<Cube*> cubes);
static Player *player;
private:

View File

@ -96,6 +96,8 @@ Biome::~Biome() {
}
void Biome::draw() {
Scene::testCubes(m_cubes);
glPushMatrix();
glTranslatef(m_x, m_y, m_z);

View File

@ -31,7 +31,7 @@ void Cube::draw() {
// Front right
if((m_y >= m_map->depth - 1) || (m_map->map[MAP_POS(m_x, m_y + 1, m_z)] == 0)) {
if(m_selected) glColor3ub(255, 255, 255);
if(!m_selected) glColor3ub(255, 255, 255);
else glColor3ub(255, 0, 0);
glTexCoord2d(1, 0); glVertex3d(m_x + 1, m_y + 1, m_z + 1);
glTexCoord2d(0, 0); glVertex3d(m_x + 1, m_y + 1, m_z);
@ -41,7 +41,7 @@ void Cube::draw() {
// Front left
if((m_x >= m_map->width - 1) || (m_map->map[MAP_POS(m_x + 1, m_y, m_z)] == 0)) {
if(m_selected) glColor3ub(255, 255, 255);
if(!m_selected) glColor3ub(255, 255, 255);
else glColor3ub(255, 0, 0);
glTexCoord2d(1, 0); glVertex3d(m_x + 1, m_y, m_z + 1);
glTexCoord2d(0, 0); glVertex3d(m_x + 1, m_y, m_z);
@ -51,7 +51,7 @@ void Cube::draw() {
// Back left
if((m_y <= 0) || (m_map->map[MAP_POS(m_x, m_y - 1, m_z)] == 0)) {
if(m_selected) glColor3ub(255, 255, 255);
if(!m_selected) glColor3ub(255, 255, 255);
else glColor3ub(255, 0, 0);
glTexCoord2d(1, 0); glVertex3d(m_x, m_y, m_z + 1);
glTexCoord2d(0, 0); glVertex3d(m_x, m_y, m_z);
@ -61,7 +61,7 @@ void Cube::draw() {
// Back right
if((m_x <= 0) || (m_map->map[MAP_POS(m_x - 1, m_y, m_z)] == 0)) {
if(m_selected) glColor3ub(255, 255, 255);
if(!m_selected) glColor3ub(255, 255, 255);
else glColor3ub(255, 0, 0);
glTexCoord2d(1, 0); glVertex3d(m_x, m_y + 1, m_z + 1);
glTexCoord2d(0, 0); glVertex3d(m_x, m_y + 1, m_z);
@ -71,7 +71,7 @@ void Cube::draw() {
// Bottom
if((m_z <= 0) || (m_map->map[MAP_POS(m_x, m_y, m_z - 1)] == 0)) {
if(m_selected) glColor3ub(255, 255, 255);
if(!m_selected) glColor3ub(255, 255, 255);
else glColor3ub(255, 0, 0);
glTexCoord2d(1, 0); glVertex3d(m_x + 1, m_y + 1, m_z);
glTexCoord2d(0, 0); glVertex3d(m_x + 1, m_y, m_z);
@ -81,7 +81,7 @@ void Cube::draw() {
// Top
if((m_z >= m_map->height - 1) || (m_map->map[MAP_POS(m_x, m_y, m_z + 1)] == 0)) {
if(m_selected) glColor3ub(255, 255, 255);
if(!m_selected) glColor3ub(255, 255, 255);
else glColor3ub(255, 0, 0);
glTexCoord2d(0, 1); glVertex3d(m_x, m_y, m_z + 1);
glTexCoord2d(0, 0); glVertex3d(m_x + 1, m_y, m_z + 1);

View File

@ -20,7 +20,7 @@
Player *Scene::player;
bool intersectionSphereLine(vect3D center, float radius, vect3D linePoint, vect3D directionVector) {
bool Scene::intersectionSphereLine(vect3D center, float radius, vect3D linePoint, vect3D directionVector) {
vect3D u;
u.x = center.x - linePoint.x;
@ -42,7 +42,7 @@ bool intersectionSphereLine(vect3D center, float radius, vect3D linePoint, vect3
}
}
void testCubes(std::vector<Cube*> cubes) {
void Scene::testCubes(std::vector<Cube*> cubes) {
float radius = sqrt(3) / 2;
vect3D linePoint;