parameters: (self, node, shader, mode=BASE, with_normals=True)
docstring: Main recursive rendering method.
docstring_summary: Main recursive rendering method.
docstring_tokens: Main recursive rendering method .
function: def recursive_render(self, node, shader, mode=BASE, with_normals=True):
          """ Main recursive rendering method.
          """
  
          normals = with_normals
  
          if mode == COLORS:
              normals = False
  
  
          if not hasattr(node, "selected"):
              node.selected = False
  
          m = get_world_transform(self.scene, node)
  
          # HELPERS mode
          ###
          if mode == HELPERS:
              # if node.type == ENTITY:
              self.render_axis(m,
                               label=node.name if node != self.scene.rootnode else None,
                               selected=node.selected if hasattr(node, "selected") else False)
  
              if node.type == CAMERA:
                  self.render_camera(node, m)
  
              for child in node.children:
                      self.recursive_render(child, shader, mode)
  
              return
  
          # Mesh rendering modes
          ###
          if node.type == MESH:
  
              for mesh in node.meshes:
  
                  stride = 24  # 6 * 4 bytes
  
                  if node.selected and mode == SILHOUETTE:
                      glUniform4f(shader.u_materialDiffuse, 1.0, 0.0, 0.0, 1.0)
                      glUniformMatrix4fv(shader.u_modelViewMatrix, 1, GL_TRUE,
                                         numpy.dot(self.view_matrix, m))
  
                  else:
                      if mode == COLORS:
                          colorid = self.node2colorid[node.name]
                          r, g, b = self.get_rgb_from_colorid(colorid)
                          glUniform4f(shader.u_materialDiffuse, r / 255.0, g / 255.0, b / 255.0, 1.0)
                      elif mode == SILHOUETTE:
                          glUniform4f(shader.u_materialDiffuse, .0, .0, .0, 1.0)
                      else:
                          if node.selected:
                              diffuse = (1.0, 0.0, 0.0, 1.0)  # selected nodes in red
                          else:
                              diffuse = mesh.material.properties["diffuse"]
                          if len(diffuse) == 3:  # RGB instead of expected RGBA
                              diffuse.append(1.0)
                          glUniform4f(shader.u_materialDiffuse, *diffuse)
                          # if ambient:
                          #    glUniform4f( shader.Material_ambient, *mat["ambient"] )
  
                  if mode == BASE:  # not in COLORS or SILHOUETTE
                      normal_matrix = linalg.inv(numpy.dot(self.view_matrix, m)[0:3, 0:3]).transpose()
                      glUniformMatrix3fv(shader.u_normalMatrix, 1, GL_TRUE, normal_matrix)
  
                  glUniformMatrix4fv(shader.u_modelMatrix, 1, GL_TRUE, m)
  
                  vbo = mesh.gl["vbo"]
                  vbo.bind()
  
                  glEnableVertexAttribArray(shader.a_vertex)
                  if normals:
                      glEnableVertexAttribArray(shader.a_normal)
  
                  glVertexAttribPointer(
                      shader.a_vertex,
                      3, GL_FLOAT, False, stride, vbo
                  )
  
                  if normals:
                      glVertexAttribPointer(
                          shader.a_normal,
                          3, GL_FLOAT, False, stride, vbo + 12
                      )
  
                  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.gl["faces"])
                  glDrawElements(GL_TRIANGLES, mesh.gl["nbfaces"] * 3, GL_UNSIGNED_INT, None)
  
                  vbo.unbind()
                  glDisableVertexAttribArray(shader.a_vertex)
  
                  if normals:
                      glDisableVertexAttribArray(shader.a_normal)
  
                  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)
  
          for child in node.children:
              self.recursive_render(child, shader, mode)
function_tokens: def recursive_render ( self , node , shader , mode = BASE , with_normals = True ) : normals = with_normals if mode == COLORS : normals = False if not hasattr ( node , "selected" ) : node . selected = False m = get_world_transform ( self . scene , node ) # HELPERS mode ### if mode == HELPERS : # if node.type == ENTITY: self . render_axis ( m , label = node . name if node != self . scene . rootnode else None , selected = node . selected if hasattr ( node , "selected" ) else False ) if node . type == CAMERA : self . render_camera ( node , m ) for child in node . children : self . recursive_render ( child , shader , mode ) return # Mesh rendering modes ### if node . type == MESH : for mesh in node . meshes : stride = 24 # 6 * 4 bytes if node . selected and mode == SILHOUETTE : glUniform4f ( shader . u_materialDiffuse , 1.0 , 0.0 , 0.0 , 1.0 ) glUniformMatrix4fv ( shader . u_modelViewMatrix , 1 , GL_TRUE , numpy . dot ( self . view_matrix , m ) ) else : if mode == COLORS : colorid = self . node2colorid [ node . name ] r , g , b = self . get_rgb_from_colorid ( colorid ) glUniform4f ( shader . u_materialDiffuse , r / 255.0 , g / 255.0 , b / 255.0 , 1.0 ) elif mode == SILHOUETTE : glUniform4f ( shader . u_materialDiffuse , .0 , .0 , .0 , 1.0 ) else : if node . selected : diffuse = ( 1.0 , 0.0 , 0.0 , 1.0 ) # selected nodes in red else : diffuse = mesh . material . properties [ "diffuse" ] if len ( diffuse ) == 3 : # RGB instead of expected RGBA diffuse . append ( 1.0 ) glUniform4f ( shader . u_materialDiffuse , * diffuse ) # if ambient: #    glUniform4f( shader.Material_ambient, *mat["ambient"] ) if mode == BASE : # not in COLORS or SILHOUETTE normal_matrix = linalg . inv ( numpy . dot ( self . view_matrix , m ) [ 0 : 3 , 0 : 3 ] ) . transpose ( ) glUniformMatrix3fv ( shader . u_normalMatrix , 1 , GL_TRUE , normal_matrix ) glUniformMatrix4fv ( shader . u_modelMatrix , 1 , GL_TRUE , m ) vbo = mesh . gl [ "vbo" ] vbo . bind ( ) glEnableVertexAttribArray ( shader . a_vertex ) if normals : glEnableVertexAttribArray ( shader . a_normal ) glVertexAttribPointer ( shader . a_vertex , 3 , GL_FLOAT , False , stride , vbo ) if normals : glVertexAttribPointer ( shader . a_normal , 3 , GL_FLOAT , False , stride , vbo + 12 ) glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , mesh . gl [ "faces" ] ) glDrawElements ( GL_TRIANGLES , mesh . gl [ "nbfaces" ] * 3 , GL_UNSIGNED_INT , None ) vbo . unbind ( ) glDisableVertexAttribArray ( shader . a_vertex ) if normals : glDisableVertexAttribArray ( shader . a_normal ) glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER , 0 ) for child in node . children : self . recursive_render ( child , shader , mode )