pyunity.render module¶
Classes to aid in rendering in a Scene.
-
pyunity.render.
gen_buffers
(mesh)[source]¶ Create buffers for a mesh.
Parameters: mesh (Mesh) – Mesh to create buffers for Returns: Tuple containing a vertex buffer object and an index buffer object. Return type: tuple
-
pyunity.render.
gen_array
()[source]¶ Generate a vertex array object.
Returns: A vertex buffer object of floats. Has 3 elements: # vertex # normal # texcoord x, y, z, a, b, c, u, v
Return type: Any
-
class
pyunity.render.
Shader
(vertex, frag, name)[source]¶ Bases:
object
-
compile
()[source]¶ Compiles shader and generates program. Checks for errors.
Notes
This function will not work if there is no active framebuffer.
-
static
fromFolder
(path, name)[source]¶ Create a Shader from a folder. It must contain
vertex.glsl
andfragment.glsl
.Parameters: - path (str) – Path of folder to load
- name (str) – Name to register this shader to. Used with Camera.SetShader.
-
setVec3
(var, val)[source]¶ Set a
vec3
uniform variable.Parameters: - var (bytes) – Variable name
- val (Any) – Value of uniform variable
-
setMat4
(var, val)[source]¶ Set a
mat4
uniform variable.Parameters: - var (bytes) – Variable name
- val (Any) – Value of uniform variable
-
setInt
(var, val)[source]¶ Set an
int
uniform variable.Parameters: - var (bytes) – Variable name
- val (Any) – Value of uniform variable
-
-
class
pyunity.render.
Camera
(transform)[source]¶ Bases:
pyunity.core.SingleComponent
Component to hold data about the camera in a scene.
-
near
¶ Distance of the near plane in the camera frustrum. Defaults to 0.05.
Type: float
-
far
¶ Distance of the far plane in the camera frustrum. Defaults to 100.
Type: float
-
fov
¶ FOV of camera
-
Resize
(width, height)[source]¶ Resizes the viewport on screen size change.
Parameters: - width (int) – Width of new window
- height (int) – Height of new window
-
Render
(renderers, lights)[source]¶ Render specific renderers, taking into account light positions.
Parameters: - renderers (List[MeshRenderer]) – Which meshes to render
- lights (List[Light]) – Lights to load into shader
-