pyunity.render module

Classes to aid in rendering in a Scene.

class pyunity.render.Camera[source]

Bases: pyunity.core.SingleComponent

Component to hold data about the camera in a scene.

fov

Fov in degrees measured horizontally. Defaults to 90.

Type:int
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
clearColor

Tuple of 4 floats of the clear color of the camera. Defaults to (.1, .1, .1, 1). Color mode is RGBA.

Type:tuple
AddComponent(component)

Calls AddComponent on the component’s GameObject.

Parameters:component (Component) – Component to add. Must inherit from Component
GetComponent(component)

Calls GetComponent on the component’s GameObject.

Parameters:componentClass (Component) – Component to get. Must inherit from Component
GetComponents(component)

Calls GetComponents on the component’s GameObject.

Parameters:componentClass (Component) – Component to get. Must inherit from Component
RemoveComponent(component)

Calls RemoveComponent on the component’s GameObject.

Parameters:component (Component) – Component to remove. Must inherit from Component
RemoveComponents(component)

Calls RemoveComponents on the component’s GameObject.

Parameters:component (Component) – Component to remove. Must inherit from Component
Resize(width, height)[source]

Resizes the viewport on screen size change.

Parameters:
  • width (int) – Width of new window
  • height (int) – Height of new window
pyunity.render.convert(type, list)[source]

Converts a Python array to a C type from ctypes.

Parameters:
  • type (_ctypes.PyCSimpleType) – Type to cast to.
  • list (list) – List to cast
Returns:

A C array

Return type:

Any

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
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