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


Add more friends to your messenger and enjoy! Invite them now.