Surface¶
Qualified name: algan.mobs.surfaces.surface.Surface
- class Surface(coord_function=None, normal_function=None, grid_height=50, grid_width=None, grid_aspect_ratio=None, checkered_color=None, color_texture=None, ignore_normals=False, *args, **kwargs)[source]¶
Bases:
Renderable
A smooth 2-D surface, embedded in 3-D space, A.K.A a manifold. The surface is implemented by sampling a uniform grid of 2-D points from the unit square (known as intrinsic coordinates, or “UV coordinates”), tiling this grid with triangles, and then mapping the triangle corners to 3-D world coordinates as defined by the manifold function.
- Parameters:
function – The function mapping 2-D intrinsic coordinates (ranging from [0,1]), to 3-D world coordinates, which defines the manifold’s shape.
function_normals – Function mapping 3-D world coordinates to their normal vectors (i.e. vectors facing directly out of the surface), used for lighting.
grid_height – Height of the grid from which internal coordinates are sampled.
grid_width – Width of the grid from which internal coordinates are sampled.
grid_aspect_radio – If not None, set the grid_height to be equal to grid_width * grid_aspect_ratio
*args – Passed to
Mob
**kwargs – Passed to
Mob
Methods
Default function used to map intrinsic coordinates to world space to define manifold shape.
get_base_grid
get_default_color
get_render_primitives
Default function used to map intrinsic coordinates to world space normals to define manifold normal directions.
set_color_by_function
set_color_by_texture
set_location_by_function
set_normal_by_function
Changes this surface's shape to the shape defined by another surface's
coord_function()
.Attributes
animation_manager
basis
The flattened 3x3 matrix representing the Mob's orientation and scale.
color
glow
location
The 3-D location of the Mob in world space.
max_opacity
normalized_basis
The Mob's basis matrix with all its row vectors normalized to unit length.
opacity
scale_coefficient
The scaling factor of the Mob along its local axes, derived from the basis.
- coord_function(uv)[source]¶
Default function used to map intrinsic coordinates to world space to define manifold shape. This method is overwritten by subclasses to define new shapes.
- Parameters:
uv (torch.Tensor[*, 2]) – Collection of 2-D coordinates to be mapped.
- normal_function(uv)[source]¶
Default function used to map intrinsic coordinates to world space normals to define manifold normal directions. This method is overwritten by subclasses to define new shapes.
- Parameters:
uv (torch.Tensor[*, 2]) – Collection of 2-D coordinates to be mapped.
- set_shape_to(other_surface)[source]¶
Changes this surface’s shape to the shape defined by another surface’s
coord_function()
.- Parameters:
other_surface (Surface) – The surface from which to get coord_function.