peng3d.layer
- Extensible 2D/3D Layering¶
-
class
peng3d.layer.
Layer
(menu, window, peng)[source]¶ Base layer class.
A Layer can be used to seperate background from foreground or the 3d world from a 2d HUD.
This class by itself does nothing, you will need to subclass it and override the
draw()
method.-
draw
()[source]¶ Called when this layer needs to be drawn.
Override this method in subclasses to redefine behaviour.
Custom fake event handler called by
Menu.on_enter()
for every layer.Useful for adding and removing event handlers per layer.
Custom fake event handler called by
Menu.on_exit()
for every layer.Useful for adding and removing event handlers per layer.
-
-
class
peng3d.layer.
Layer2D
(menu, window, peng)[source]¶ 2D Variant of
Layer()
and a subclass of the former.This class makes use of the
predraw()
method to configure OpenGL to draw 2-Dimensionally. This class usesPengWindow.set2d()
to set the 2D mode.When overriding the
predraw()
method, make sure to call the superclass.
-
class
peng3d.layer.
Layer3D
(menu, window, peng, cam)[source]¶ 3D Variant of
Layer()
and a subclass of the former.This class works the same as
Layer2D()
, only for 3D drawing instead. This class usesPengWindow.set3d()
to set the 3D mode.Also, the correct
glTranslatef()
andglRotatef()
are applied to simplify drawing objects. When writing thedraw()
method of this class, you will only need to use world coordinates, not camera coordinates. This allows for easy building of Games using First-Person-Perspectives.
-
class
peng3d.layer.
LayerGroup
(menu, window, peng, group)[source]¶ Layer variant wrapping the supplied pyglet group.
group
may only be an instance ofpyglet.graphics.Group
, else aTypeError
will be raised.Also note that both the
predraw()
andpostdraw()
methods are overwritten by this class.See also
For more information about pyglet groups, see the pyglet docs.
-
class
peng3d.layer.
LayerWorld
(menu, window, peng, world, viewname)[source]¶ Subclass of
Layer3D()
implementing a 3D Layer showing a specificWorldView
.All arguments passed to the constructor should be self-explanatory.
Note that you may not set any of the attributes directly, or crashes and bugs may appear indirectly within a certain timeframe.
Passes the event through to the WorldView to allow for custom behaviour.
Same as
on_menu_enter()
.