## Re: [cgkit-user] Polyhedron

 Re: [cgkit-user] Polyhedron From: Matthias Baas - 2010-11-04 21:08:17 ```Hi Greg, On 03.11.10 04:54, Greg Friedland wrote: > Are there any examples out there for how Polyhedron and/or > PolyhedronGeom class works? I'm having trouble creating a simple > tetrahedron with: > > Polyhedron(verts = [vec3(0,0,1), > vec3(0.94,0,0.33), > vec3(-0.47,0.82,-0.33), > vec3(-0.47,-0.82,-0.33), > ]) > > Nothing displays in the viewer with this code and I'm not sure what to > do with the 'poly' constructor argment. Well, you only specified the vertices, but you don't mention how to are connected to form faces. That's what the "polys" argument is for, it defines the polygons which use indices into the vertex list (have a look at the docs for PolyhedronGeom, this one does contain at least some information). The polys argument is a sequence of polygons where each polygon is a sequence of vertex loops. A vertex loop is again a sequence of vertex indices. In your case, every polygon only has one single vertex loop (additional loops would define holes in the polygon). So for example, if you set polys = [[(0,1,2)]] you define a single triangle that is made of vertex 0, 1 and 2 (in this order). Make sure to specify all the triangles with a consistent vertex order. If shading looks odd, try reversing the order. Cheers, - Matthias - ```

 [cgkit-user] Polyhedron From: Greg Friedland - 2010-11-03 04:54:40 Attachments: Message as HTML ```Hi All, Are there any examples out there for how Polyhedron and/or PolyhedronGeom class works? I'm having trouble creating a simple tetrahedron with: Polyhedron(verts = [vec3(0,0,1), vec3(0.94,0,0.33), vec3(-0.47,0.82,-0.33), vec3(-0.47,-0.82,-0.33), ]) Nothing displays in the viewer with this code and I'm not sure what to do with the 'poly' constructor argment. Cheers, Greg ```
 Re: [cgkit-user] Polyhedron From: Matthias Baas - 2010-11-04 21:08:17 ```Hi Greg, On 03.11.10 04:54, Greg Friedland wrote: > Are there any examples out there for how Polyhedron and/or > PolyhedronGeom class works? I'm having trouble creating a simple > tetrahedron with: > > Polyhedron(verts = [vec3(0,0,1), > vec3(0.94,0,0.33), > vec3(-0.47,0.82,-0.33), > vec3(-0.47,-0.82,-0.33), > ]) > > Nothing displays in the viewer with this code and I'm not sure what to > do with the 'poly' constructor argment. Well, you only specified the vertices, but you don't mention how to are connected to form faces. That's what the "polys" argument is for, it defines the polygons which use indices into the vertex list (have a look at the docs for PolyhedronGeom, this one does contain at least some information). The polys argument is a sequence of polygons where each polygon is a sequence of vertex loops. A vertex loop is again a sequence of vertex indices. In your case, every polygon only has one single vertex loop (additional loops would define holes in the polygon). So for example, if you set polys = [[(0,1,2)]] you define a single triangle that is made of vertex 0, 1 and 2 (in this order). Make sure to specify all the triangles with a consistent vertex order. If shading looks odd, try reversing the order. Cheers, - Matthias - ```