示例#1
0
 def display_gl(self, modelview, projection, pose):
     controller_X_room = pose.mDeviceToAbsoluteTracking
     controller_X_room = matrixForOpenVrMatrix(controller_X_room)
     modelview0 = controller_X_room * modelview
     # Repack before use, just in case
     modelview0 = numpy.asarray(numpy.matrix(modelview0, dtype=numpy.float32))
     glUniformMatrix4fv(4, 1, False, modelview0)
     normal_matrix = numpy.asarray(controller_X_room)
     glUniformMatrix4fv(8, 1, False, normal_matrix)
     glActiveTexture(GL_TEXTURE0)
     glBindTexture(GL_TEXTURE_2D, self.diffuse_texture)
     glBindVertexArray(self.vao)
     glDrawElements(GL_TRIANGLES, len(self.indexPositions), GL_UNSIGNED_INT, None)
     glBindVertexArray(0)
示例#2
0
 def display_gl(self, modelview, projection, pose):
     if not self.model_is_loaded:
         self._try_load_model()
         return
     if not self.texture_is_loaded:
         self._try_load_texture()
         return
     controller_X_room = pose.mDeviceToAbsoluteTracking
     controller_X_room = matrixForOpenVrMatrix(controller_X_room)
     modelview0 = controller_X_room * modelview
     # Repack before use, just in case
     modelview0 = numpy.asarray(numpy.matrix(modelview0, dtype=numpy.float32))
     GL.glUniformMatrix4fv(4, 1, False, modelview0)
     normal_matrix = numpy.asarray(controller_X_room)
     GL.glUniformMatrix4fv(8, 1, False, normal_matrix)
     GL.glActiveTexture(GL.GL_TEXTURE0)
     GL.glBindTexture(GL.GL_TEXTURE_2D, self.diffuse_texture)
     GL.glBindVertexArray(self.vao)
     GL.glDrawElements(GL.GL_TRIANGLES, len(self.indexPositions), GL.GL_UNSIGNED_INT, None)
     GL.glBindVertexArray(0)
示例#3
0
    def display_gl(self, modelview, projection, pose):

        self.pulse += 0.0125 #make the model pulse in size

        controller_X_room = pose.mDeviceToAbsoluteTracking
        controller_X_room = matrixForOpenVrMatrix(controller_X_room)
        modelview0 = controller_X_room * modelview
        # Repack before use, just in case
        modelview0 = np.asarray(np.matrix(modelview0, dtype=np.float32))
        glUniformMatrix4fv(4, 1, False, modelview0)

        glBindVertexArray(self.vao) #start bind with VAO

        # Vertices data buffer initialization (only touched once)

        verts_pulse = self.vertices * ( 1 + np.sin(self.pulse) * 0.35 )
        self.vertexPositions = vbo.VBO(verts_pulse.astype(np.float32))
        self.vertexPositions.bind()
        glEnableVertexAttribArray(0)
        glVertexAttribPointer(0, 3, GL_FLOAT, False, 0, None)

        glDrawElements(GL_POINTS, self.indexPositions.size, GL_UNSIGNED_INT, None)
        glBindVertexArray(0) #stop bind VAO