コード例 #1
0
    def __init__(self,
                 size,
                 pos=(0, 0, 0),
                 rotation=(0, 0, 0),
                 colorize=(1, 1, 1, 1),
                 texture=None,
                 hide_faces=[]):
        """Create the Quad
           size is the quad
           pos is the position of the quad
           rotation is the rotation of the quad
           colorize is the color of the quad
           texture can be None, a string filename of an image to load or a data.Texture object - entire texture is mapped to the face
           hide_faces are the same as for Cube, except only front and back are allowed"""

        BaseSceneObject.__init__(self)
        self.size = size
        self.pos = pos
        self.rotation = rotation
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        self.colorize = colorize

        self.scale = 1

        self.display_list = data.DisplayList()

        self.hide_faces = hide_faces

        self._compile()
コード例 #2
0
ファイル: image.py プロジェクト: PyMine/PyMine
    def __init__(self,
                 frames=[],
                 pos=(0, 0),
                 rotation=(0, 0, 0),
                 scale=1,
                 colorize=None):
        """Create the Animation
           frames must be a list/tuple of [Image, duration] objects
           pos is the 2d position of the image
           rotation is the 3d rotation of the image
           scale is the scale factor for the image
           colorize is the color of the image"""
        BaseSceneObject.__init__(self)

        self.frames = frames

        self.pos = pos
        self.rotation = rotation
        self.scale = scale
        self.colorize = colorize

        self.cur = 0
        self.ptime = time.time()
        self.running = True
        self.breakpoint = len(self.frames) - 1
        self.startpoint = 0
        self.reversed = False
        self.looping = True

        self.filename = None
コード例 #3
0
ファイル: geometry.py プロジェクト: AjaxVM/team-pp-pyweek9
    def __init__(self, size, pos=(0,0,0), rotation=(0,0,0),
                 colorize=(1,1,1,1), texture=None, detail=30):
        """Create the Sphere
           size is the radius of the Sphere
           pos ithe position of the sphere
           rotation is the rotation of the sphere
           colorize is the color of the sphere
           texture can be None, a string filename of an image to load or a data.Texture object that will be mapped to the sphere
           detail is the level of detail for the Sphere, higher = a more smooth sphere"""
        BaseSceneObject.__init__(self)

        self.size = size
        self.pos = pos
        self.rotation = rotation
        self.colorize = colorize
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        else:
            self.texture = BlankTexture()
        self.detail = detail
        self.scale = 1

        self.display_list = data.DisplayList()

        self._compile()
コード例 #4
0
    def __init__(self,
                 size,
                 pos=(0, 0, 0),
                 rotation=(0, 0, 0),
                 colorize=(1, 1, 1, 1),
                 texture=None,
                 detail=30,
                 show_inside=False):
        """Create the Sphere
           size is the radius of the Sphere
           pos ithe position of the sphere
           rotation is the rotation of the sphere
           colorize is the color of the sphere
           texture can be None, a string filename of an image to load or a data.Texture object that will be mapped to the sphere
           detail is the level of detail for the Sphere, higher = a more smooth sphere
           show_inside indicates whether the inside of the sphere is rendered or not"""
        BaseSceneObject.__init__(self)

        self.size = size
        self.pos = pos
        self.rotation = rotation
        self.colorize = colorize
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        self.detail = detail
        self.scale = 1
        self.show_inside = show_inside

        self.display_list = data.DisplayList()

        self._compile()
コード例 #5
0
ファイル: misc.py プロジェクト: PyMine/PyMine
    def __init__(self,
                 verts=[],
                 texture=None,
                 texcs=[],
                 colorize=(1, 1, 1, 1),
                 scale=1,
                 pos=(0, 0, 0),
                 rotation=(0, 0, 0),
                 fix_order=True,
                 usage=GL_POLYGON):
        BaseSceneObject.__init__(self)

        self.verts = verts
        if texture:
            self.texture = texture
        if texcs:
            self.texcs = texcs
        else:
            self.texcs = [(0, 0)] * len(self.verts)
        self.colorize = colorize
        self.scale = scale

        self.pos = pos
        self.rotation = rotation

        self.usage = usage

        self.display_list = data.DisplayList()
        self._compile(fix_order)
