Logo Search packages:      
Sourcecode: blender version File versions

void RAS_OpenGLRasterizer::IndexPrimitives ( const vecVertexArray &  vertexarrays,
const vecIndexArrays &  indexarrays,
int  mode,
class RAS_IPolyMaterial polymat,
class RAS_IRenderTools *  rendertools,
bool  useObjectColor,
const MT_Vector4 rgbacolor 
) [virtual]

IndexPrimitives: Renders primitives.

Parameters:
vertexarrays is an array of vertex arrays
indexarrays is an array of index arrays
mode determines the type of primitive stored in the vertex/index arrays: 0 triangles 1 lines (default) 2 quads
polymat (reserved)
useObjectColor will render the object using
rgbacolor instead of vertex colours.

Implements RAS_IRasterizer.

Reimplemented in RAS_VAOpenGLRasterizer.

Definition at line 552 of file RAS_OpenGLRasterizer.cpp.

{ 
      GLenum drawmode;
      switch (mode)
      {
      case 0:
            drawmode = GL_TRIANGLES;
            break;
      case 1:
            drawmode = GL_LINES;
            break;
      case 2:
            drawmode = GL_QUADS;
            break;
      default:
            drawmode = GL_LINES;
            break;
      }
      
      const RAS_TexVert* vertexarray ;
      unsigned int numindices,vt;

      for (vt=0;vt<vertexarrays.size();vt++)
      {
            vertexarray = &((*vertexarrays[vt]) [0]);
            const KX_IndexArray & indexarray = (*indexarrays[vt]);
            numindices = indexarray.size();
            
            if (!numindices)
                  break;
            
            int vindex=0;
            switch (mode)
            {
            case 1:
                  {
                        glBegin(GL_LINES);
                        vindex=0;
                        for (unsigned int i=0;i<numindices;i+=2)
                        {
                              glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
                              glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
                        }
                        glEnd();
                  }
                  break;
            case 2:
                  {
                        glBegin(GL_QUADS);
                        vindex=0;
                        if (useObjectColor)
                        {
                              for (unsigned int i=0;i<numindices;i+=4)
                              {

                                    glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);

                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                              }
                        }
                        else
                        {
                              for (unsigned int i=0;i<numindices;i+=4)
                              {
                                    // This looks curiously endian unsafe to me.
                                    // However it depends on the way the colors are packed into 
                                    // the m_rgba field of RAS_TexVert

                                    glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                              }
                        }
                        glEnd();    
                        break;
                  }
            case 0:
                  {
                        glBegin(GL_TRIANGLES);
                        vindex=0;
                        if (useObjectColor)
                        {
                              for (unsigned int i=0;i<numindices;i+=3)
                              {

                                    glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);

                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                              }
                        }
                        else 
                        {
                              for (unsigned int i=0;i<numindices;i+=3)
                              {

                                    glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                                    
                                    glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
                                    glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
                                    glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
                                    glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
                                    vindex++;
                              }
                        }
                        glEnd();    
                        break;
                  }
            default:
                  {
                  }
                  
            } // switch
      } // for each vertexarray

}


Generated by  Doxygen 1.6.0   Back to index