changed 3D rendering
added pan/zoom gesture
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include "../../../fixC11.h"
|
||||
|
||||
#include "Outline.h"
|
||||
|
||||
#include <QMatrix4x4>
|
||||
@@ -19,17 +21,15 @@ void Outline::render(const RenderSettings& rs) {
|
||||
|
||||
// show both sides
|
||||
//glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_CULL_FACE);
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
rs.shader->setColor(color.x, color.y, color.z);
|
||||
rs.shader->setVertices(vertices.data());
|
||||
rs.shader->setNormals(normals.data());
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertices.size() / 3);
|
||||
rs.shader->setVertices(triangles.getVertices().data());
|
||||
rs.shader->setNormals(triangles.getNormals().data());
|
||||
glDrawArrays(GL_TRIANGLES, 0, triangles.getVertices().size() / 3);
|
||||
rs.shader->unsetVertices();
|
||||
rs.shader->unsetNormals();
|
||||
|
||||
|
||||
|
||||
rs.shader->release();
|
||||
|
||||
}
|
||||
@@ -39,8 +39,7 @@ void Outline::setColor(float r, float g, float b) {
|
||||
}
|
||||
|
||||
void Outline::clear() {
|
||||
normals.clear();
|
||||
vertices.clear();
|
||||
triangles.clear();
|
||||
}
|
||||
|
||||
void Outline::add(std::vector<std::vector<Point3>>& triangles) {
|
||||
@@ -54,18 +53,22 @@ void Outline::add(std::vector<std::vector<Point3>>& triangles) {
|
||||
|
||||
const Point3 n = cross(p2-p1, p3-p1);
|
||||
if (n.z < 0) {
|
||||
vertices.push_back(p1.x); vertices.push_back(p1.y); vertices.push_back(p1.z);
|
||||
vertices.push_back(p3.x); vertices.push_back(p3.y); vertices.push_back(p3.z);
|
||||
vertices.push_back(p2.x); vertices.push_back(p2.y); vertices.push_back(p2.z);
|
||||
} else {
|
||||
vertices.push_back(p1.x); vertices.push_back(p1.y); vertices.push_back(p1.z);
|
||||
vertices.push_back(p2.x); vertices.push_back(p2.y); vertices.push_back(p2.z);
|
||||
vertices.push_back(p3.x); vertices.push_back(p3.y); vertices.push_back(p3.z);
|
||||
}
|
||||
|
||||
normals.push_back(0); normals.push_back(0); normals.push_back(1);
|
||||
normals.push_back(0); normals.push_back(0); normals.push_back(1);
|
||||
normals.push_back(0); normals.push_back(0); normals.push_back(1);
|
||||
// upper side (floor)
|
||||
this->triangles.addTriangle(p1, p3, p2, Point3(0,0,+1));
|
||||
|
||||
// facing downwards (ceiling)
|
||||
this->triangles.addTriangle(p1, p2, p3, Point3(0,0,-1));
|
||||
|
||||
} else {
|
||||
|
||||
// upper side (floor)
|
||||
this->triangles.addTriangle(p1, p2, p3, Point3(0,0,+1));
|
||||
|
||||
// facing downwards (ceiling)
|
||||
this->triangles.addTriangle(p1, p3, p2, Point3(0,0,-1));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user