コード例 #6
0
ファイル: geometry.py プロジェクト: AjaxVM/pyggel
    def __init__(self, size, pos=(0,0,0), rotation=(0,0,0),
                 colorize=(1,1,1,1), texture=None, hide_faces=[]):
        """Create the Quad
           size is the quad
           pos is the position of the quad
           rotation is the rotation of the quad
           colorize is the color of the quad
           texture can be None, a string filename of an image to load or a data.Texture object - entire texture is mapped to the face
           hide_faces are the same as for Cube, except only front and back are allowed"""

        BaseSceneObject.__init__(self)
        self.size = size
        self.pos = pos
        self.rotation = rotation
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        else:
            self.texture = BlankTexture()
        self.colorize = colorize

        self.scale = 1

        self.display_list = data.DisplayList()

        self.hide_faces = hide_faces

        self._compile()
コード例 #7
0
ファイル: geometry.py プロジェクト: AjaxVM/pyggel
    def __init__(self, size, pos=(0,0,0), rotation=(0,0,0),
                 colorize=(1,1,1,1), texture=None, show_inside=False,
                 detail=10):
        """Create the Sphere
           size is the radius of the Sphere
           pos ithe position of the sphere
           rotation is the rotation of the sphere
           colorize is the color of the sphere
           texture can be None, a string filename of an image to load or a data.Texture object that will be mapped to the sphere
           show_inside indicates whether the inside of the sphere is rendered or not
           detail is the size of each section - lower = smoother/slower"""
        BaseSceneObject.__init__(self)

        self.size = size
        self.pos = pos
        self.rotation = rotation
        self.colorize = colorize
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        else:
            self.texture = BlankTexture()
        self.scale = 1
        self.detail = detail

        self.show_inside = show_inside

        self.display_list = data.DisplayList()

        self._compile()
コード例 #8
0
ファイル: font.py プロジェクト: AjaxVM/pyggel
    def __init__(self, font, text="", color=(1,1,1,1), linewrap=None,
                 underline=False, italic=False, bold=False):
        """Create the font image
           font must be the font object used to create this image
           text must be a string of text to render (support \n newlines)
           color must be the rgba(0-1) color of the image text
           linewrap must be None or the number of pixels wide a line *should* be
               if an individual word is too large then it will go over
           underline must be True/False - whether the text is underlined or not
           italic must be True/False - whether the text is italic or not
           bold must be True/False - whether the text is bold or not"""
        BaseSceneObject.__init__(self)

        self._font = font
        self.rotation = (0,0,0)
        self.scale = 1

        self._underline = underline
        self._italic = italic
        self._bold = bold

        self._linewrap = linewrap

        self.pos = (0,0)
        self._color = (1,1,1,1)
        self.glyphs = []
        self._width = 0
        self._height = 0

        self.color = color
        self.pos = (0,0)
        self.text = text
コード例 #9
0
ファイル: image.py プロジェクト: AjaxVM/team-pp-pyweek9
    def __init__(self, frames=[], pos=(0,0),
                 rotation=(0,0,0), scale=1,
                 colorize=None):
        """Create the Animation
           frames must be a list/tuple of [Image, duration] objects
           pos is the 2d position of the image
           rotation is the 3d rotation of the image
           scale is the scale factor for the image
           colorize is the color of the image"""
        BaseSceneObject.__init__(self)

        self.frames = frames

        self.pos = pos
        self.rotation = rotation
        self.scale = scale
        self.colorize = colorize

        self.cur = 0
        self.ptime = time.time()
        self.running = True
        self.breakpoint = len(self.frames)-1
        self.startpoint = 0
        self.reversed = False
        self.looping = True

        self.filename = None
コード例 #10
0
ファイル: misc.py プロジェクト: AjaxVM/pyggel
    def __init__(self, objects=[]):
        """Create the group.
           objects must be a list of renderable objects"""
        BaseSceneObject.__init__(self)

        if not hasattr(objects, "__iter__"):
            objects = [objects]
        self.objects = objects
        self.gl_list = data.DisplayList()
        self.pickable = False

        self.compile()
コード例 #11
0
ファイル: misc.py プロジェクト: PyMine/PyMine
    def __init__(self, objects=[]):
        """Create the group.
           objects must be a list of renderable objects"""
        BaseSceneObject.__init__(self)

        if not hasattr(objects, "__iter__"):
            objects = [objects]
        self.objects = objects
        self.gl_list = data.DisplayList()
        self.pickable = False

        self.compile()
