Camera ¶
Camera(camera=None)
distance_for_scale ¶
distance_for_scale(size_max, scale=1.0, margin=0.0, fit_axis='auto')
Compute:
- d0: distance at which an unscaled object of real size size_max
exactly fits
the camera frame along fit_axis
(largest dimension touches the borders).
- d : distance such that the UNscaled object at distance d has the same apparent size
as the SCALED object (size_max * scale) at distance d0. (i.e. d = d0 / scale)
- meters_per_pixel: world-space length at distance d that projects to exactly 1 pixel
(so two vertices closer than this fall onto the same pixel).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size_max
|
float
|
Largest real dimension of the mesh (Blender units). |
required |
scale
|
float
|
Geometry scale (> 0) applied at distance d0. |
1.0
|
margin
|
float
|
Extra margin around the frame (same convention as elsewhere). |
0.0
|
fit_axis
|
(auto, width, height)
|
Which frame span to use to define "exactly fits". - "auto": min(width, height) - "width": frame width - "height": frame height |
"auto"
|
Returns:
Name | Type | Description |
---|---|---|
d |
float
|
Distance where the UNscaled object matches the apparent size of the SCALED one at d0 (d = d0 / scale). |
meters_per_pixel |
float
|
World-space size corresponding to 1 pixel at distance d. |
Notes
- Uses Blender's view_frame on plane z = cam_z. width = cam_x1 - cam_x0 height = cam_y1 - cam_y0
- Perspective: apparent_size ∝ size / distance equality ⇒ size_max / d = (size_max * scale) / d0 ⇒ d = d0 / scale.
pixels_per_meter ¶
pixels_per_meter(distances)
Returns the number of pixels per meter given the distances
Arguments
- distances (array of floats) : the distances
Returns:
Type | Description |
---|---|
- array of floats : the size of a meter in pixels
|
|
visible_edges ¶
visible_edges(mesh, radius=0.0, margin=0.0)
Mesh edges visibility
The visibility of each point is computed with the given radius. An edge is considered invisible if both points are hidden for the same reason: both are left to the camera, or right, or behind...
In the other case, the edge is considered as visible.
Arguments
mesh : Mesh The mesh with points and edges radius : float The radius of the camera margin : float The margin of the camera
Returns:
Name | Type | Description |
---|---|---|
vis |
array (n) of bools
|
The visibility of each edge |
size |
array (n) of floats
|
The size of the projected edges |
visible_faces ¶
visible_faces(mesh, margin=0.0, back_face_culling=False)
Mesh faces visibility
A face is considered invisible if all its points are hidden for the same reason: all are left to the camera, or right, or behind...
Arguments
mesh : Mesh The mesh with points and faces margin : float The margin of the camera back_face_culling : bool If True, the back face is not considered as visible
Returns:
Name | Type | Description |
---|---|---|
vis |
array (n) of bools
|
The visibility of each face |
size |
array (n) of floats
|
The size of the projected faces |
proj |
array (n, 3) of floats
|
The projected position of each face |
visible_islands ¶
visible_islands(mesh, islands, attribute='Island', margin=0.0)
Mesh islands visibility
Islands are defined by an integer.
Visibility is computed with the position and size of the islands
Arguments
mesh : Mesh The mesh with points and faces islands: array of ints One identifier per island attribute: attribute name The attribute name to use for the islands margin : float The margin of the camera
Returns:
Type | Description |
---|---|
- couple of arrays : array[n, 7] of bools, array[n, 2] of floats
|
|
visible_points ¶
visible_points(verts, radius=0.0, margin=0.0, normals=None, return_proj=False)
Compute the visibility of vertices.
For each vertex, the following values are computed: - visible : vertex is visible (all bools below are False) - behind : vertex is behind the visible rectangle - left : vertex is left to the visible rectangle - right : vertex if right to the visible rectangle - above : vertex is above the visible rectangle - below : vertex is below the visible rectangle - back : normal points outards - distance : distance to the camera - size : apparent size (based on radius)
Arguments
- verts (array of vectors) : vertex locations
- radius (array of floats or float = 0.) : size at the locations
- margin (float, default=0.) : margin factor around the camera
- normals (array of vectors = None) : normal pointing outwards are not visible
Returns:
Type | Description |
---|---|
- couple of arrays : array[n, 7] of bools, array[n, 2] of floats
|
|