Esempio n. 1
0
    def draw(self, camera, projection, mvMat):
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glEnableClientState(GL_TEXTURE_COORD_ARRAY)

        glEnable(GL_TEXTURE_2D)

        for face_group in self.face_groups.itervalues():
            material = self.materials[face_group.material_name]
            
            vb = self.mat_obj.getVBO(material.name)
            if material.alpha < 1.0:
                glEnable(GL_BLEND) ## for opacity
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

            modelview = matrix.copy(mvMat) # sonst hämmert man auf der helimatrix rum, die man nachher noch braucht
            modelview = dot(modelview, trafo.translationMatrix(self.center[0], self.center[1], self.center[2]))
            modelview = dot(modelview, dot(trafo.rotationMatrix(radians(self.angle), self.rotation_axis), self.orientation))
            modelview = dot(modelview, trafo.translationMatrix(-self.center[0], -self.center[1], -self.center[2]))
            
            normalMat = linalg.inv(modelview[0:3,0:3]).T

            mvpMat = dot(projection, modelview)
            
            glUseProgram(self.program)

            s = self.shadersender
            s.sendMat4("mvMatrix", mvMat)
            s.sendMat4("mvpMatrix", mvpMat)
            s.sendMat3("normalMatrix", normalMat)
            s.sendVec4("diffuseColor", material.diffuse)
            s.sendVec4("ambientColor", material.ambient)
            s.sendVec4("specularColor", material.specular)
            s.sendValue("shininess", material.exponent)
            s.sendValue("alpha", material.alpha)
            s.sendVec3("lightPosition", [0,70.0,70.0])
            s.sendValue("hasTexture", material.has_texture())
            
            vb.bind()

            glVertexPointer(3, GL_FLOAT, 36, vb)
            glTexCoordPointer(3, GL_FLOAT, 36, vb + 12)
            glNormalPointer(GL_FLOAT, 36, vb + 24)
                
            glBindTexture(GL_TEXTURE_2D, material.texture_id)

            glDrawArrays(GL_TRIANGLES, 0, len(vb) / 3)
            vb.unbind()

        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_TEXTURE_COORD_ARRAY)
Esempio n. 2
0
 def _rotate_global(self, rot_angle, axis, curr_angle=None):
     self.orientation = dot(trafo.rotationMatrix(rot_angle, axis),
                            self.orientation)
Esempio n. 3
0
 def _rotate(self, rot_angle, axis, curr_angle=None):
     self.orientation = dot(self.orientation,
                            trafo.rotationMatrix(rot_angle, axis))
Esempio n. 4
0
 def _rotate_global(self, rot_angle, axis, curr_angle=None):
     self.orientation = dot(trafo.rotationMatrix(rot_angle, axis), self.orientation)
Esempio n. 5
0
 def _rotate(self, rot_angle, axis, curr_angle=None):
     self.orientation = dot(self.orientation, trafo.rotationMatrix(rot_angle, axis))