scenepic 1.1.0
3D Visualization Made Easy
Public Member Functions | Static Public Member Functions | Friends | List of all members
scenepic::Mesh Class Reference

The basic ScenePic mesh class, containing vertex, triangle, and line buffers. More...

#include <mesh.h>

Public Member Functions

 Mesh (const Color &shared_color=Color::None(), const std::string &texture_id="")
 Constructor. More...
 
std::uint32_t count_vertices () const
 The number of vertices in the mesh. More...
 
Vector center_of_mass () const
 The mean of mesh vertex positions. More...
 
void reverse_triangle_order ()
 Reverses the winding order of all triangles in this mesh. More...
 
void apply_transform (const Transform &transform)
 Apply a 3D homogeneous matrix transform (i.e. More...
 
void apply_rotation (const Transform &transform)
 Apply a 3D homogeneous matrix rotation (i.e. More...
 
Mesh get_transformed (const Transform &transform)
 Get a transformed copy of this Mesh. More...
 
Mesh get_rotated (const Transform &transform)
 Get a rotated copy of this Mesh. More...
 
void append_mesh (const Mesh &mesh)
 Append another mesh object to this mesh. More...
 
void add_triangle (const Color &color=Color::None(), const Vector &pos0=Vector(0, 0, 0), const Vector &pos1=Vector(1, 0, 0), const Vector &pos2=Vector(0, 1, 0), const Vector &normal=VectorNone(), bool fill_triangles=true, bool add_wireframe=false, const UV &uv_0=UV(0, 0), const UV &uv_1=UV(1, 0), const UV &uv_2=UV(0, 1))
 Adds a triangle to the mesh. More...
 
void add_quad (const Color &color=Color::None(), const Vector &pos0=Vector(0, -0.5f, -0.5f), const Vector &pos1=Vector(0,+0.5f, -0.5f), const Vector &pos2=Vector(0,+0.5f,+0.5f), const Vector &pos3=Vector(0, -0.5f,+0.5f), const Vector &normal=VectorNone(), bool fill_triangles=true, bool add_wireframe=false, const Transform &transform=Transform::Identity(), const UV &uv_0=UV(0, 0), const UV &uv_1=UV(1, 0), const UV &uv_2=UV(1, 1), const UV &uv_3=UV(0, 1))
 Adds a quad to the mesh. More...
 
void add_image (const Vector &origin=Vector(-0.5f, -0.5f, 0), const Vector &x_axis=Vector(1, 0, 0), const Vector &y_axis=Vector(0, 1, 0), const Vector &normal=VectorNone(), const UV &uv_0=UV(0, 0), const UV &uv_1=UV(1, 0), const UV &uv_2=UV(1, 1), const UV &uv_3=UV(0, 1), bool double_sided=true, const Transform &transform=Transform::Identity())
 Add an image as a textured quad to this Mesh. More...
 
void add_cube (const Color &color=Color::None(), const Transform &transform=Transform::Identity(), bool fill_triangles=true, bool add_wireframe=false)
 Add a unit diameter cube to this mesh. More...
 
void add_thickline (const Color &color=Color::None(), const Vector &start_point=Vector(-0.5, 0, 0), const Vector &end_point=Vector(0.5, 0, 0), float start_thickness=0.1f, float end_thickness=0.1f, const Transform &transform=Transform::Identity(), bool fill_triangles=true, bool add_wireframe=false)
 Add a thick line to this Mesh. More...
 
void add_cone (const Color &color=Color::None(), const Transform &transform=Transform::Identity(), float truncation_height=1, std::uint32_t lat_count=10, std::uint32_t long_count=10, bool fill_triangles=true, bool add_wireframe=false)
 Add a cone to this Mesh. More...
 
void add_coordinate_axes (float length=1.0f, float thickness=0.1f, const Transform &transform=Transform::Identity())
 Add a set of coordinate axes to this Mesh. More...
 
void add_camera_frustum (const Color &color=Color::None(), float fov_y_degrees=45.0f, float aspect_ratio=16.0f/9.0f, float depth=1.0f, float thickness=0.02f, const Transform &transform=Transform::Identity())
 Add a camera frustum visualization to this Mesh. More...
 
void add_camera_frustum (const Camera &camera, const Color &color=Color::None(), float thickness=0.02f, float depth=1.0f)
 Add a camera frustum visualization to this Mesh. More...
 
void add_camera_image (const Camera &camera, float depth=1.0f)
 Add the image plane for a camera into the scene. More...
 
void add_disc (const Color &color=Color::None(), const Transform &transform=Transform::Identity(), std::uint32_t segment_count=10, bool fill_triangles=true, bool add_wireframe=false)
 Add a x-axis aligned unit diameter disc to this Mesh. More...
 
void add_cylinder (const Color &color=Color::None(), const Transform &transform=Transform::Identity(), std::uint32_t segment_count=10, bool fill_triangles=true, bool add_wireframe=false)
 Add a x-axis aligned unit diameter cylinder to this Mesh. More...
 
void add_sphere (const Color &color=Color::None(), const Transform &transform=Transform::Identity(), bool fill_triangles=true, bool add_wireframe=false)
 Add a default (ico) unit diameter sphere primitive to the mesh. More...
 
void add_icosphere (const Color &color=Color::None(), const Transform &transform=Transform::Identity(), std::uint32_t steps=0, bool fill_triangles=true, bool add_wireframe=false)
 Add a unit diameter ico-sphere to this Mesh. More...
 
void add_uv_sphere (const Color &color=Color::None(), const Transform &transform=Transform::Identity(), std::uint32_t lat_count=10, std::uint32_t long_count=10, bool fill_triangles=true, bool add_wireframe=false)
 Add a unit diameter UV sphere to this Mesh. More...
 
void add_mesh_without_normals (const ConstVectorBufferRef &vertices, const ConstTriangleBufferRef &triangles, const ConstColorBufferRef &colors=ColorBufferNone(), const ConstUVBufferRef &uvs=UVBufferNone(), const Transform &transform=Transform::Identity(), bool reverse_triangle_order=false, bool fill_triangles=true, bool add_wireframe=false)
 Add a triangle mesh to this ScenePic Mesh, with normals computed automatically. More...
 
void add_mesh_with_normals (const ConstVectorBufferRef &vertices, const ConstVectorBufferRef &normals, const ConstTriangleBufferRef &triangles, const ConstColorBufferRef &colors=ColorBufferNone(), const ConstUVBufferRef &uvs=UVBufferNone(), const Transform &transform=Transform::Identity(), bool reverse_triangle_order=false, bool fill_triangles=true, bool add_wireframe=false)
 Add a triangle mesh to this ScenePic Mesh, with normals provided. More...
 
void add_mesh (const std::shared_ptr< MeshInfo > &mesh_info, const Transform &transform=Transform::Identity(), bool reverse_triangle_order=false, bool fill_triangles=true, bool add_wireframe=false)
 Add a triangle mesh to this ScenePic Mesh, with normals computed automatically. More...
 
void add_lines (const ConstVertexBufferRef &start_points, const ConstVertexBufferRef &end_points, const Color &color=Color::None(), const Transform &transform=Transform::Identity())
 Add a line cloud to this Mesh. More...
 
void enable_instancing (const ConstVectorBufferRef &positions, const ConstQuaternionBufferRef &rotations=QuaternionBufferNone(), const ConstColorBufferRef &colors=ColorBufferNone())
 Makes ScenePic render this Mesh with multiple instances, e.g. More...
 
std::string to_string () const
 Return a JSON string representing the object. More...
 
JsonValue to_json () const
 Convert this mesh into ScenePic json. More...
 
const Colorshared_color () const
 Whole-mesh color (reduces memory requirements but makes Mesh monochrome). More...
 
Meshshared_color (const Color &shared_color)
 Whole-mesh color (reduces memory requirements but makes Mesh monochrome). More...
 
const std::string & texture_id () const
 Specifies the id of a ScenePic Image to be used as a texture in this Mesh. More...
 
Meshtexture_id (const std::string &texture_id)
 Specifies the id of a ScenePic Image to be used as a texture in this Mesh. More...
 
const std::string & mesh_id () const
 A unique identifier for the Mesh. More...
 
const std::string & layer_id () const
 An identifier to allow several Meshes to be grouped together into a "layer". More...
 
Meshlayer_id (const std::string &layer_id)
 An identifier to allow several Meshes to be grouped together into a "layer". More...
 
bool double_sided () const
 Whether to turn off back face culling and draw the Mesh's triangles as double sided. More...
 
Meshdouble_sided (bool double_sided)
 Whether to turn off back face culling and draw the Mesh's triangles as double sided. More...
 
bool camera_space () const
 Whether this Mesh is defined in camera space (cannot be moved in the ScenePic user interface) or world space (standard). More...
 
Meshcamera_space (bool camera_space)
 Whether this Mesh is defined in camera space (cannot be moved in the ScenePic user interface) or world space (standard). More...
 
bool nn_texture () const
 Whether the shader should use nearest-neighbor texture interpolation. More...
 
Meshnn_texture (bool nn_texture)
 Whether the shader should use nearest-neighbor texture interpolation. More...
 
bool use_texture_alpha () const
 Whether to use the alpha channel in the texture for transparency (only relevant for textured Meshes). More...
 
Meshuse_texture_alpha (bool use_texture_alpha)
 Whether to use the alpha channel in the texture for transparency (only relevant for textured Meshes). More...
 
bool is_billboard () const
 Draw this Mesh as a billboard (i.e. More...
 
Meshis_billboard (bool is_billboard)
 Draw this Mesh as a billboard (i.e. More...
 
bool is_label () const
 This mesh will be treated specially as a label. More...
 
Meshis_label (bool is_label)
 This mesh will be treated specially as a label. More...
 
const ConstTriangleBufferRef triangles () const
 The triangles (i.e. More...
 
VertexBlock vertex_positions ()
 Reference to the vertex positions. More...
 
const ConstVertexBlock vertex_positions () const
 const Reference to the vertex positions. More...
 
Meshvertex_positions (const VertexBlock &vertices)
 Set the vertex positions. More...
 
VertexBlock vertex_normals ()
 Reference to the vertex normals. More...
 
Meshvertex_normals (const VertexBlock &normals)
 Set the vertex normals. More...
 
const ConstVertexBlock vertex_normals () const
 const Reference to the vertex normals. More...
 
VertexBlock vertex_colors ()
 Reference to the vertex colors. More...
 
Meshvertex_colors (const VertexBlock &colors)
 Set the vertex colors. More...
 
const ConstVertexBlock vertex_colors () const
 const Reference to the vertex colors. More...
 
VertexBlock vertex_uvs ()
 Reference to the vertex uvs. More...
 
Meshvertex_uvs (const VertexBlock &uvs)
 Set the vertex uvs. More...
 
const ConstVertexBlock vertex_uvs () const
 const Reference to the vertex uvs. More...
 
VertexBufferRef vertex_buffer ()
 Reference to the vertex buffer. More...
 
InstanceBufferRef instance_buffer ()
 References to the instance buffer. More...
 

Static Public Member Functions

static VectorBuffer compute_normals (const ConstVectorBufferRef &vertices, const ConstTriangleBufferRef &triangles, bool reverse_triangle_order=false)
 Compute the vertex normals given a set of triangles and vertices. More...
 

Friends

class Scene
 

Detailed Description

The basic ScenePic mesh class, containing vertex, triangle, and line buffers.

To allow for compatibility with Numpy, we use row major order, so each data point is stored as a row for efficiency. Vertex buffer contains float32 elements with structure: x,y,z, and the normal buffer contains elements: nx,ny,nz.

If shared_color is set then per-vertex color [cr,cg,cb,ca] in the color buffer is omitted to save memory.

If texture_id is None then per-vertex texture coordinates [tu, tv] in the uv buffer are omitted to save memory.

Right handed coordinate system used throughout.

Triangle winding order is counter clockwise.

Constructor & Destructor Documentation

◆ Mesh()

scenepic::Mesh::Mesh ( const Color shared_color = Color::None(),
const std::string &  texture_id = "" 
)

Constructor.

A Mesh constructed in this way will not be added to a scene.

Parameters
shared_colorthe initial shared color for the mesh
texture_idthe initial texture ID for the mesh

Member Function Documentation

◆ add_camera_frustum() [1/2]

void scenepic::Mesh::add_camera_frustum ( const Camera camera,
const Color color = Color::None(),
float  thickness = 0.02f,
float  depth = 1.0f 
)

Add a camera frustum visualization to this Mesh.

Parameters
camerathe ScenePic Camera to visualize
colorrequired unless Mesh was constructed with shared_color argument.
thicknessthickness of the edges
depthdepth of the frustum

◆ add_camera_frustum() [2/2]

void scenepic::Mesh::add_camera_frustum ( const Color color = Color::None(),
float  fov_y_degrees = 45.0f,
float  aspect_ratio = 16.0f/9.0f,
float  depth = 1.0f,
float  thickness = 0.02f,
const Transform &  transform = Transform::Identity() 
)

Add a camera frustum visualization to this Mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
fov_y_degreesvertical field of view in degrees
aspect_ratioaspect ratio of field of view (width/height)
depthdepth of the frustrtum
thicknessthickness of the edges
transformoptional transform

◆ add_camera_image()

void scenepic::Mesh::add_camera_image ( const Camera camera,
float  depth = 1.0f 
)

Add the image plane for a camera into the scene.

Parameters
camerathe ScenePic Camera corresponding to the image
depthdepth of the frustum

◆ add_cone()

void scenepic::Mesh::add_cone ( const Color color = Color::None(),
const Transform &  transform = Transform::Identity(),
float  truncation_height = 1,
std::uint32_t  lat_count = 10,
std::uint32_t  long_count = 10,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a cone to this Mesh.

The cone has base center at [0.5, 0., 0.] and apex at [-0.5, 0., 0.].

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
transformoptional transform
truncation_heightdraws a truncated cone of this height
lat_countnumber of discrete samples in latitude
long_countnumber of discrete samples in longitude
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_coordinate_axes()

void scenepic::Mesh::add_coordinate_axes ( float  length = 1.0f,
float  thickness = 0.1f,
const Transform &  transform = Transform::Identity() 
)

Add a set of coordinate axes to this Mesh.

xyz axes map to RGB colors.

Parameters
lengthlength of axes
thicknessthickness of axes
transformoptional transform

◆ add_cube()

void scenepic::Mesh::add_cube ( const Color color = Color::None(),
const Transform &  transform = Transform::Identity(),
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a unit diameter cube to this mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
transformoptional transform
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_cylinder()

void scenepic::Mesh::add_cylinder ( const Color color = Color::None(),
const Transform &  transform = Transform::Identity(),
std::uint32_t  segment_count = 10,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a x-axis aligned unit diameter cylinder to this Mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
transformoptional transform
segment_countnumber of segments in the cylinder
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_disc()

void scenepic::Mesh::add_disc ( const Color color = Color::None(),
const Transform &  transform = Transform::Identity(),
std::uint32_t  segment_count = 10,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a x-axis aligned unit diameter disc to this Mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
transformoptional transform
segment_countnumber of segments in the disc
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_icosphere()

void scenepic::Mesh::add_icosphere ( const Color color = Color::None(),
const Transform &  transform = Transform::Identity(),
std::uint32_t  steps = 0,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a unit diameter ico-sphere to this Mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
transformoptional transform
stepsnumber of subdivision steps to apply to the icosahedron base primitive
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_image()

void scenepic::Mesh::add_image ( const Vector &  origin = Vector(-0.5f, -0.5f, 0),
const Vector &  x_axis = Vector(1, 0, 0),
const Vector &  y_axis = Vector(0, 1, 0),
const Vector &  normal = VectorNone(),
const UV &  uv_0 = UV(0, 0),
const UV &  uv_1 = UV(1, 0),
const UV &  uv_2 = UV(1, 1),
const UV &  uv_3 = UV(0, 1),
bool  double_sided = true,
const Transform &  transform = Transform::Identity() 
)

Add an image as a textured quad to this Mesh.

The Mesh must have a texture_id.

Parameters
originbottom left corner of image.
x_axisdirection and length of the x-axis of the image in world space
y_axisdirection and length of the y-axis of the image in world space
normalwill be computed automatically if set to zero
uv_0the bottom left UV coordinate
uv_1the top left UV coordinate
uv_2the top right UV coordinate
uv_3the bottom right UV coordinate
double_sidedwhether the image should be shown on both sides
transforman optional transform

◆ add_lines()

void scenepic::Mesh::add_lines ( const ConstVertexBufferRef &  start_points,
const ConstVertexBufferRef &  end_points,
const Color color = Color::None(),
const Transform &  transform = Transform::Identity() 
)

Add a line cloud to this Mesh.

Parameters
start_pointsdefines N line start positions (and, optionally, the per-point colors)
end_pointsdefines N line end positions (and, optionally, the per-point colors)
colorif provided, will override any per-point colors stored in start_colors and end_colors.
transformoptional transform

◆ add_mesh()

void scenepic::Mesh::add_mesh ( const std::shared_ptr< MeshInfo > &  mesh_info,
const Transform &  transform = Transform::Identity(),
bool  reverse_triangle_order = false,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a triangle mesh to this ScenePic Mesh, with normals computed automatically.

Parameters
mesh_infothe positions, triangles and other elements of the mesh
transformoptional transform
reverse_triangle_orderwhether to reverse the triangle winding order
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_mesh_with_normals()

void scenepic::Mesh::add_mesh_with_normals ( const ConstVectorBufferRef &  vertices,
const ConstVectorBufferRef &  normals,
const ConstTriangleBufferRef &  triangles,
const ConstColorBufferRef &  colors = ColorBufferNone(),
const ConstUVBufferRef &  uvs = UVBufferNone(),
const Transform &  transform = Transform::Identity(),
bool  reverse_triangle_order = false,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a triangle mesh to this ScenePic Mesh, with normals provided.

Parameters
verticesmatrix of N vertex positions
normalsmatrix of N vertex normals
trianglesmatrix of N triangle vertex indices
colorsoptional matrix of N per-vertex RGB color vectors
uvsoptional matrix of N per-vertex UV coordinates
transformoptional transform
reverse_triangle_orderwhether to reverse the triangle winding order
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_mesh_without_normals()

void scenepic::Mesh::add_mesh_without_normals ( const ConstVectorBufferRef &  vertices,
const ConstTriangleBufferRef &  triangles,
const ConstColorBufferRef &  colors = ColorBufferNone(),
const ConstUVBufferRef &  uvs = UVBufferNone(),
const Transform &  transform = Transform::Identity(),
bool  reverse_triangle_order = false,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a triangle mesh to this ScenePic Mesh, with normals computed automatically.

Parameters
verticesmatrix of N vertex positions
trianglesmatrix of N triangle vertex indices
colorsoptional matrix of N per-vertex RGB color vectors
uvsoptional matrix of N per-vertex UV coordinates
transformoptional transform
reverse_triangle_orderwhether to reverse the triangle winding order
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_quad()

void scenepic::Mesh::add_quad ( const Color color = Color::None(),
const Vector &  pos0 = Vector(0, -0.5f, -0.5f),
const Vector &  pos1 = Vector(0,+0.5f, -0.5f),
const Vector &  pos2 = Vector(0,+0.5f,+0.5f),
const Vector &  pos3 = Vector(0, -0.5f,+0.5f),
const Vector &  normal = VectorNone(),
bool  fill_triangles = true,
bool  add_wireframe = false,
const Transform &  transform = Transform::Identity(),
const UV &  uv_0 = UV(0, 0),
const UV &  uv_1 = UV(1, 0),
const UV &  uv_2 = UV(1, 1),
const UV &  uv_3 = UV(0, 1) 
)

Adds a quad to the mesh.

All points are assumed to lie on the same plane.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
pos0the first vertex
pos1the second vertex
pos2the third vertex
pos3the fourth vertex
normalwill be computed automatically if set to zero
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline
transformoptional transform
uv_0optional first uv coordinate (for UV meshes)
uv_1optional second uv coordinate (for UV meshes)
uv_2optional third uv coordinate (for UV meshes)
uv_3optional fourth uv coordinate (for UV meshes)

◆ add_sphere()

void scenepic::Mesh::add_sphere ( const Color color = Color::None(),
const Transform &  transform = Transform::Identity(),
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a default (ico) unit diameter sphere primitive to the mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
transformoptional transform
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_thickline()

void scenepic::Mesh::add_thickline ( const Color color = Color::None(),
const Vector &  start_point = Vector(-0.5, 0, 0),
const Vector &  end_point = Vector(0.5, 0, 0),
float  start_thickness = 0.1f,
float  end_thickness = 0.1f,
const Transform &  transform = Transform::Identity(),
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a thick line to this Mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
start_pointthe start point of the line
end_pointthe end point of the line
start_thicknessthe start thickness of the line
end_thicknessthe end thickness of the line
transformoptional transform
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ add_triangle()

void scenepic::Mesh::add_triangle ( const Color color = Color::None(),
const Vector &  pos0 = Vector(0, 0, 0),
const Vector &  pos1 = Vector(1, 0, 0),
const Vector &  pos2 = Vector(0, 1, 0),
const Vector &  normal = VectorNone(),
bool  fill_triangles = true,
bool  add_wireframe = false,
const UV &  uv_0 = UV(0, 0),
const UV &  uv_1 = UV(1, 0),
const UV &  uv_2 = UV(0, 1) 
)

Adds a triangle to the mesh.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
pos0the first vertex
pos1the second vertex
pos2the third vertex
normalwill be computed automatically if set to zero
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline
uv_0optional first uv coordinate (for UV meshes)
uv_1optional second uv coordinate (for UV meshes)
uv_2optional third uv coordinate (for UV meshes)

◆ add_uv_sphere()

void scenepic::Mesh::add_uv_sphere ( const Color color = Color::None(),
const Transform &  transform = Transform::Identity(),
std::uint32_t  lat_count = 10,
std::uint32_t  long_count = 10,
bool  fill_triangles = true,
bool  add_wireframe = false 
)

Add a unit diameter UV sphere to this Mesh.

If the mesh has a texture attached, this method will automatically create a set of vertex UVs which unwraps the sphere to map to the full UV space.

Parameters
colorrequired unless Mesh was constructed with shared_color argument.
transformoptional transform
lat_countnumber of discrete samples in latitude
long_countnumber of discrete samples in longitude
fill_triangleswhether to fill the primitive
add_wireframewhether to add a wireframe outline

◆ append_mesh()

void scenepic::Mesh::append_mesh ( const Mesh mesh)

Append another mesh object to this mesh.

Parameters
meshthe mesh to append

◆ apply_rotation()

void scenepic::Mesh::apply_rotation ( const Transform &  transform)

Apply a 3D homogeneous matrix rotation (i.e.

4x4 matrix) to all vertices (and appropriately to the normals) in the Mesh. Separated out from apply_transform() so that a matrix inverse is not required, for speed.

Parameters
transforma 3D homogeneous rotation matrix

◆ apply_transform()

void scenepic::Mesh::apply_transform ( const Transform &  transform)

Apply a 3D homogeneous matrix transform (i.e.

4x4 matrix) to all vertices (and appropriately to the normals) in the Mesh.

Parameters
transforma 3D homogeneous transform

◆ camera_space() [1/2]

bool scenepic::Mesh::camera_space ( ) const

Whether this Mesh is defined in camera space (cannot be moved in the ScenePic user interface) or world space (standard).

◆ camera_space() [2/2]

Mesh & scenepic::Mesh::camera_space ( bool  camera_space)

Whether this Mesh is defined in camera space (cannot be moved in the ScenePic user interface) or world space (standard).

◆ center_of_mass()

Vector scenepic::Mesh::center_of_mass ( ) const

The mean of mesh vertex positions.

◆ compute_normals()

static VectorBuffer scenepic::Mesh::compute_normals ( const ConstVectorBufferRef &  vertices,
const ConstTriangleBufferRef &  triangles,
bool  reverse_triangle_order = false 
)
static

Compute the vertex normals given a set of triangles and vertices.

Parameters
verticesthe vertex positions
trianglesthe triangles defining the mesh
reverse_triangle_orderwhether to reverse the triangle order when computing the normals.
Returns
a buffer containing the normalized per-vertex normals

◆ count_vertices()

std::uint32_t scenepic::Mesh::count_vertices ( ) const

The number of vertices in the mesh.

◆ double_sided() [1/2]

bool scenepic::Mesh::double_sided ( ) const

Whether to turn off back face culling and draw the Mesh's triangles as double sided.

◆ double_sided() [2/2]

Mesh & scenepic::Mesh::double_sided ( bool  double_sided)

Whether to turn off back face culling and draw the Mesh's triangles as double sided.

◆ enable_instancing()

void scenepic::Mesh::enable_instancing ( const ConstVectorBufferRef &  positions,
const ConstQuaternionBufferRef &  rotations = QuaternionBufferNone(),
const ConstColorBufferRef &  colors = ColorBufferNone() 
)

Makes ScenePic render this Mesh with multiple instances, e.g.

for point-cloud visualizations. Can be used to make point clouds, for example. The whole contents of the Mesh will be rendered multiple times.

Parameters
positionsthe positions of the N instances
colorsif provided, a per-instance color that overrides a Mesh's shared_color or per-vertex color
rotationsif provided, a per-instance quaternion rotation that rotates each instance

◆ get_rotated()

Mesh scenepic::Mesh::get_rotated ( const Transform &  transform)

Get a rotated copy of this Mesh.

Parameters
transforma 3D homogeneous rotation matrix
Returns
a transformed copy of this mesh

◆ get_transformed()

Mesh scenepic::Mesh::get_transformed ( const Transform &  transform)

Get a transformed copy of this Mesh.

Parameters
transforma 3D homogeneous transform
Returns
a transformed copy of this mesh

◆ instance_buffer()

InstanceBufferRef scenepic::Mesh::instance_buffer ( )

References to the instance buffer.

Instances are stored in a NxD matrix in the following way per row: [x, y, z] [x, y, z, r, g, b] (+ color) [x, y, z, qx, qy, qz, qw] (+ rotation) [x, y, z, qx, qy, qz, qw, r, g, b] (+ rotation and color)

◆ is_billboard() [1/2]

bool scenepic::Mesh::is_billboard ( ) const

Draw this Mesh as a billboard (i.e.

always facing the user) rather than rotating with the rest of the world.

◆ is_billboard() [2/2]

Mesh & scenepic::Mesh::is_billboard ( bool  is_billboard)

Draw this Mesh as a billboard (i.e.

always facing the user) rather than rotating with the rest of the world.

◆ is_label() [1/2]

bool scenepic::Mesh::is_label ( ) const

This mesh will be treated specially as a label.

Not for public use.

◆ is_label() [2/2]

Mesh & scenepic::Mesh::is_label ( bool  is_label)

This mesh will be treated specially as a label.

Not for public use.

◆ layer_id() [1/2]

const std::string & scenepic::Mesh::layer_id ( ) const

An identifier to allow several Meshes to be grouped together into a "layer".

Layers should be used in conjunction with Canvas3D.set_layer_settings().

See also
Canvas3D::set_layer_settings.

◆ layer_id() [2/2]

Mesh & scenepic::Mesh::layer_id ( const std::string &  layer_id)

An identifier to allow several Meshes to be grouped together into a "layer".

Layers should be used in conjunction with Canvas3D.set_layer_settings().

See also
Canvas3D::set_layer_settings.

◆ mesh_id()

const std::string & scenepic::Mesh::mesh_id ( ) const

A unique identifier for the Mesh.

◆ nn_texture() [1/2]

bool scenepic::Mesh::nn_texture ( ) const

Whether the shader should use nearest-neighbor texture interpolation.

◆ nn_texture() [2/2]

Mesh & scenepic::Mesh::nn_texture ( bool  nn_texture)

Whether the shader should use nearest-neighbor texture interpolation.

◆ reverse_triangle_order()

void scenepic::Mesh::reverse_triangle_order ( )

Reverses the winding order of all triangles in this mesh.

Useful when interoping with existing codebases that use opposite convention.

◆ shared_color() [1/2]

const Color & scenepic::Mesh::shared_color ( ) const

Whole-mesh color (reduces memory requirements but makes Mesh monochrome).

◆ shared_color() [2/2]

Mesh & scenepic::Mesh::shared_color ( const Color shared_color)

Whole-mesh color (reduces memory requirements but makes Mesh monochrome).

◆ texture_id() [1/2]

const std::string & scenepic::Mesh::texture_id ( ) const

Specifies the id of a ScenePic Image to be used as a texture in this Mesh.

◆ texture_id() [2/2]

Mesh & scenepic::Mesh::texture_id ( const std::string &  texture_id)

Specifies the id of a ScenePic Image to be used as a texture in this Mesh.

◆ to_json()

JsonValue scenepic::Mesh::to_json ( ) const

Convert this mesh into ScenePic json.

Returns
a json value

◆ to_string()

std::string scenepic::Mesh::to_string ( ) const

Return a JSON string representing the object.

◆ triangles()

const ConstTriangleBufferRef scenepic::Mesh::triangles ( ) const

The triangles (i.e.

face vertex indices) defining the mesh

◆ use_texture_alpha() [1/2]

bool scenepic::Mesh::use_texture_alpha ( ) const

Whether to use the alpha channel in the texture for transparency (only relevant for textured Meshes).

◆ use_texture_alpha() [2/2]

Mesh & scenepic::Mesh::use_texture_alpha ( bool  use_texture_alpha)

Whether to use the alpha channel in the texture for transparency (only relevant for textured Meshes).

◆ vertex_buffer()

VertexBufferRef scenepic::Mesh::vertex_buffer ( )

Reference to the vertex buffer.

Vertices are stored in a NxD matrix in the following way per row: [x, y, z, nx, ny, nz] (no color or uvs) [x, y, z, nx, ny, nz, r, g, b] (+ color) [x, y, z, nx, ny, nz, u, v] (+ uv)

◆ vertex_colors() [1/3]

VertexBlock scenepic::Mesh::vertex_colors ( )

Reference to the vertex colors.

◆ vertex_colors() [2/3]

const ConstVertexBlock scenepic::Mesh::vertex_colors ( ) const

const Reference to the vertex colors.

◆ vertex_colors() [3/3]

Mesh & scenepic::Mesh::vertex_colors ( const VertexBlock &  colors)

Set the vertex colors.

◆ vertex_normals() [1/3]

VertexBlock scenepic::Mesh::vertex_normals ( )

Reference to the vertex normals.

◆ vertex_normals() [2/3]

const ConstVertexBlock scenepic::Mesh::vertex_normals ( ) const

const Reference to the vertex normals.

◆ vertex_normals() [3/3]

Mesh & scenepic::Mesh::vertex_normals ( const VertexBlock &  normals)

Set the vertex normals.

◆ vertex_positions() [1/3]

VertexBlock scenepic::Mesh::vertex_positions ( )

Reference to the vertex positions.

◆ vertex_positions() [2/3]

const ConstVertexBlock scenepic::Mesh::vertex_positions ( ) const

const Reference to the vertex positions.

◆ vertex_positions() [3/3]

Mesh & scenepic::Mesh::vertex_positions ( const VertexBlock &  vertices)

Set the vertex positions.

◆ vertex_uvs() [1/3]

VertexBlock scenepic::Mesh::vertex_uvs ( )

Reference to the vertex uvs.

◆ vertex_uvs() [2/3]

const ConstVertexBlock scenepic::Mesh::vertex_uvs ( ) const

const Reference to the vertex uvs.

◆ vertex_uvs() [3/3]

Mesh & scenepic::Mesh::vertex_uvs ( const VertexBlock &  uvs)

Set the vertex uvs.

Friends And Related Function Documentation

◆ Scene

friend class Scene
friend

The documentation for this class was generated from the following file: