many changes :P
This commit is contained in:
82
mapview/3D/misc/Cube.h
Normal file
82
mapview/3D/misc/Cube.h
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef CUBE_H
|
||||
#define CUBE_H
|
||||
|
||||
#include <Indoor/geo/Point3.h>
|
||||
#include <QtOpenGL>
|
||||
|
||||
class Cube {
|
||||
|
||||
private:
|
||||
|
||||
Point3 pos;
|
||||
float size;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
Cube(Point3 pos, float size) : pos(pos), size(size) {
|
||||
|
||||
}
|
||||
|
||||
void paintGL() {
|
||||
|
||||
float s = size;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(pos.x, pos.z, pos.y);
|
||||
|
||||
glColor3f(0,0,1);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
// bottom
|
||||
glNormal3f(0,-1,0);
|
||||
glVertex3f(+s, -s, -s);
|
||||
glVertex3f(+s, -s, +s);
|
||||
glVertex3f(-s, -s, +s);
|
||||
glVertex3f(-s, -s, -s);
|
||||
|
||||
// top
|
||||
glNormal3f(0,+1,0);
|
||||
glVertex3f(-s, +s, -s);
|
||||
glVertex3f(-s, +s, +s);
|
||||
glVertex3f(+s, +s, +s);
|
||||
glVertex3f(+s, +s, -s);
|
||||
|
||||
// left
|
||||
glNormal3f(-1,0,0);
|
||||
glVertex3f(-s, -s, -s);
|
||||
glVertex3f(-s, -s, +s);
|
||||
glVertex3f(-s, +s, +s);
|
||||
glVertex3f(-s, +s, -s);
|
||||
|
||||
// right
|
||||
glNormal3f(+1,0,0);
|
||||
glVertex3f(+s, +s, -s);
|
||||
glVertex3f(+s, +s, +s);
|
||||
glVertex3f(+s, -s, +s);
|
||||
glVertex3f(+s, -s, -s);
|
||||
|
||||
// front
|
||||
glNormal3f(0,0,+1);
|
||||
glVertex3f(+s, +s, +s);
|
||||
glVertex3f(-s, +s, +s);
|
||||
glVertex3f(-s, -s, +s);
|
||||
glVertex3f(+s, -s, +s);
|
||||
|
||||
// rear
|
||||
glNormal3f(0,0,-1);
|
||||
glVertex3f(+s, -s, -s);
|
||||
glVertex3f(-s, -s, -s);
|
||||
glVertex3f(-s, +s, -s);
|
||||
glVertex3f(+s, +s, -s);
|
||||
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // CUBE_H
|
||||
Reference in New Issue
Block a user