Ejemplo n.º 1
0
* :class:`Vertex`: An object containing all the data needed to define a vertex.
* :class:`Face`: An object containing a set of vertices, and a primitive rendering mode.
* :class:`Texture`: A bound texture.
* :class:`Transform`: A transformation.
'''

import pygame
import numpy
from OpenGL.GL import *
from OpenGL.GLU import *

from vmath import Vector, Matrix
from event import EventHandler
from log import main, DV1, DV2, DV3, obCode
logger=main.getChild('sg')

class Modification(object):
	'''The :class:`Modification` is a generic class that applies some state
change to the current context, and reverts that state change (ideally, to the
previous state) later--usually, when that state is no longer needed. It is
actually the parent of quite a few other classes, :class:`Texture` and
:class:`Transform` included.'''
	def Apply(self):
		'''Apply the state change.

.. note::

	This must be defined by a subclass.'''
		raise NotImplementedError('Modification object must define .Apply()')
	def Revert(self):
Ejemplo n.º 2
0
This module provides an interface to a simple layout manager which is entirely
compatible with the scenegraph (provided that it is rendered after 3D geometry
and with the depth test turned off). The layout manager is a *tiling* manager,
which means that it deals with :class:`Grid`\ s.
'''

import pygame
from pygame.locals import *
from OpenGL.GL import *

from vmath import Vector
from scenegraph import Renderable, Texture
from event import EVENT, KBD, MOUSE
from log import main, DV1, DV2, DV3, obCode
logger = main.getChild('layout')


class LayoutCell(object):
    '''A :class:`LayoutCell` represents a single cell in a layout facility. In
particular, once computations have been undergone by the manager holding (a set)
of these cells, the :attr:`offset` and :attr:`size` attributes should represent
the (window coordinate) space that this cell takes up, on one dimension. (Two
cells are needed for two dimensions.)'''
    def __init__(self, weight=1.0, fixed=0):
        #: A floating point number indicating how much space this cell should be given relative to other cells in the same layout.
        self.weight = weight
        #: A numeric amount of fixed space this cell must contain (measured in the window coordinate system).
        self.fixed = fixed
        #: The offset from the origin on the dimension specifying this cell (-1 if not computed or not in a layout).
        self.offset = -1
Ejemplo n.º 3
0
This module provides an interface to a simple layout manager which is entirely
compatible with the scenegraph (provided that it is rendered after 3D geometry
and with the depth test turned off). The layout manager is a *tiling* manager,
which means that it deals with :class:`Grid`\ s.
'''

import pygame
from pygame.locals import *
from OpenGL.GL import *

from vmath import Vector
from scenegraph import Renderable, Texture
from event import EVENT, KBD, MOUSE
from log import main, DV1, DV2, DV3, obCode
logger=main.getChild('layout')

class LayoutCell(object):
	'''A :class:`LayoutCell` represents a single cell in a layout facility. In
particular, once computations have been undergone by the manager holding (a set)
of these cells, the :attr:`offset` and :attr:`size` attributes should represent
the (window coordinate) space that this cell takes up, on one dimension. (Two
cells are needed for two dimensions.)'''
	def __init__(self, weight=1.0, fixed=0):
		#: A floating point number indicating how much space this cell should be given relative to other cells in the same layout.
		self.weight=weight
		#: A numeric amount of fixed space this cell must contain (measured in the window coordinate system).
		self.fixed=fixed
		#: The offset from the origin on the dimension specifying this cell (-1 if not computed or not in a layout).
		self.offset=-1
		#: The size of this cell on this dimension (-1 if not computed or not in a layout).
Ejemplo n.º 4
0
* :class:`Vertex`: An object containing all the data needed to define a vertex.
* :class:`Face`: An object containing a set of vertices, and a primitive rendering mode.
* :class:`Texture`: A bound texture.
* :class:`Transform`: A transformation.
'''

import pygame
import numpy
from OpenGL.GL import *
from OpenGL.GLU import *

from vmath import Vector, Matrix
from event import EventHandler
from log import main, DV1, DV2, DV3, obCode
logger = main.getChild('sg')


class Modification(object):
    '''The :class:`Modification` is a generic class that applies some state
change to the current context, and reverts that state change (ideally, to the
previous state) later--usually, when that state is no longer needed. It is
actually the parent of quite a few other classes, :class:`Texture` and
:class:`Transform` included.'''
    def Apply(self):
        '''Apply the state change.

.. note::

	This must be defined by a subclass.'''
        raise NotImplementedError('Modification object must define .Apply()')
Ejemplo n.º 5
0
'''
.. mindscape -- Mindscape Engine
event -- Events
===============

This module defines events that may be used anywhere that an event-driven
system is required.
'''

import pygame
from pygame.locals import *

from vmath import Vector
from log import main, DV1, DV2, DV3, obCode

logger = main.getChild('event')


class EVENT:
    '''An enumeration containing valid values for :attr:`Event.type`.'''
    #: An event relating to the keyboard (key down, key up, character, ...)
    KBD = 1
    #: An event relating to the mouse (button press, release, mouse move, ...)
    MOUSE = 2


class KBD:
    '''An enumeration containing event subtypes for the :attr:`EVENT.KBD` event.'''
    #: A key was pressed.
    KEYDOWN = 1
    #: A key was released.
Ejemplo n.º 6
0
'''
.. mindscape -- Mindscape Engine
event -- Events
===============

This module defines events that may be used anywhere that an event-driven
system is required.
'''

import pygame
from pygame.locals import *

from vmath import Vector
from log import main, DV1, DV2, DV3, obCode
logger=main.getChild('event')

class EVENT:
	'''An enumeration containing valid values for :attr:`Event.type`.'''
	#: An event relating to the keyboard (key down, key up, character, ...)
	KBD=1
	#: An event relating to the mouse (button press, release, mouse move, ...)
	MOUSE=2

class KBD:
	'''An enumeration containing event subtypes for the :attr:`EVENT.KBD` event.'''
	#: A key was pressed.
	KEYDOWN=1
	#: A key was released.
	KEYUP=2
	#: A printable character was generated
	#: