Working on cube selection.
This commit is contained in:
parent
d5533d2137
commit
3236c3e9ec
@ -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:
|
||||
|
@ -96,6 +96,8 @@ Biome::~Biome() {
|
||||
}
|
||||
|
||||
void Biome::draw() {
|
||||
Scene::testCubes(m_cubes);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(m_x, m_y, m_z);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user