コード例 #12
0
ファイル: particle.py プロジェクト: AjaxVM/pyggel
    def __init__(self, behavior, pos=(0,0,0)):
        """Create the emitter.
           behavior must be the behavior class (not instance) that will control how the emitter and particles will behave
           pos must be a three-part tuple of the position of the emitter"""
        BaseSceneObject.__init__(self)

        self.pos = pos
        self.behavior = behavior(self)
        self.particles = []
        self.particle_type = Particle3D

        self.pickable = False
コード例 #13
0
ファイル: mesh.py プロジェクト: AjaxVM/pyggel
    def __init__(self, objs, pos=(0,0,0), rotation=(0,0,0),
                 scale=1, colorize=(1,1,1,1)):
        """Create the mesh object
           objs must be a lit of the CompiledGroup objects of the mesh
           pos/rotation/scale/colorize attributes of the mesh"""
        BaseSceneObject.__init__(self)

        self.objs = objs
        self.pos = pos
        self.rotation = rotation
        self.scale = scale
        self.colorize = colorize
コード例 #14
0
ファイル: mesh.py プロジェクト: PyMine/PyMine
    def __init__(self, name, material, dlist, dimensions, pos):
        """Create the Group
           name is the name of the object
           material is the data.Material object the group uses
           dlist is the display list of the object
           dimensions/pos are the size/center of the vertices in the object."""
        BaseSceneObject.__init__(self)
        self.name = name
        self.material = material
        self.display_list = dlist
        self.dimensions = dimensions

        self.base_pos = pos
        self.pos = pos
コード例 #15
0
ファイル: mesh.py プロジェクト: AjaxVM/pyggel
    def __init__(self, name, material, dlist, dimensions, pos):
        """Create the Group
           name is the name of the object
           material is the data.Material object the group uses
           dlist is the display list of the object
           dimensions/pos are the size/center of the vertices in the object."""
        BaseSceneObject.__init__(self)
        self.name = name
        self.material = material
        self.display_list = dlist
        self.dimensions = dimensions

        self.base_pos = pos
        self.pos = pos
コード例 #16
0
ファイル: mesh.py プロジェクト: PyMine/PyMine
    def __init__(self,
                 objs,
                 pos=(0, 0, 0),
                 rotation=(0, 0, 0),
                 scale=1,
                 colorize=(1, 1, 1, 1)):
        """Create the mesh object
           objs must be a lit of the CompiledGroup objects of the mesh
           pos/rotation/scale/colorize attributes of the mesh"""
        BaseSceneObject.__init__(self)

        self.objs = objs
        self.pos = pos
        self.rotation = rotation
        self.scale = scale
        self.colorize = colorize
コード例 #17
0
ファイル: particle.py プロジェクト: AjaxVM/pyggel
    def __init__(self, behavior, pos=(0,0,0)):
        """Create the emitter.
           behavior must be the behavior class (not instance) that will control how the emitter and particles will behave
           pos must be a three-part tuple of the position of the emitter"""
        BaseSceneObject.__init__(self)

        self.pos = pos
        self.behavior = behavior(self)
        self.particles = numpy.empty(self.behavior.max_particles, dtype=object)
        self.empty_spaces = []
        self.last_number = 0

        self.array = data.get_best_array_type(GL_POINTS, self.behavior.max_particles, 5)

        self.pickable = False
        self.particle_type = ParticlePoint
コード例 #18
0
ファイル: mesh.py プロジェクト: PyMine/PyMine
    def __init__(self, mesh, skeleton, commands):
        """Create the Animation object
           mesh must be a BasicMesh object, used to get the mesh parts
           skeleton must be a Skeleton object representing the mesh data
           commands must be a dict of {"name":Action} pairs"""
        BaseSceneObject.__init__(self)

        self.mesh = mesh
        self.skeleton = skeleton
        self.commands = commands

        self.action = None
        self.loop = True

        self.pos = (0, 0, 0)
        self.rotation = (0, 0, 0)
        self.scale = (1, 1, 1)
        self.colorize = (1, 1, 1, 1)
コード例 #19
0
ファイル: mesh.py プロジェクト: AjaxVM/pyggel
    def __init__(self, mesh, skeleton, commands):
        """Create the Animation object
           mesh must be a BasicMesh object, used to get the mesh parts
           skeleton must be a Skeleton object representing the mesh data
           commands must be a dict of {"name":Action} pairs"""
        BaseSceneObject.__init__(self)

        self.mesh = mesh
        self.skeleton = skeleton
        self.commands = commands

        self.action = None
        self.loop = True

        self.pos = (0,0,0)
        self.rotation = (0,0,0)
        self.scale = (1,1,1)
        self.colorize=(1,1,1,1)
コード例 #20
0
ファイル: mesh.py プロジェクト: AjaxVM/team-pp-pyweek9
    def __init__(self, lists, pos=(0,0,0),
                 rotation=(0,0,0), verts=[],
                 scale=1, colorize=(1,1,1,1)):
        """Create the mesh object
           lists is a list of [data.DisplayList, texture] objects holding the 3d rendering of the mesh
           pos must be a three-part tuple representing the position of the mesh
           rotation must be a three-part tuple representing the rotation of the mesh
           verts is a list of vertices in the mesh
           scale must be a number or three part tuple representing the scale value of the mesh
           colorize is a 4 part tuple representing the (RGBA 0-1) color of the mesh"""
        BaseSceneObject.__init__(self)

        self.gl_lists = lists
        self.pos = pos
        self.rotation = rotation
        self.verts = verts
        self.scale = scale
        self.colorize = colorize
コード例 #21
0
ファイル: mesh.py プロジェクト: PyMine/PyMine
    def __init__(self,
                 root_mesh,
                 speed=0.025,
                 frame_duration=10,
                 kill_when_finished=True):
        """Create the exploder
           root_mesh must be a BasicMesh object to explode
           speed is how fast you want each piece to move/rotate
           frame_duration is how many times it will update before dying
           kill_when_finished indicates whether the exploder should be removed
                              from the scene when it ends"""
        BaseSceneObject.__init__(self)

        self.kill_when_finished = kill_when_finished

        self.root_mesh = root_mesh
        self.angles = {}
        self.rots = {}
        for i in self.root_mesh.get_names():
            a = math3d.Vector(self.root_mesh.get_obj_by_name(i).base_pos)
            x, y, z = a.x, a.y, a.z
            if x == y == z == 0:
                x, y, z = misc.randfloat(-2, 2), misc.randfloat(
                    0, 2), misc.randfloat(-2, 2)
            else:
                a = a.normalize()
                x, y, z = a.x, a.y, a.z

            y += misc.randfloat(1.5, 2.5)
            self.angles[i] = x + misc.randfloat(-1, 1), y + misc.randfloat(
                -1, 1), z + misc.randfloat(-1, 1)
            self.rots[i] = (misc.randfloat(-10, 10), misc.randfloat(-10, 10),
                            misc.randfloat(-10, 10))

        self.root_vals = {}
        for i in self.root_mesh.get_names():
            self.root_vals[i] = (self.root_mesh.get_obj_by_name(i).pos,
                                 self.root_mesh.get_obj_by_name(i).rotation)

        self.speed = speed
        self.age = 0
        self.frame_duration = frame_duration
        self.dead = False
        self.down_delta = 0
コード例 #22
0
ファイル: misc.py プロジェクト: AjaxVM/pyggel
    def __init__(self, verts=[], texture=None, texcs=[], colorize=(1,1,1,1), scale=1,
                 pos=(0,0,0), rotation=(0,0,0), fix_order=True, usage=GL_POLYGON):
        BaseSceneObject.__init__(self)

        self.verts = verts
        if texture:
            self.texture = texture
        if texcs:
            self.texcs = texcs
        else:
            self.texcs = [(0,0)]*len(self.verts)
        self.colorize = colorize
        self.scale = scale

        self.pos = pos
        self.rotation = rotation

        self.usage = usage

        self.display_list = data.DisplayList()
        self._compile(fix_order)
コード例 #23
0
ファイル: image.py プロジェクト: PyMine/PyMine
    def __init__(self,
                 filename,
                 pos=(0, 0),
                 rotation=(0, 0, 0),
                 scale=1,
                 colorize=(1, 1, 1, 1)):
        """Create the Image
           filename must be a filename to an image file, a pygame.Surface object or an image.Image to copy
           pos is the 2d position of the image
           rotation is the 3d rotation of the image
           scale is the scale factor for the image
           colorize is the color of the image"""
        BaseSceneObject.__init__(self)

        self.filename = filename

        self.pos = pos

        if type(filename) is type(""):
            self._load_file()
        elif isinstance(filename, type(self)):
            self._pimage = filename._pimage
            self._pimage2 = filename._pimage2
            self._image_size = filename._image_size
            self._altered_image_size = filename._altered_image_size
            self.rect = self._pimage.get_rect()
            self.to_be_blitted = list(filename.to_be_blitted)
            self.display_list = filename.display_list
            self.texture = filename.texture
            self.offset = filename.offset
            loaded = True
        else:
            self.compile_from_surface(filename)
            self.filename = None
            loaded = True

        self.to_be_blitted = []
        self.rotation = rotation
        self.scale = scale
        self.colorize = colorize
コード例 #24
0
ファイル: mesh.py プロジェクト: AjaxVM/pyggel
    def __init__(self, root_mesh, speed=0.025, frame_duration=10,
                 kill_when_finished=True):
        """Create the exploder
           root_mesh must be a BasicMesh object to explode
           speed is how fast you want each piece to move/rotate
           frame_duration is how many times it will update before dying
           kill_when_finished indicates whether the exploder should be removed
                              from the scene when it ends"""
        BaseSceneObject.__init__(self)

        self.kill_when_finished = kill_when_finished

        self.root_mesh = root_mesh
        self.angles = {}
        self.rots = {}
        for i in self.root_mesh.get_names():
            a = math3d.Vector(self.root_mesh.get_obj_by_name(i).base_pos)
            x, y, z = a.x, a.y, a.z
            if x == y == z == 0:
                x, y, z = misc.randfloat(-2,2), misc.randfloat(0,2), misc.randfloat(-2,2)
            else:
                a = a.normalize()
                x, y, z = a.x, a.y, a.z

            y += misc.randfloat(1.5,2.5)
            self.angles[i] = x+misc.randfloat(-1,1), y+misc.randfloat(-1,1), z+misc.randfloat(-1,1)
            self.rots[i] = (misc.randfloat(-10, 10),
                            misc.randfloat(-10, 10),
                            misc.randfloat(-10, 10))

        self.root_vals = {}
        for i in self.root_mesh.get_names():
            self.root_vals[i] = (self.root_mesh.get_obj_by_name(i).pos,
                                 self.root_mesh.get_obj_by_name(i).rotation)

        self.speed = speed
        self.age = 0
        self.frame_duration = frame_duration
        self.dead = False
        self.down_delta = 0
コード例 #25
0
ファイル: geometry.py プロジェクト: AjaxVM/pyggel
    def __init__(self, size, pos=(0,0,0), rotation=(0,0,0),
                 colorize=(1,1,1,1), texture=None, hide_faces=[]):
        BaseSceneObject.__init__(self)

        self.hide_faces = hide_faces

        self.size = size
        self.pos = pos
        self.rotation = rotation
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        else:
            self.texture = BlankTexture()
        self.colorize = colorize

        self.scale = 1

        self.display_list = data.DisplayList()

        self._compile()
コード例 #26
0
    def __init__(self,
                 font,
                 text,
                 color=(1, 1, 1, 1),
                 linewrap=None,
                 underline=False,
                 italic=False,
                 bold=False):
        """Create the font image
           font must be the font object used to create this image
           text must be a string of text to render (support \n newlines)
           color must be the rgba(0-1) color of the image text
           linewrap must be None or the number of pixels wide a line *should* be
               if an individual word is too large then it will go over
           underline must be True/False - whether the text is underlined or not
           italic must be True/False - whether the text is italic or not
           bold must be True/False - whether the text is bold or not"""
        BaseSceneObject.__init__(self)

        self._font = font
        self._text = text
        self._color = color
        self._linewrap = linewrap
        self._underline = underline
        self._italic = italic
        self._bold = bold

        self.pos = (0, 0)
        self.rotation = (0, 0, 0)

        self.size = (0, 0)
        self.scale = 1

        self._compiled = False
        self._compiled_list = None
        self._compiled_glyphs = []

        self.rebuild_glyphs()
コード例 #27
0
ファイル: image.py プロジェクト: AjaxVM/team-pp-pyweek9
    def __init__(self, filename, pos=(0,0),
                 rotation=(0,0,0), scale=1,
                 colorize=(1,1,1,1)):
        """Create the Image
           filename must be a filename to an image file, a pygame.Surface object or an image.Image to copy
           pos is the 2d position of the image
           rotation is the 3d rotation of the image
           scale is the scale factor for the image
           colorize is the color of the image"""
        BaseSceneObject.__init__(self)

        self.filename = filename

        self.pos = pos

        if type(filename) is type(""):
            self._load_file()
        elif isinstance(filename, type(self)):
            self._pimage = filename._pimage
            self._pimage2 = filename._pimage2
            self._image_size = filename._image_size
            self._altered_image_size = filename._altered_image_size
            self.rect = self._pimage.get_rect()
            self.to_be_blitted = list(filename.to_be_blitted)
            self.display_list = filename.display_list
            self.texture = filename.texture
            self.offset = filename.offset
            loaded = True
        else:
            self.compile_from_surface(filename)
            self.filename = None
            loaded = True

        self.to_be_blitted = []
        self.rotation = rotation
        self.scale = scale
        self.colorize = colorize
コード例 #28
0
ファイル: font.py プロジェクト: AjaxVM/pyggel
    def __init__(self, font, text, char_height, color=(1,1,1,1),
                 underline=False, italic=False, bold=False,
                 linewrap=None, break_words=False):
        BaseSceneObject.__init__(self)
        self.font = font
        self.char_height = char_height
        self._bold = bold
        self._italic = italic
        self._underline = underline
        self.underline_count = 0
        self._color = None
        self._linewrap = linewrap
        self._break_words = break_words

        if underline:
            tsize = len(text)+1 #works because new lines are replaced by the underlines...
        else:
            tsize = len(text)-text.count("\n")

        self.text_array = data.get_best_array_type(GL_TRIANGLES, 6*tsize, 5) #create array!
        self.text_array.texture = self.font.font_tex

        self.text = text
        self.color = color
コード例 #29
0
ファイル: image.py プロジェクト: AjaxVM/pyggel
    def __init__(self, filename, pos=(0,0),
                 rotation=(0,0,0), scale=1,
                 colorize=(1,1,1,1)):
        """Create the Image
           filename must be a filename to an image file, a pygame.Surface object or an image.Image to copy
           pos is the 2d position of the image
           rotation is the 3d rotation of the image
           scale is the scale factor for the image
           colorize is the color of the image"""
        BaseSceneObject.__init__(self)

        if isinstance(filename, data.Texture):
            self.filename = filename.filename
            self.texture = filename
        else:
            self.filename = filename
            self.texture = data.Texture(filename)

        self._compile()

        self.pos = pos
        self.rotation = rotation
        self.scale = scale
        self.colorize = colorize
コード例 #30
0
    def __init__(self,
                 size,
                 pos=(0, 0, 0),
                 rotation=(0, 0, 0),
                 colorize=(1, 1, 1, 1),
                 texture=None,
                 mirror=True,
                 hide_faces=[]):
        """Create a cube
           size is the absolute size of the cube
           pos is the position of the cube
           rotation is the rotation of the cube
           colorize is the color of the cube (0-1 RGBA)
           texture can be None, a data.Texture object or a string representing the filename of a texture to load
           mirror indicates whether each face of the cube has the full texture on it (so each is identicle) or
               if True, each face will have the entire texture mapped to it
               if False, the Texture is considered a cube map, like this:
                   blank, blank, top, blank,
                   back, left, front, right,
                   blank, blank, bottom, blank
           hide_faces must be a list of the sides of the cube not to add:
               acceptable values are left, right, top, bottom, back, front"""
        BaseSceneObject.__init__(self)

        self.hide_faces = hide_faces

        self.size = size
        self.pos = pos
        self.rotation = rotation
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        self.colorize = colorize

        self.mirror = mirror

        self.corners = (
            (-1, -1, 1),  #topleftfront
            (1, -1, 1),  #toprightfront
            (1, 1, 1),  #bottomrightfront
            (-1, 1, 1),  #bottomleftfront
            (-1, -1, -1),  #topleftback
            (1, -1, -1),  #toprightback
            (1, 1, -1),  #bottomrightback
            (-1, 1, -1))  #bottomleftback

        sides = (
            (7, 4, 0, 3, 2, 2, 5),  #left
            (2, 1, 5, 6, 3, 4, 4),  #right
            (7, 3, 2, 6, 5, 0, 3),  #top
            (0, 4, 5, 1, 4, 5, 2),  #bottom
            (3, 0, 1, 2, 0, 1, 0),  #front
            (6, 5, 4, 7, 1, 3, 1))  #back
        self.sides = []
        if not "left" in hide_faces:
            self.sides.append(sides[0])
        if not "right" in hide_faces:
            self.sides.append(sides[1])
        if not "top" in hide_faces:
            self.sides.append(sides[2])
        if not "bottom" in hide_faces:
            self.sides.append(sides[3])
        if not "front" in hide_faces:
            self.sides.append(sides[4])
        if not "back" in hide_faces:
            self.sides.append(sides[5])

        self.normals = (
            (0, 0, 1),  #front
            (0, 0, -1),  #back
            (0, -1, 0),  #top
            (0, 1, 0),  #bottom
            (1, 0, 0),  #right
            (-1, 0, 0))  #left

        self.split_coords = (
            (2, 2),  #top
            (0, 1),  #back
            (1, 1),  #left
            (2, 1),  #front
            (3, 1),  #right
            (2, 0))  #bottom

        self.scale = 1

        self.display_list = data.DisplayList()

        self._compile()
