Thread: [PyOpenGL-Users] pointer for vertex index
Brought to you by:
mcfletch
From: Prashant S. <ani...@ya...> - 2008-10-23 16:40:03
|
Hi, I am creating a viewer to display Renderman (.rib) using PyOpenGL. I'll be using either vertex arrays or VBO to store and render the data. A 6 face polygonal cube in .rib format: (5 faces are quad and I purposely divided 4th face into 2 triangles before exporting from 3d application) PointsGeneralPolygons [ 4 4 4 4 3 3 4 ] #number of vertices in face [ 2 3 1 0 4 5 3 2 6 7 5 4 0 1 7 6 3 7 1 5 7 3 4 2 0 6 ] #vertex index "vertex point P" [ -4.470358 -4.1476117 3.9099706 4.470358 -4.1476117 3.9099706 -4.470358 4.1476117 3.9099706 4.470358 4.1476117 3.9099706 -4.470358 4.1476117 -3.9099706 4.470358 4.1476117 -3.9099706 -4.470358 -4.1476117 -3.9099706 4.470358 -4.1476117 -3.9099706 ] "facevarying normal N" [ 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 ] "facevarying float[2] st" [ 0.375 0.75 0.625 0.75 0.625 1 0.375 1 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5 0.375 0 0.625 0 0.625 0.25 0.375 0.25 0.625 0.75 0.875 1 0.625 1 0.875 0.75 0.875 1 0.625 0.75 0.125 0.75 0.375 0.75 Here normals and "st" (texture coord) are per face basis while vertices are object basis. In OpenGL we have three different pointers to feed this data in: glVertexPointer, glTexCoordPointer and glNormalPointer. 1. In above case I would be needing vertices array also per face basis to pass them into glVertexPointer, which I could do by parsing vertex index array and vertices. Do we have something in GL to overcome this problem and creting the mesh using the information as it's already there in the rib. 2. Secondly we have quads as well as tris in this case. Is it possible to pass an array which contains both of them. For example: [[...], [a,b,c], #three verts of a triangle [a,b,c,d], #four vertices of a quad Thanks Prashant Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/ |
From: Mike C. F. <mcf...@vr...> - 2008-10-30 02:23:17
|
Prashant Saxena wrote: > Hi, > > I am creating a viewer to display Renderman (.rib) using PyOpenGL. > I'll be using either vertex arrays or VBO to store and render the data. > > A 6 face polygonal cube in .rib format: (5 faces are quad and I > purposely divided 4th face into 2 triangles before exporting from 3d > application) > PointsGeneralPolygons > [ 4 4 4 4 3 3 4 ] #number of vertices in face > [ 2 3 1 0 4 5 3 2 6 7 5 4 0 1 7 6 3 7 > 1 5 7 3 4 2 0 6 ] #vertex index > "vertex point P" [ -4.470358 -4.1476117 3.9099706 4.470358 > -4.1476117 3.9099706 -4.470358 4.1476117 3.9099706 4.470358 4.1476117 > 3.9099706 > -4.470358 4.1476117 -3.9099706 4.470358 4.1476117 -3.9099706 > -4.470358 -4.1476117 -3.9099706 4.470358 -4.1476117 -3.9099706 ] > "facevarying normal N" [ 0 0 1 0 0 1 0 0 1 0 0 1 > 0 1 0 0 1 0 0 1 0 0 1 0 > 0 0 -1 0 0 -1 0 0 -1 0 0 -1 > 0 -1 0 0 -1 0 0 -1 0 0 -1 0 > 1 0 0 1 0 0 1 0 0 1 0 0 > 1 0 0 1 0 0 -1 0 0 -1 0 0 > -1 0 0 -1 0 0 ] > "facevarying float[2] st" [ 0.375 0.75 0.625 0.75 0.625 1 0.375 1 > 0.375 0.5 0.625 0.5 > 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5 > 0.375 0 0.625 0 0.625 0..25 0.375 0.25 0.625 0.75 0.875 1 > 0.625 1 0.875 0.75 0.875 1 0.625 0.75 0.125 0.75 0.375 0.75 > > Here normals and "st" (texture coord) are per face basis while > vertices are object basis. In OpenGL we have three different pointers > to feed this data in: glVertexPointer, glTexCoordPointer and > glNormalPointer. > > 1. In above case I would be needing vertices array also per face basis > to pass them into glVertexPointer, which I could do by parsing vertex > index array and vertices. Do we have something in GL to overcome this > problem and creting the mesh using the information as it's already > there in the rib. You generally are going to need equally-indexed arrays AFAIK. That is, you need to be able to say "render vertex X from current arrays". When you have that, you can use e.g. glDrawElements or glDrawRangeElements to render the data-set. Although there might be some extension that allows you to use different indices for the various arrays, I don't believe anything in core allows you to do so. In summary: yes, you will likely need to expand your vertex array. > 2. Secondly we have quads as well as tris in this case. Is it possible > to pass an array which contains both of them. For example: > [[...], > [a,b,c], #three verts of a triangle > [a,b,c,d], #four vertices of a quad You can pass them in in the same array/vbo and then use multiple calls to glDrawElements to render the geometry. HTH, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |