示例#1
0
 void render_wire(){
     glLineWidth(1.0);
     glColor3f(.3f,.3f,.3f);
     Surface_mesh::Vertex_property<Point> points = mesh()->vertex_property<Point>("v:point");
     gl::glVertexPointer(points.data());
     glEnableClientState(GL_VERTEX_ARRAY);
     /// Render
     glDisable(GL_LIGHTING);
     glColor3f(0.0, 0.0, 0.0);
     glDepthRange(0.0, 1.0);
     glDepthFunc(GL_LEQUAL);
     if(edges.size()) glDrawElements(GL_LINES, (GLsizei)edges.size(), GL_UNSIGNED_INT, &edges[0]);
     glDepthFunc(GL_LESS);
 }
示例#2
0
    void render(){
		if(mesh()->n_faces() < 1) return;

        Surface_mesh::Vertex_property<Point>  points = mesh()->vertex_property<Point>(VPOINT);
        Surface_mesh::Vertex_property<Point>  vnormals = mesh()->vertex_property<Point>(VNORMAL);
    
        // Deal with color
        bool has_vertex_color = mesh()->has_vertex_property<Color>(VCOLOR);
        Surface_mesh::Vertex_property<Color>  vcolor;
        if (has_vertex_color) vcolor = mesh()->get_vertex_property<Color>(VCOLOR);
    
        // setup vertex arrays    
        gl::glVertexPointer(points.data());
        gl::glNormalPointer(vnormals.data());
        if(has_vertex_color) 
            gl::glColorPointer(vcolor.data());
    
        glEnable(GL_LIGHTING);
        glShadeModel(GL_SMOOTH);
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_NORMAL_ARRAY);
        if(has_vertex_color) glEnableClientState(GL_COLOR_ARRAY);
        if(triangles.size()) glDrawElements(GL_TRIANGLES, (GLsizei)triangles.size(), GL_UNSIGNED_INT, &triangles[0]);
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_NORMAL_ARRAY);
    }
示例#3
0
void Scene::updateVBOs()
{
	QSegMesh * mesh = activeObject();

	if(mesh && mesh->isReady)
	{
		// Create VBO for each segment if needed
		for (int i=0;i<(int)mesh->nbSegments();i++)
		{			
			QSurfaceMesh* seg = mesh->getSegment(i);
			QString objId = seg->objectName();

			if (VBO::isVBOSupported() && !vboCollection.contains(objId))
			{
				Surface_mesh::Vertex_property<Point>  points   = seg->vertex_property<Point>("v:point");
				Surface_mesh::Vertex_property<Point>  vnormals = seg->vertex_property<Point>("v:normal");
				Surface_mesh::Vertex_property<Color>  vcolors  = seg->vertex_property<Color>("v:color");			
				seg->fillTrianglesList();

				// Create VBO 
				vboCollection[objId] = VBO( seg->n_vertices(), points.data(), vnormals.data(), vcolors.data(), seg->triangles );		
			}
		}
	}
}
示例#4
0
 void render(){
     glDisable(GL_LIGHTING);
 
 /// @todo Much faster but does not support color...YET
 #ifdef TODO_WIREFRAME_VBUFFER
     /// Setup Vertex Array
     Surface_mesh::Vertex_property<Point> points = mesh()->vertex_property<Point>("v:point");
     gl::glVertexPointer(points.data());
     glEnableClientState(GL_VERTEX_ARRAY);
     /// Render
     glColor3f(0.0, 0.0, 0.0);
     glDepthRange(0.0, 1.0);
     glDepthFunc(GL_LEQUAL);
     if(edges.size()) glDrawElements(GL_LINES, (GLsizei)edges.size(), GL_UNSIGNED_INT, &edges[0]);
     glDepthFunc(GL_LESS);
 #else
     Surface_mesh::Vertex_property<Point> points = mesh()->vertex_property<Point>("v:point");
     Surface_mesh::Edge_property<Color> ecolor = mesh()->get_edge_property<Color>("e:color");
     bool has_edge_color = mesh()->has_edge_property<Color>("e:color");
     glBegin(GL_LINES);
     Surface_mesh::Edge_iterator eit, eend=mesh()->edges_end();
     for (eit=mesh()->edges_begin(); eit!=eend; ++eit){
         Surface_mesh::Edge e = eit;
         Surface_mesh::Vertex v0 = mesh()->vertex(eit,0);
         Surface_mesh::Vertex v1 = mesh()->vertex(eit,1);
 
         if(has_edge_color)
             gl::glColor(ecolor[eit]); ///< Apply color
         else
             gl::glColor(Color(0,0,0));
 
         gl::glVertex(points[v0]);
         gl::glVertex(points[v1]);
     }
     glEnd();
 #endif
 
     glEnable(GL_LIGHTING);
 }