Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Polyhedron rending with OpenGL

Subject: CGAL users discussion list

List archive

[cgal-discuss] Polyhedron rending with OpenGL


Chronological Thread 
  • From: Lettuce <>
  • To:
  • Subject: [cgal-discuss] Polyhedron rending with OpenGL
  • Date: Wed, 6 Jun 2018 01:02:43 -0700 (MST)
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Fail ; spf=Pass
  • Ironport-phdr: 9a23:4bF6aRQ+E7zgNuhyUQH870pNcNpsv+yvbD5Q0YIujvd0So/mwa68bBGN2/xhgRfzUJnB7Loc0qyK6/2mATRIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfbN/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbDVwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4qF2QxHqlSgHLSY0/m/XhMJuj6xVvR2uqABwzYPPfIGYNuZycr/Bcd8GW2ZMWNtaWSxbAoO7aosCF+wPMvhEr4nhulsBsQWxDhSrCePtzz9Fhn/70KI53ug9CgzKwQ0tEtwUvHvIq9X1Mb4fXOaox6fGyjXDaulZ2Tb76IXQdBAuu+qDUql0ccXP00UgCwTFjlCWpIf4PD2VzvwAv3Wa4uZ+T+6jlW4qpg9rrjSyyMohhJPFi4ALxl3C6C532pw6JceiR05+edOkEIVftyWdN4ZuRMMvTHtkuCAgxbIdopG7eDYFxI47yB7YbvyLa4mI4hT9W+aNOTp0mXNodKylixqs8UWtxPfwWtS63VtEtCZIkMfAumgI1xPJ68iHTvV9/l2m2TaKzw3T6ORELEA0mKfUKJMt3qU9mocSvEnNBCP5hEL2jKqOekU+5ueo8/jnYqnhppKEK4B0hRvxMqA3lsOiAOQ4KRQBX3WA+eSnz7Dj5k34QLBSjvIsiKXZsZbaJd4apqGjGQNV3JwjuF6DCGKt390c2HUGN1lYYwmvjo7zOliILuqrI+24hgGInSt32vvLdunjB8iQciibuO6/JvB27EsKm1l79sxW+58BUuJJG/n0QEKk7IWJXC98CBS9xqPcMPs404ofXWyVBarIYvqM6hmD4ed9f7DQNr9Qgy70Lr0e39CrlWUwyA1EI/Lv1pwSOijhQ6ZWZn6BaH+pue8vVGcHug1nEb7s1BuEWDRZY3v0VKU5tGg2

Hello,
firstly i use CGAL::poisson_suface_reconstruction_delaunay to creat a mesh
here is the code

CGAL::poisson_surface_reconstruction_delaunay
(points.begin(), points.end(),
CGAL::First_of_pair_property_map<Pwn>(),
CGAL::Second_of_pair_property_map<Pwn>(),
P, average_spacing);

then i want to use opengl to rending it and the code is

void gl_draw_facet(Polyhedron::Facet_iterator f){
Polyhedron::Halfedge_around_facet_circulator he = f->facet_begin();
do{
const Point& p = he->vertex()->point();
glVertex3d(p.x(), p.y(), p.z());
} while (++he != f->facet_begin());
}

void drawPoint(){
Polyhedron::Vertex_iterator v;
Polyhedron::Facet_iterator f;
Polyhedron::Edge_iterator eit;
Polyhedron::Halfedge_handle h_handle;
double x, y, z;

CGAL::Polygon_mesh_processing::compute_normals(P,
boost::make_assoc_property_map(vnormals),
boost::make_assoc_property_map(fnormals));

glBegin(GL_TRIANGLES);
for (f = P.facets_begin(); f != P.facets_end(); f++){
xx = fnormals[f].x() /
sqrt((fnormals[f].x()*fnormals[f].x()) +
(fnormals[f].y()*fnormals[f].y()) + (fnormals[f].z()*fnormals[f].z()));
yy = fnormals[f].y() /
sqrt((fnormals[f].x()*fnormals[f].x()) +
(fnormals[f].y()*fnormals[f].y()) + (fnormals[f].z()*fnormals[f].z()));
zz = fnormals[f].z() /
sqrt((fnormals[f].x()*fnormals[f].x()) +
(fnormals[f].y()*fnormals[f].y()) + (fnormals[f].z()*fnormals[f].z()));
glNormal3f(xx, yy, zz);
gl_draw_facet(f);
}
glEnd();
}
but the result shows there is something wrong with the normals. here is the
result
<http://cgal-discuss.949826.n4.nabble.com/file/t375948/cat.png>

i dont know what's wrong with my code.

need help,thank you.





--
Sent from: http://cgal-discuss.949826.n4.nabble.com/



Archive powered by MHonArc 2.6.18.

Top of Page