Effect¶
The base Effect class extended in effect modules.
Draw Methods¶
-
Effect.
draw
(time, frametime, target)¶ Draw function called by the system every frame when the effect is active. You are supposed to override this method.
Parameters: - time – The current time in seconds (float)
- frametime – The time the previous frame used to render in seconds (float)
- target – The target FBO for the effect
Resource Methods¶
-
Effect.
get_shader
(path, local=False) → ShaderProgram¶ 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
- local – Auto-prepend the effect package name to the path
Returns: Shader object
-
Effect.
get_texture
(path, local=False, **kwargs) → Texture2D¶ Get a texture 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
- local – Auto-prepend the effect package name to the path
Returns: Texture object
-
Effect.
get_texture_array
(path, layers=0, local=False, **kwargs) → TextureArray¶ Get a texture 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
- layers – (int) Numer of layers
- local – Auto-prepend the effect package name to the path
Returns: Texture object
-
Effect.
get_track
(name, local=False) → Track¶ 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
- local – Auto-prepend the effect package name to the path
Returns: Track object
-
Effect.
get_scene
(path, local=False, **kwargs) → Scene¶ Get or create a scene. :param path: Path to the scene :param local: Auto-prepend the effect package name to the path :param kwargs: Generic paramters passed to scene loaders :return: Scene object
-
Effect.
get_data
(path, local=False, **kwargs) → Data¶ Get or create a data file. :param path: Path to the data file :param local: Auto-prepend the effect package name to the path :param kwargs: Generic paramters passed to data loader :return: Data object
-
Effect.
post_load
()¶ Called when all effects are initialized before effects start running.
Utility Methods¶
-
Effect.
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
-
Effect.
create_transformation
(rotation=None, translation=None)¶ Convenient transformation method doing rotations and translation
-
Effect.
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
Attributes¶
-
Effect.
ctx
¶ ModernGL context
-
Effect.
sys_camera
¶ The system camera responding to input
-
Effect.
name
¶ Full python path to the effect
-
Effect.
effect_name
¶ Package name for the effect
-
Effect.
window_size
¶ Window size tuple (width, height)
-
Effect.
window_width
¶ Window width in pixels
-
Effect.
window_height
¶ Window height in pixels
-
Effect.
window_aspect
¶ Aspect ratio of the window