opynsim.graphics#
Classes
- class opynsim.graphics.Mesh(*args, **kwargs)#
Bases:
objectRepresents a renderable mesh.
- __init__(self) None#
- property faces#
Gets/sets the faces (indices) of the mesh as an 1-dimensional ndarray.
- property vertices#
Gets/sets the vertices of the mesh as an Nx3 ndarray.
- class opynsim.graphics.Texture2D#
Bases:
objectRepresents a two-dimensional image.
- __init__(*args, **kwargs)#
- pixels_rgb24(self) numpy.ndarray[dtype=uint8, shape=(*, *, 3), writable=False]#
Returns an ndarray with the shape
(height, width, 3), where each element of the 3rd dimension is a raw uint8 (0-255) pixel value for the red (R), green (G), and blue (B) components of the texture respectively.The layout of the pixels is such that the first pixel in the first row (
rv[0, 0]) starts in the top-left of the image. Subsequent pixels within that row are then encoded left-to-right. The following row (rv[1]) is then below that row, and so on, until the final pixel, which is in the bottom-right of the image.The encoding of the components of a pixel is such that the lowest value for each component is zero, representing zero intensity of that component. The highest value for each component is 255, representing the maximum intensity of that component. All components are in an sRGB color space.
- pixels_rgba32(self) numpy.ndarray[dtype=uint8, shape=(*, *, 4), writable=False]#
Returns an ndarray with the shape
(height, width, 4), where each element of the 3rd dimension is a raw uint8 (0-255) pixel value for the red (R), green (G), blue (B), and alpha (A) components of the texture respectively.The layout of the pixels is such that the first pixel in the first row (
rv[0, 0]) starts in the top-left of the image. Subsequent pixels within that row are then encoded left-to-right. The following row (rv[1]) is then below that row, and so on, until the final pixel, which is in the bottom-right of the image.The encoding of the components of a pixel is such that the lowest value for each component is zero, representing zero intensity of that component. The highest value for each component is 255, representing the maximum intensity of that component. The color components (R, G, and B) are in an sRGB color space, while the alpha component (A) is linear.
- opynsim.graphics.render_model_in_state(model: opynsim._core.Model, model_state: opynsim._core.ModelState, *, dimensions: tuple[int, int] = (640, 480), zoom_to_fit: bool = True, draw_floor: bool = False) opynsim._core.graphics.Texture2D#
Renders the given
opynsim.Model+opynsim.ModelStateto aopynsim.graphics.Texture2D.- Parameters:
model (opynsim.Model) – The model to render.
model_state (opynsim.ModelState) – The state of the model to render. Should be realized to at least
opynsim.ModelStateStage.REPORT.dimensions (tuple[int, int]) – The desired output resolution (width, height) of the rendered image in pixels.
zoom_to_fit (bool) – Tells the renderer to automatically set up the camera to focus on the center of the bounds of the scene at a distance that can see the entire scene.
draw_floor (bool) – Draws a chequered floor.
- Returns:
The rendered image, which will have the specified
dimensions.- Return type: