peng3d.layer
- Extensible 2D/3D Layering¶
-
class
peng3d.layer.
Layer
(menu: peng3d.menu.BasicMenu, window: Any = None, peng: Any = None)[source]¶ Base layer class.
A Layer can be used to separate 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
() → None[source]¶ Called when this layer needs to be drawn.
Override this method in subclasses to redefine behavior.
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.
-
on_redraw
() → None[source]¶ Called whenever the Layer should redraw itself.
Note that this method should not be called manually, instead call
redraw()
.Returns: None
-
postdraw
() → None[source]¶ Called after the
draw()
method is called.This method can be used to reset OpenGL state to avoid conflicts with other code.
Override this method in subclasses to redefine behavior.
-
-
class
peng3d.layer.
Layer2D
(menu: peng3d.menu.BasicMenu, window: Any = None, peng: Any = None)[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: peng3d.menu.BasicMenu, window: Any = None, peng: Any = None, cam: peng3d.camera.Camera = None)[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: peng3d.menu.BasicMenu, window: Any = None, peng: Any = None, group: pyglet.graphics.Group = None)[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: peng3d.menu.BasicMenu, window: Any = None, peng: Any = None, world=None, viewname: str = None)[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 during future re-drawing of the screen.
Passes the event through to the WorldView to allow for custom behavior.
Same as
on_menu_enter()
.
-
predraw
()[source]¶ Sets up the attributes used by
Layer3D()
and callsLayer3D.predraw()
.
-
setView
(name: str) → None[source]¶ Sets the view used to the specified
name
.The name must be known to the world or else a
ValueError
is raised.