Randomizing face colour for each face
Allows to easily identify each face.
This commit is contained in:
parent
6e89298950
commit
66d6d89aeb
1 changed files with 7 additions and 1 deletions
|
@ -3,6 +3,8 @@
|
|||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <cstring>
|
||||
#include <random>
|
||||
#include <ctime>
|
||||
|
||||
GlutRender& GlutRender::get_instance() {
|
||||
static GlutRender instance;
|
||||
|
@ -67,6 +69,10 @@ void GlutRender::display() {
|
|||
glLoadIdentity();
|
||||
glTranslatef(0., 0., -6.);
|
||||
|
||||
std::default_random_engine rand_engine(time(NULL));
|
||||
std::uniform_real_distribution<double> distribution;
|
||||
auto rand_color = std::bind(distribution, rand_engine);
|
||||
|
||||
for(Mesh* mesh: meshes) {
|
||||
const Point& mesh_center = mesh->get_center();
|
||||
|
||||
|
@ -77,7 +83,7 @@ void GlutRender::display() {
|
|||
Point p0 = face.pt(0, points) + mesh_center,
|
||||
p1 = face.pt(1, points) + mesh_center,
|
||||
p2 = face.pt(2, points) + mesh_center;
|
||||
glColor3f(1.0f, 1.0f, 0.0f);
|
||||
glColor3f(rand_color(), rand_color(), rand_color());
|
||||
glVertex3f(p0[0], p0[1], p0[2]);
|
||||
glVertex3f(p1[0], p1[1], p1[2]);
|
||||
glVertex3f(p2[0], p2[1], p2[2]);
|
||||
|
|
Loading…
Reference in a new issue