diff --git a/editor/src/config.h b/editor/src/config.h index 737cde2..6f7c629 100644 --- a/editor/src/config.h +++ b/editor/src/config.h @@ -5,16 +5,22 @@ #define WINDOW_HEIGHT 600 #define CUBE_SIZE 30 -#define MOVE_SPEED 5 +#define MOVE_SPEED 7 +#define ZOOM_LEVEL 25 -#define PI 3.14159265 +#define PI 3.1415926535897932 // Materials extern float ledOnMaterial[]; +extern float wireMaterial[]; +extern float innerWireMaterial[]; // Movement extern float lookX, lookZ; extern float eyePos, eyeAngle; +// Objects +extern GLUquadricObj *quadric; + #endif diff --git a/editor/src/display.c b/editor/src/display.c index 773e278..d2c7e49 100644 --- a/editor/src/display.c +++ b/editor/src/display.c @@ -4,22 +4,49 @@ #include "config.h" #include "display.h" -extern void moveCameraPosition(float direction); void drawLEDCube() { - glMatrixMode(GL_MODELVIEW); - glMaterialfv(GL_FRONT, GL_DIFFUSE, ledOnMaterial); - int x, y, z; - float space = 10.0; - for (z=0; z<3; ++z) // Ebene - for (y=0; y<3; ++y) // Zeile - for (x=0; x<3; ++x) { // Spalte + + // LEDs + glMaterialfv(GL_FRONT, GL_DIFFUSE, ledOnMaterial); + for (z=-10; z<=10; z+=10) // Ebene + for (y=-10; y<=10; y+=10) // Zeile + for (x=-10; x<=10; x+=10) { // Spalte glPushMatrix(); - glTranslatef(x*space, y*space, z*space); + glTranslatef(x, y, z); glutSolidSphere(1.0, 16, 16); + gluCylinder(quadric, 1.0, 1.0, 1.3, 16, 2); + //glTranslatef(x, y, z+0.8); + //gluCylinder(quadric, 1.3, 1.3, 0.2, 16, 2); + //gluDisk( + glPopMatrix(); } + + // Wires + for (y=-10; y<=10; y+=10) + for (x=-10; x<=10; x+=10) { + glMaterialfv(GL_FRONT, GL_DIFFUSE, ((x == 0 || y == 0) ? innerWireMaterial : wireMaterial)); + + // Front + glBegin(GL_LINES); + glVertex3f(x, y, -10); + glVertex3f(x, y, 10); + glEnd(); + + // Side + glBegin(GL_LINES); + glVertex3f(-10, x, y); + glVertex3f(10, x, y); + glEnd(); + + // Top + glBegin(GL_LINES); + glVertex3f(x, -10, y); + glVertex3f(x, 10, y); + glEnd(); + } } void display() { @@ -27,12 +54,11 @@ void display() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(45.0, WINDOW_WIDTH/WINDOW_HEIGHT, 1.0, 250.0); + gluPerspective(ZOOM_LEVEL, WINDOW_WIDTH/WINDOW_HEIGHT, 1.0, 350.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - moveCameraPosition(0.0); - gluLookAt(lookX, eyeAngle, lookZ, CUBE_SIZE/2, 6.0, CUBE_SIZE/2, 0, 1, 0); + gluLookAt(lookX, eyeAngle, lookZ, 0, 0, 0, 0, 1, 0); drawLEDCube(); glutSwapBuffers(); diff --git a/editor/src/input.c b/editor/src/input.c index 5606335..8759e6c 100644 --- a/editor/src/input.c +++ b/editor/src/input.c @@ -9,8 +9,8 @@ void moveCameraPosition(float direction) { eyePos += direction; if (eyePos > 360.0) eyePos = 0.0; - lookX = cos(eyePos * PI/180.0)*(CUBE_SIZE/2+50.0) + (CUBE_SIZE/2); - lookZ = sin(eyePos * PI/180.0)*(CUBE_SIZE/2+50.0) + (CUBE_SIZE/2); + lookX = sin(eyePos * PI/180.0)*70.0; + lookZ = cos(eyePos * PI/180.0)*70.0; } void moveCameraAngle(float angle) { diff --git a/editor/src/main.c b/editor/src/main.c index 0a90791..4ca1c76 100644 --- a/editor/src/main.c +++ b/editor/src/main.c @@ -7,10 +7,20 @@ #include "display.h" #include "input.h" -float ledOnMaterial[] = {1.0, 0.0, 0.0, 1.0}; +float ledOnMaterial[] = {0.0, 0.0, 1.0, 1.0}; +float wireMaterial[] = {0.7, 0.7, 0.7, 1.0}; +float innerWireMaterial[] = {0.2, 0.2, 0.2, 0.3}; + +float light_diffuse[] = {0.0, 0.0, 1.0, 1.0}; +float light_position[] = {1.0, 1.0, 1.0, 0.0}; + float lookX = 0.0, lookZ = 0.0; -float eyePos = 0.0, eyeAngle = 50.0; +float eyePos = 0.0, eyeAngle = 45.0; + +GLUquadricObj *quadric; + +extern void moveCameraPosition(float direction); int main(int argc, char* argv[]) { glutInit(&argc, argv); @@ -30,7 +40,16 @@ int main(int argc, char* argv[]) { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glMatrixMode(GL_MODELVIEW); + moveCameraPosition(0); // Init the Position + + + quadric = gluNewQuadric(); + gluQuadricNormals(quadric, GLU_SMOOTH); + gluQuadricDrawStyle(quadric, GLU_FILL); + glutMainLoop(); return 0;