4#ifndef _SCENEPIC_MESH_H_
5#define _SCENEPIC_MESH_H_
109 const Vector& pos0 = Vector(0, 0, 0),
110 const Vector& pos1 = Vector(1, 0, 0),
111 const Vector& pos2 = Vector(0, 1, 0),
112 const Vector& normal = VectorNone(),
113 bool fill_triangles =
true,
114 bool add_wireframe =
false,
115 const UV& uv_0 = UV(0, 0),
116 const UV& uv_1 = UV(1, 0),
117 const UV& uv_2 = UV(0, 1));
138 const Vector& pos0 = Vector(0, -0.5f, -0.5f),
139 const Vector& pos1 = Vector(0, +0.5f, -0.5f),
140 const Vector& pos2 = Vector(0, +0.5f, +0.5f),
141 const Vector& pos3 = Vector(0, -0.5f, +0.5f),
142 const Vector& normal = VectorNone(),
143 bool fill_triangles =
true,
144 bool add_wireframe =
false,
145 const Transform& transform = Transform::Identity(),
146 const UV& uv_0 = UV(0, 0),
147 const UV& uv_1 = UV(1, 0),
148 const UV& uv_2 = UV(1, 1),
149 const UV& uv_3 = UV(0, 1));
167 const Vector& origin = Vector(-0.5f, -0.5f, 0),
168 const Vector& x_axis = Vector(1, 0, 0),
169 const Vector& y_axis = Vector(0, 1, 0),
170 const Vector& normal = VectorNone(),
171 const UV& uv_0 = UV(0, 0),
172 const UV& uv_1 = UV(1, 0),
173 const UV& uv_2 = UV(1, 1),
174 const UV& uv_3 = UV(0, 1),
176 const Transform& transform = Transform::Identity());
187 const Transform& transform = Transform::Identity(),
188 bool fill_triangles =
true,
189 bool add_wireframe =
false);
204 const Vector& start_point = Vector(-0.5, 0, 0),
205 const Vector& end_point = Vector(0.5, 0, 0),
206 float start_thickness = 0.1f,
207 float end_thickness = 0.1f,
208 const Transform& transform = Transform::Identity(),
209 bool fill_triangles =
true,
210 bool add_wireframe =
false);
225 const Transform& transform = Transform::Identity(),
226 float truncation_height = 1,
227 std::uint32_t lat_count = 10,
228 std::uint32_t long_count = 10,
229 bool fill_triangles =
true,
230 bool add_wireframe =
false);
239 float thickness = 0.1f,
240 const Transform& transform = Transform::Identity());
253 float fov_y_degrees = 45.0f,
254 float aspect_ratio = 16.0f / 9.0f,
256 float thickness = 0.02f,
257 const Transform& transform = Transform::Identity());
269 float thickness = 0.02f,
288 const Transform& transform = Transform::Identity(),
289 std::uint32_t segment_count = 10,
290 bool fill_triangles =
true,
291 bool add_wireframe =
false);
303 const Transform& transform = Transform::Identity(),
304 std::uint32_t segment_count = 10,
305 bool fill_triangles =
true,
306 bool add_wireframe =
false);
317 const Transform& transform = Transform::Identity(),
318 bool fill_triangles =
true,
319 bool add_wireframe =
false);
332 const Transform& transform = Transform::Identity(),
333 std::uint32_t steps = 0,
334 bool fill_triangles =
true,
335 bool add_wireframe =
false);
350 const Transform& transform = Transform::Identity(),
351 std::uint32_t lat_count = 10,
352 std::uint32_t long_count = 10,
353 bool fill_triangles =
true,
354 bool add_wireframe =
false);
369 const ConstVectorBufferRef& vertices,
371 const ConstColorBufferRef& colors = ColorBufferNone(),
372 const ConstUVBufferRef& uvs = UVBufferNone(),
373 const Transform& transform = Transform::Identity(),
375 bool fill_triangles =
true,
376 bool add_wireframe =
false);
387 const ConstVectorBufferRef& vertices,
404 const ConstVectorBufferRef& vertices,
405 const ConstVectorBufferRef& normals,
407 const ConstColorBufferRef& colors = ColorBufferNone(),
408 const ConstUVBufferRef& uvs = UVBufferNone(),
409 const Transform& transform = Transform::Identity(),
411 bool fill_triangles =
true,
412 bool add_wireframe =
false);
424 const std::shared_ptr<MeshInfo>& mesh_info,
425 const Transform& transform = Transform::Identity(),
427 bool fill_triangles =
true,
428 bool add_wireframe =
false);
440 const ConstVertexBufferRef& start_points,
441 const ConstVertexBufferRef& end_points,
443 const Transform& transform = Transform::Identity());
455 const ConstVectorBufferRef& positions,
456 const ConstQuaternionBufferRef& rotations = QuaternionBufferNone(),
457 const ConstColorBufferRef& colors = ColorBufferNone());
630 bool is_instanced()
const;
631 void check_instances();
632 void check_color(
const Color& color);
634 append_vertex(
const Vector& pos,
const Vector& normal,
const Color& color);
636 append_vertex(
const Vector& pos,
const Vector& normal, UV texture_uv);
637 std::uint32_t append_vertex(
const Vector& pos,
const Vector& normal);
638 void append_triangle(
639 std::uint32_t index0, std::uint32_t index1, std::uint32_t index2);
640 void append_line(std::uint32_t index0, std::uint32_t index1);
643 VertexBuffer m_vertices;
644 TriangleBuffer m_triangles;
646 Color m_shared_color;
647 std::string m_texture_id;
648 std::string m_mesh_id;
649 std::string m_layer_id;
653 bool m_use_texture_alpha;
657 InstanceBuffer m_instance_buffer;
658 bool m_instance_buffer_has_rotations;
659 bool m_instance_buffer_has_colors;
A camera type.
Definition: camera.h:15
Class for representing color values.
Definition: color.h:19
static const Color None()
Constant value indicating "no color".
Representation of a JSON value according to the specification at https://www.json....
Definition: json_value.h:30
The basic ScenePic mesh class, containing vertex, triangle, and line buffers.
Definition: mesh.h:38
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.
bool is_label() const
This mesh will be treated specially as a label.
Mesh & camera_space(bool camera_space)
Whether this Mesh is defined in camera space (cannot be moved in the ScenePic user interface) or worl...
bool is_billboard() const
Draw this Mesh as a billboard (i.e.
Mesh(const Color &shared_color=Color::None(), const std::string &texture_id="")
Constructor.
const ConstVertexBlock vertex_uvs() const
const Reference to the vertex uvs.
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.
void enable_instancing(const ConstVectorBufferRef &positions, const ConstQuaternionBufferRef &rotations=QuaternionBufferNone(), const ConstColorBufferRef &colors=ColorBufferNone())
Makes ScenePic render this Mesh with multiple instances, e.g.
Vector center_of_mass() const
The mean of mesh vertex positions.
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.
JsonValue to_json() const
Convert this mesh into ScenePic json.
Mesh & is_label(bool is_label)
This mesh will be treated specially as a label.
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.
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.
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.
const ConstVertexBlock vertex_normals() const
const Reference to the vertex normals.
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.
Mesh get_transformed(const Transform &transform)
Get a transformed copy of this Mesh.
void reverse_triangle_order()
Reverses the winding order of all triangles in this mesh.
Mesh & vertex_uvs(const VertexBlock &uvs)
Set the vertex uvs.
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.
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.
Mesh & vertex_positions(const VertexBlock &vertices)
Set the vertex positions.
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.
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.
InstanceBufferRef instance_buffer()
References to the instance buffer.
const std::string & layer_id() const
An identifier to allow several Meshes to be grouped together into a "layer".
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.
Mesh get_rotated(const Transform &transform)
Get a rotated copy of this Mesh.
VertexBlock vertex_positions()
Reference to the vertex positions.
std::uint32_t count_vertices() const
The number of vertices in the mesh.
Mesh & texture_id(const std::string &texture_id)
Specifies the id of a ScenePic Image to be used as a texture in this Mesh.
const ConstVertexBlock vertex_colors() const
const Reference to the vertex colors.
void apply_transform(const Transform &transform)
Apply a 3D homogeneous matrix transform (i.e.
const std::string & texture_id() const
Specifies the id of a ScenePic Image to be used as a texture in this Mesh.
Mesh & double_sided(bool double_sided)
Whether to turn off back face culling and draw the Mesh's triangles as double sided.
VertexBlock vertex_uvs()
Reference to the vertex uvs.
Mesh & use_texture_alpha(bool use_texture_alpha)
Whether to use the alpha channel in the texture for transparency (only relevant for textured Meshes).
Mesh & is_billboard(bool is_billboard)
Draw this Mesh as a billboard (i.e.
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.
bool camera_space() const
Whether this Mesh is defined in camera space (cannot be moved in the ScenePic user interface) or worl...
const std::string & mesh_id() const
A unique identifier for the Mesh.
bool double_sided() const
Whether to turn off back face culling and draw the Mesh's triangles as double sided.
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.
Mesh & nn_texture(bool nn_texture)
Whether the shader should use nearest-neighbor texture interpolation.
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.
VertexBufferRef vertex_buffer()
Reference to the vertex buffer.
const Color & shared_color() const
Whole-mesh color (reduces memory requirements but makes Mesh monochrome).
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.
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.
void apply_rotation(const Transform &transform)
Apply a 3D homogeneous matrix rotation (i.e.
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.
VertexBlock vertex_normals()
Reference to the vertex normals.
void append_mesh(const Mesh &mesh)
Append another mesh object to this mesh.
std::string to_string() const
Return a JSON string representing the object.
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.
VertexBlock vertex_colors()
Reference to the vertex colors.
Mesh & shared_color(const Color &shared_color)
Whole-mesh color (reduces memory requirements but makes Mesh monochrome).
void add_camera_image(const Camera &camera, float depth=1.0f)
Add the image plane for a camera into the scene.
Mesh & vertex_colors(const VertexBlock &colors)
Set the vertex colors.
Mesh & layer_id(const std::string &layer_id)
An identifier to allow several Meshes to be grouped together into a "layer".
bool nn_texture() const
Whether the shader should use nearest-neighbor texture interpolation.
const ConstTriangleBufferRef triangles() const
The triangles (i.e.
Mesh & vertex_normals(const VertexBlock &normals)
Set the vertex normals.
bool use_texture_alpha() const
Whether to use the alpha channel in the texture for transparency (only relevant for textured Meshes).
const ConstVertexBlock vertex_positions() const
const Reference to the vertex positions.
Top level container representing an entire ScenePic.
Definition: scene.h:58
Definition: audio_track.h:14