This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/3D/misc/Cube.h
root e5e19779d5 worked on android port
opengl1 -> es
2018-01-31 17:15:11 +01:00

108 lines
1.7 KiB
C++

#ifndef CUBE_H
#define CUBE_H
#include <Indoor/geo/Point3.h>
#include "Renderable3D.h"
class Shader;
class Cube : public Renderable3D {
private:
Point3 pos;
Point3 size;
Point3 rot;
Point3 color;
public:
Cube(Point3 pos, float size);
Cube(Point3 pos, Point3 size, Point3 rot);
void setColor(float r, float g, float b);
void render(const RenderSettings& rs) override;
/*
void paintGL(Shader* shader);
TODO_GL
glColor3f(color.x, color.y, color.z);
glPushMatrix();
// 3) move to destination
glTranslatef(pos.x, pos.z, pos.y); // swap yz
// 2) rotate
glRotatef(rot.x, 1, 0, 0);
glRotatef(rot.y, 0, 0, 1); // swap yz
glRotatef(rot.z, 0, 1, 0);
// 1) scale
glScalef(size.x, size.z, size.y); // swap yz
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