demosys.effects package¶
Submodules¶
demosys.effects.effect module¶
-
class
demosys.effects.effect.
Effect
¶ Bases:
object
Effect base class.
The following attributes are injected by demosys before initialization:
- window_width (int): Window width in pixels
- window_height (int): Window height in pixels
- window_aspect (float): Aspect ratio of the resolution
- sys_camera (demosys.scene.camera.Camera): The system camera responding to inputs
-
create_normal_matrix
(modelview)¶ Convert to mat3 and return inverse transpose. These are normally needed when dealing with normals in shaders.
Parameters: modelview – The modelview matrix Returns: Normal matrix
-
create_projection
(fov=75.0, near=1.0, far=100.0, ratio=None)¶ Create a projection matrix with the following parameters.
Parameters: - fov – Field of view (float)
- near – Camera near value
- far – Camrea far value
- ratio – Aspect ratio of the window
Returns: The projection matrix
-
create_transformation
(rotation=None, translation=None)¶ Convenient transformation method doing rotations and translation
-
draw
(time, frametime, target)¶ Draw function called by the system every frame.
Parameters: - time – The current time in seconds (float)
- frametime – The number of milliseconds the frame is expected to take
- target – The target FBO for the effect
-
get_shader
(path)¶ Get a shader or schedule the shader for loading. If the resource is not loaded yet, an empty shader object is returned that will be populated later.
Parameters: path – Path to the shader in the virtual shader directory Returns: Shader object
-
get_texture
(path, **kwargs)¶ Get a shader or schedule the texture for loading. If the resource is not loaded yet, an empty texture object is returned that will be populated later.
Parameters: path – Path to the texture in the virtual texture directory Returns: Texture object
-
get_track
(name)¶ Get or create a rocket track. This only makes sense when using rocket timers. If the resource is not loaded yet, an empty track object is returned that will be populated later.
Parameters: name – The rocket track name Returns: Track object
-
name
= ''¶
-
sys_camera
= None¶
-
window_aspect
= 0¶
-
window_height
= 0¶
-
window_width
= 0¶
-
demosys.effects.effect.
bind_target
(func)¶ Decorator auto binding and releasing the incoming FBO in
draw()
.literal blocks:
@bind_target def draw(...): # draw stuff
demosys.effects.managers module¶
-
class
demosys.effects.managers.
BaseEffectManger
¶ Bases:
object
Base effect manager. A manager is responsible for figuring out what effect should be drawn at any given time.
-
draw
(time, frametime, target)¶ Called by the system every frame. This method should be overridden.
Parameters: - time – The current time in seconds
- frametime – The time one frame should take in seconds
- target – The target FBO
-
key_event
(key, scancode, action, mods)¶ Forwarded (unconsumed) key events from the system. See glfw’s key events for detailed information.
Parameters: - key – The keyboard key that was pressed or released.
- scancode – The system-specific scancode of the key.
- action – GLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT
- mods – Bit field describing which modifier keys were held down.
-
post_load
()¶ Called after resources are loaded. This method should be overridden.
-
pre_load
()¶ Called after OpenGL context creation before resources are loaded. This method should be overridden.
-
-
exception
demosys.effects.managers.
ManagerError
¶ Bases:
Exception
-
class
demosys.effects.managers.
SingleEffectManager
(effect_module=None)¶ Bases:
demosys.effects.managers.BaseEffectManger
Run a single effect
-
draw
(time, frametime, target)¶
-
key_event
(key, scancode, action, mods)¶
-
post_load
()¶
-
pre_load
()¶ Initialize the effect that should run.
-
-
class
demosys.effects.managers.
TrackerEffectManager
¶ Bases:
demosys.effects.managers.BaseEffectManger
Effect manager handling tracker data
demosys.effects.registry module¶
-
class
demosys.effects.registry.
EffectConfig
(module=None, cls=None)¶ Bases:
object
-
exception
demosys.effects.registry.
EffectError
¶ Bases:
Exception
-
class
demosys.effects.registry.
Effects
¶ Bases:
object
Registry for effects. This also collects what resources effects are using so we can use this in resource loading later on.
-
get_dirs
()¶ Get all effect directories for registered effects.
-
get_effect_cls
(module_name)¶ Find and return an effect class in a module
Parameters: module_name – Name of the module Returns: module, cls tuple
-
polulate
(effect_list)¶ Find all effect modules.
Parameters: effect_list – List of effect module paths
-