worked on 3D display

some ui changes
refactoring
new icons
This commit is contained in:
2018-02-03 23:30:55 +01:00
parent e5e19779d5
commit 3b62f23c0e
21 changed files with 1054 additions and 765 deletions

View File

@@ -2,217 +2,52 @@
#include "Shader.h"
#include <QtOpenGL>
//static float cube_vertices[] = {
//1 -1.0000, -1.0000, -1.0000,
//2 -1.0000, 1.0000, -1.0000,
//3 1.0000, 1.0000, -1.0000,
//4 1.0000, -1.0000, -1.0000,
//5 -1.0000, -1.0000, 1.0000,
//6 1.0000, -1.0000, 1.0000,
//7 1.0000, 1.0000, 1.0000,
//8 -1.0000, 1.0000, 1.0000,
//};
//static int cube_vertex_indices[] = {
// 1, 2, 3,
// 3, 4, 1,
// 5, 6, 7,
// 7, 8, 5,
// 1, 4, 6,
// 6, 5, 1,
// 4, 3, 7,
// 7, 6, 4,
// 3, 2, 8,
// 8, 7, 3,
// 2, 1, 5,
// 5, 8, 2,
//};
static float cube_vertices[] = {
-1, -1, -1, -1, +1, -1, +1, +1, -1,
+1, +1, -1, +1, -1, -1, -1, -1, -1,
-1, -1, 0,
+1, -1, 0,
0, +1, 0,
-1, -1, +1, +1, -1, +1, +1, +1, +1,
+1, +1, +1, -1, +1, +1, -1, -1, +1,
// -1.0000, -1.0000, -1.0000, -1.0000, 1.0000, -1.0000, 1.0000, 1.0000, -1.0000,
// 1.0000, 1.0000, -1.0000, 1.0000, -1.0000, -1.0000, -1.0000, -1.0000, -1.0000,
-1, -1, -1, +1, -1, -1, +1, -1, +1,
+1, -1, +1, -1, -1, +1, -1, -1, -1,
// -1.0000, -1.0000, 1.0000, 1.0000, -1.0000, 1.0000, 1.0000, 1.0000, 1.0000,
// 1.0000, 1.0000, 1.0000, -1.0000, 1.0000, 1.0000, -1.0000, -1.0000, 1.0000,
+1, -1, -1, +1, +1, -1, +1, +1, +1,
+1, +1, +1, +1, -1, +1, +1, -1, -1,
// -1.0000, -1.0000, -1.0000, 1.0000, -1.0000, -1.0000, 1.0000, -1.0000, 1.0000,
// 1.0000, -1.0000, 1.0000, -1.0000, -1.0000, 1.0000, -1.0000, -1.0000, -1.0000,
+1, +1, -1, -1, +1, -1, -1, +1, +1,
-1, +1, +1, +1, +1, +1, +1, +1, -1,
// 1.0000, -1.0000, -1.0000, 1.0000, 1.0000, -1.0000, 1.0000, 1.0000, 1.0000,
// 1.0000, 1.0000, 1.0000, 1.0000, -1.0000, 1.0000, 1.0000, -1.0000, -1.0000,
// 1.0000, 1.0000, -1.0000, -1.0000, 1.0000, -1.0000, -1.0000, 1.0000, 1.0000,
// -1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, -1.0000,
// -1.0000, 1.0000, -1.0000, -1.0000, -1.0000, -1.0000, -1.0000, -1.0000, 1.0000,
// -1.0000, -1.0000, 1.0000, -1.0000, 1.0000, 1.0000, -1.0000, 1.0000, -1.0000,
-1, +1, -1, -1, -1, -1, -1, -1, +1,
-1, -1, +1, -1, +1, +1, -1, +1, -1,
};
//static float cube_normals[] = {
// 0.0000, 0.0000, -1.0000,
// 0.0000, 0.0000, 1.0000,
// 0.0000, -1.0000, 0.0000,
// 1.0000, 0.0000, 0.0000,
// 0.0000, 1.0000, 0.0000,
// -1.0000, 0.0000, 0.0000,
//};
static float cube_normals[] = {
0.0000, 0.0000, -1.0000, 0.0000, 0.0000, -1.0000, 0.0000, 0.0000, -1.0000,
0.0000, 0.0000, -1.0000, 0.0000, 0.0000, -1.0000, 0.0000, 0.0000, -1.0000,
0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 1.0000,
0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 1.0000,
0, 0, -1, 0, 0, -1, 0, 0, -1,
0, 0, -1, 0, 0, -1, 0, 0, -1,
0.0000, -1.0000, 0.0000, 0.0000, -1.0000, 0.0000, 0.0000, -1.0000, 0.0000,
0.0000, -1.0000, 0.0000, 0.0000, -1.0000, 0.0000, 0.0000, -1.0000, 0.0000,
0, 0, +1, 0, 0, +1, 0, 0, +1,
0, 0, +1, 0, 0, +1, 0, 0, +1,
1.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000,
1.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000,
0, -1, 0, 0, -1, 0, 0, -1, 0,
0, -1, 0, 0, -1, 0, 0, -1, 0,
0.0000, 1.0000, 0.0000,0.0000, 1.0000, 0.0000,0.0000, 1.0000, 0.0000,
0.0000, 1.0000, 0.0000,0.0000, 1.0000, 0.0000,0.0000, 1.0000, 0.0000,
1, 0, 0, 1, 0, 0, 1, 0, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0,
0, +1, 0, 0, +1, 0, 0, +1, 0,
0, +1, 0, 0, +1, 0, 0, +1, 0,
-1, 0, 0, -1, 0, 0, -1, 0, 0,
-1, 0, 0, -1, 0, 0, -1, 0, 0,
-1.0000, 0.0000, 0.0000,-1.0000, 0.0000, 0.0000,-1.0000, 0.0000, 0.0000,
-1.0000, 0.0000, 0.0000,-1.0000, 0.0000, 0.0000,-1.0000, 0.0000, 0.0000,
};
//static int cube_normal_indices[] = {
// 1, 1, 1,
// 1, 1, 1,
// 2, 2, 2,
// 2, 2, 2,
// 3, 3, 3,
// 3, 3, 3,
// 4, 4, 4,
// 4, 4, 4,
// 5, 5, 5,
// 5, 5, 5,
// 6, 6, 6,
// 6, 6, 6,
//};
//static float cube_vertices[] = {
// // bottom
// +1, -1, -1,
// +1, -1, +1,
// -1, -1, +1,
// -1, -1, +1,
// -1, -1, -1,
// +1, -1, -1,
// // top
// -1, +1, -1,
// -1, +1, +1,
// +1, +1, +1,
// +1, +1, +1,
// +1, +1, -1,
// -1, +1, -1,
// // left
// -1, -1, -1,
// -1, -1, +1,
// -1, +1, +1,
// -1, +1, +1,
// -1, +1, -1,
// -1, -1, -1,
// // right
// +1, +1, -1,
// +1, +1, +1,
// +1, -1, +1,
// +1, -1, +1,
// +1, -1, -1,
// +1, +1, -1,
// // front
// +1, +1, +1,
// -1, +1, +1,
// -1, -1, +1,
// -1, -1, +1,
// +1, -1, +1,
// +1, +1, +1,
// // rear
// +1, -1, -1,
// -1, -1, -1,
// -1, +1, -1,
// -1, +1, -1,
// +1, +1, -1,
// +1, -1, -1,
//};
//static float cube_normals[] = {
// // bottom
// 0,-1,0,
// 0,-1,0,
// 0,-1,0,
// 0,-1,0,
// 0,-1,0,
// 0,-1,0,
// // top
// 0,+1,0,
// 0,+1,0,
// 0,+1,0,
// 0,+1,0,
// 0,+1,0,
// 0,+1,0,
// // left
// -1,0,0,
// -1,0,0,
// -1,0,0,
// -1,0,0,
// -1,0,0,
// -1,0,0,
// // right
// +1,0,0,
// +1,0,0,
// +1,0,0,
// +1,0,0,
// +1,0,0,
// +1,0,0,
// // front
// 0,0,+1,
// 0,0,+1,
// 0,0,+1,
// 0,0,+1,
// 0,0,+1,
// 0,0,+1,
// // rear
// 0,0,-1,
// 0,0,-1,
// 0,0,-1,
// 0,0,-1,
// 0,0,-1,
// 0,0,-1,
//};
static Shader* shader = nullptr;
//static Shader* shader = nullptr;
Cube::Cube(Point3 pos, float size) : pos(pos), size(size,size,size), rot(0,0,0) {
@@ -228,29 +63,23 @@ void Cube::setColor(float r, float g, float b) {
void Cube::render(const RenderSettings& rs) {
rs.shader->bind();
QMatrix4x4 mat;
mat.translate(pos.x, pos.y, pos.z);
mat.rotate(rot.x, 1, 0, 0);
mat.rotate(rot.y, 0, 1, 0);
mat.rotate(rot.z, 0, 0, 1);
mat.rotate(rot.x, +1, 0, 0);
mat.rotate(rot.y, 0, +1, 0);
mat.rotate(rot.z, 0, 0, +1);
mat.scale(size.x, size.y, size.z);
// mat.scale(0.1, 0.1, 0.1);
rs.shader->setModelMatrix(mat);
// shader->setViewMatrix(V);
// shader->setProjectionMatrix(P);
rs.shader->setColor(color.x, color.y, color.z);
rs.shader->setVertices(cube_vertices);
rs.shader->setNormals(cube_normals);
glDrawArrays(GL_TRIANGLES, 0, 1*3);
//glDrawElements(GL_TRIANGLES, 12, GL_INT, cube_vertex_indices);
glDrawArrays(GL_TRIANGLES, 0, 12*3);
//glDrawElements(GL_TRIANGLES, +12, GL_INT, cube_vertex_indices);
rs.shader->unsetVertices();
rs.shader->unsetNormals();