コード例 #31
0
ファイル: geometry.py プロジェクト: AjaxVM/pyggel
    def __init__(self, size, pos=(0,0,0), rotation=(0,0,0),
                 colorize=(1,1,1,1), texture=None, mirror=True,
                 hide_faces=[]):
        """Create a cube
           size is the absolute size of the cube
           pos is the position of the cube
           rotation is the rotation of the cube
           colorize is the color of the cube (0-1 RGBA)
           texture can be None, a data.Texture object or a string representing the filename of a texture to load
           mirror indicates whether each face of the cube has the full texture on it (so each is identicle) or
               if True, each face will have the entire texture mapped to it
               if False, the Texture is considered a cube map, like this:
                   blank, blank, top, blank,
                   back, left, front, right,
                   blank, blank, bottom, blank
           hide_faces must be a list of the sides of the cube not to add:
               acceptable values are left, right, top, bottom, back, front"""
        BaseSceneObject.__init__(self)

        self.hide_faces = hide_faces

        self.size = size
        self.pos = pos
        self.rotation = rotation
        if type(texture) is type(""):
            texture = Texture(texture)
        if texture:
            self.texture = texture
        else:
            self.texture = BlankTexture()
        self.colorize = colorize

        self.mirror = mirror

        self.corners = ((-1, -1, 1),#topleftfront
                      (1, -1, 1),#toprightfront
                      (1, 1, 1),#bottomrightfront
                      (-1, 1, 1),#bottomleftfront
                      (-1, -1, -1),#topleftback
                      (1, -1, -1),#toprightback
                      (1, 1, -1),#bottomrightback
                      (-1, 1, -1))#bottomleftback

        sides = ((7,4,0,3, 2, 2, 5),#left
                      (2,1,5,6, 3, 4, 4),#right
                      (7,3,2,6, 5, 0, 3),#top
                      (0,4,5,1, 4, 5, 2),#bottom
                      (3,0,1,2, 0, 1, 0),#front
                      (6,5,4,7, 1, 3, 1))#back
        self.sides = []
        if not "left" in hide_faces:
            self.sides.append(sides[0])
        if not "right" in hide_faces:
            self.sides.append(sides[1])
        if not "top" in hide_faces:
            self.sides.append(sides[2])
        if not "bottom" in hide_faces:
            self.sides.append(sides[3])
        if not "front" in hide_faces:
            self.sides.append(sides[4])
        if not "back" in hide_faces:
            self.sides.append(sides[5])
        self.normals = ((0, 0, 1), #front
                        (0, 0, -1), #back
                        (0, -1, 0), #top
                        (0, 1, 0), #bottom
                        (1, 0, 0), #right
                        (-1, 0, 0)) #left

        self.split_coords = ((2,2),#top
                             (0,1),#back
                             (1,1),#left
                             (2,1),#front
                             (3,1),#right
                             (2,0))#bottom

        self.scale = 1

        self.display_list = data.DisplayList()

        self._compile()