|
scenepic 1.1.0
3D Visualization Made Easy
|
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 Color & | shared_color () const |
| Whole-mesh color (reduces memory requirements but makes Mesh monochrome). More... | |
| Mesh & | shared_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... | |
| Mesh & | texture_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... | |
| Mesh & | layer_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... | |
| Mesh & | double_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... | |
| 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). More... | |
| bool | nn_texture () const |
| Whether the shader should use nearest-neighbor texture interpolation. More... | |
| Mesh & | nn_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... | |
| Mesh & | use_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... | |
| Mesh & | is_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... | |
| Mesh & | is_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... | |
| Mesh & | vertex_positions (const VertexBlock &vertices) |
| Set the vertex positions. More... | |
| VertexBlock | vertex_normals () |
| Reference to the vertex normals. More... | |
| Mesh & | vertex_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... | |
| Mesh & | vertex_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... | |
| Mesh & | vertex_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 |
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.
| 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.
| shared_color | the initial shared color for the mesh |
| texture_id | the initial texture ID for the mesh |
| void scenepic::Mesh::add_camera_frustum | ( | const Camera & | camera, |
| const Color & | color = Color::None(), |
||
| float | thickness = 0.02f, |
||
| float | depth = 1.0f |
||
| ) |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| fov_y_degrees | vertical field of view in degrees |
| aspect_ratio | aspect ratio of field of view (width/height) |
| depth | depth of the frustrtum |
| thickness | thickness of the edges |
| transform | optional transform |
| void scenepic::Mesh::add_camera_image | ( | const Camera & | camera, |
| float | depth = 1.0f |
||
| ) |
Add the image plane for a camera into the scene.
| camera | the ScenePic Camera corresponding to the image |
| depth | depth of the frustum |
| 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.].
| color | required unless Mesh was constructed with shared_color argument. |
| transform | optional transform |
| truncation_height | draws a truncated cone of this height |
| lat_count | number of discrete samples in latitude |
| long_count | number of discrete samples in longitude |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| length | length of axes |
| thickness | thickness of axes |
| transform | optional transform |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| transform | optional transform |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| transform | optional transform |
| segment_count | number of segments in the cylinder |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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 |
||
| ) |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| transform | optional transform |
| steps | number of subdivision steps to apply to the icosahedron base primitive |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| origin | bottom left corner of image. |
| x_axis | direction and length of the x-axis of the image in world space |
| y_axis | direction and length of the y-axis of the image in world space |
| normal | will be computed automatically if set to zero |
| uv_0 | the bottom left UV coordinate |
| uv_1 | the top left UV coordinate |
| uv_2 | the top right UV coordinate |
| uv_3 | the bottom right UV coordinate |
| double_sided | whether the image should be shown on both sides |
| transform | an optional transform |
| 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.
| start_points | defines N line start positions (and, optionally, the per-point colors) |
| end_points | defines N line end positions (and, optionally, the per-point colors) |
| color | if provided, will override any per-point colors stored in start_colors and end_colors. |
| transform | optional transform |
| 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.
| mesh_info | the positions, triangles and other elements of the mesh |
| transform | optional transform |
| reverse_triangle_order | whether to reverse the triangle winding order |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| vertices | matrix of N vertex positions |
| normals | matrix of N vertex normals |
| triangles | matrix of N triangle vertex indices |
| colors | optional matrix of N per-vertex RGB color vectors |
| uvs | optional matrix of N per-vertex UV coordinates |
| transform | optional transform |
| reverse_triangle_order | whether to reverse the triangle winding order |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| vertices | matrix of N vertex positions |
| triangles | matrix of N triangle vertex indices |
| colors | optional matrix of N per-vertex RGB color vectors |
| uvs | optional matrix of N per-vertex UV coordinates |
| transform | optional transform |
| reverse_triangle_order | whether to reverse the triangle winding order |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| pos0 | the first vertex |
| pos1 | the second vertex |
| pos2 | the third vertex |
| pos3 | the fourth vertex |
| normal | will be computed automatically if set to zero |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| transform | optional transform |
| uv_0 | optional first uv coordinate (for UV meshes) |
| uv_1 | optional second uv coordinate (for UV meshes) |
| uv_2 | optional third uv coordinate (for UV meshes) |
| uv_3 | optional fourth uv coordinate (for UV meshes) |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| transform | optional transform |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| start_point | the start point of the line |
| end_point | the end point of the line |
| start_thickness | the start thickness of the line |
| end_thickness | the end thickness of the line |
| transform | optional transform |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| pos0 | the first vertex |
| pos1 | the second vertex |
| pos2 | the third vertex |
| normal | will be computed automatically if set to zero |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| uv_0 | optional first uv coordinate (for UV meshes) |
| uv_1 | optional second uv coordinate (for UV meshes) |
| uv_2 | optional third uv coordinate (for UV meshes) |
| 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.
| color | required unless Mesh was constructed with shared_color argument. |
| transform | optional transform |
| lat_count | number of discrete samples in latitude |
| long_count | number of discrete samples in longitude |
| fill_triangles | whether to fill the primitive |
| add_wireframe | whether to add a wireframe outline |
| void scenepic::Mesh::append_mesh | ( | const Mesh & | mesh | ) |
Append another mesh object to this mesh.
| mesh | the mesh to append |
| 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.
| transform | a 3D homogeneous rotation matrix |
| 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.
| transform | a 3D homogeneous transform |
| 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).
| 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).
| Vector scenepic::Mesh::center_of_mass | ( | ) | const |
The mean of mesh vertex positions.
|
static |
Compute the vertex normals given a set of triangles and vertices.
| vertices | the vertex positions |
| triangles | the triangles defining the mesh |
| reverse_triangle_order | whether to reverse the triangle order when computing the normals. |
| std::uint32_t scenepic::Mesh::count_vertices | ( | ) | const |
The number of vertices in the mesh.
| bool scenepic::Mesh::double_sided | ( | ) | const |
Whether to turn off back face culling and draw the Mesh's triangles as double sided.
| Mesh & scenepic::Mesh::double_sided | ( | bool | double_sided | ) |
Whether to turn off back face culling and draw the Mesh's triangles as double sided.
| 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.
| positions | the positions of the N instances |
| colors | if provided, a per-instance color that overrides a Mesh's shared_color or per-vertex color |
| rotations | if provided, a per-instance quaternion rotation that rotates each instance |
| Mesh scenepic::Mesh::get_rotated | ( | const Transform & | transform | ) |
Get a rotated copy of this Mesh.
| transform | a 3D homogeneous rotation matrix |
| Mesh scenepic::Mesh::get_transformed | ( | const Transform & | transform | ) |
Get a transformed copy of this Mesh.
| transform | a 3D homogeneous transform |
| 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)
| 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.
| 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.
| bool scenepic::Mesh::is_label | ( | ) | const |
This mesh will be treated specially as a label.
Not for public use.
| Mesh & scenepic::Mesh::is_label | ( | bool | is_label | ) |
This mesh will be treated specially as a label.
Not for public use.
| 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().
| 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().
| const std::string & scenepic::Mesh::mesh_id | ( | ) | const |
A unique identifier for the Mesh.
| bool scenepic::Mesh::nn_texture | ( | ) | const |
Whether the shader should use nearest-neighbor texture interpolation.
| Mesh & scenepic::Mesh::nn_texture | ( | bool | nn_texture | ) |
Whether the shader should use nearest-neighbor texture interpolation.
| 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.
| const Color & scenepic::Mesh::shared_color | ( | ) | const |
Whole-mesh color (reduces memory requirements but makes Mesh monochrome).
Whole-mesh color (reduces memory requirements but makes Mesh monochrome).
| const std::string & scenepic::Mesh::texture_id | ( | ) | const |
| Mesh & scenepic::Mesh::texture_id | ( | const std::string & | texture_id | ) |
| JsonValue scenepic::Mesh::to_json | ( | ) | const |
Convert this mesh into ScenePic json.
| std::string scenepic::Mesh::to_string | ( | ) | const |
Return a JSON string representing the object.
| const ConstTriangleBufferRef scenepic::Mesh::triangles | ( | ) | const |
The triangles (i.e.
face vertex indices) defining the mesh
| bool scenepic::Mesh::use_texture_alpha | ( | ) | const |
Whether to use the alpha channel in the texture for transparency (only relevant for textured Meshes).
| 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).
| 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)
| VertexBlock scenepic::Mesh::vertex_colors | ( | ) |
Reference to the vertex colors.
| const ConstVertexBlock scenepic::Mesh::vertex_colors | ( | ) | const |
const Reference to the vertex colors.
| Mesh & scenepic::Mesh::vertex_colors | ( | const VertexBlock & | colors | ) |
Set the vertex colors.
| VertexBlock scenepic::Mesh::vertex_normals | ( | ) |
Reference to the vertex normals.
| const ConstVertexBlock scenepic::Mesh::vertex_normals | ( | ) | const |
const Reference to the vertex normals.
| Mesh & scenepic::Mesh::vertex_normals | ( | const VertexBlock & | normals | ) |
Set the vertex normals.
| VertexBlock scenepic::Mesh::vertex_positions | ( | ) |
Reference to the vertex positions.
| const ConstVertexBlock scenepic::Mesh::vertex_positions | ( | ) | const |
const Reference to the vertex positions.
| Mesh & scenepic::Mesh::vertex_positions | ( | const VertexBlock & | vertices | ) |
Set the vertex positions.
| VertexBlock scenepic::Mesh::vertex_uvs | ( | ) |
Reference to the vertex uvs.
| const ConstVertexBlock scenepic::Mesh::vertex_uvs | ( | ) | const |
const Reference to the vertex uvs.
| Mesh & scenepic::Mesh::vertex_uvs | ( | const VertexBlock & | uvs | ) |
Set the vertex uvs.
|
friend |