21 #include <engine/config.hpp>
46 constexpr
float billboard_vertex_data[] =
48 -1.0f, 1.0f, 0.0f, 1.0f,
49 -1.0f, -1.0f, 0.0f, 0.0f,
50 1.0f, 1.0f, 1.0f, 1.0f,
51 1.0f, -1.0f, 1.0f, 0.0f
54 constexpr std::size_t billboard_vertex_stride = 4 *
sizeof(float);
60 m_vertex_array = std::make_unique<gl::vertex_array>(billboard_vertex_attributes);
63 m_vertex_buffer = std::make_unique<gl::vertex_buffer>
66 std::as_bytes(std::span{billboard_vertex_data})
84 switch (m_billboard_type)
92 m_render_op.
transform = transform.matrix();
107 m_render_op.
transform = transform.matrix();
132 m_billboard_type =
type;
140 void billboard::transformed()
void render(render::context &ctx) const override
Adds render operations to a render context.
void set_billboard_type(billboard_type type)
Sets the billboard type.
billboard()
Constructs a billboard.
void set_material(std::shared_ptr< render::material > material)
Sets the billboard material.
constexpr const math::fvec3 & get_up() const noexcept
Returns the camera's up vector.
constexpr const math::fvec3 & get_forward() const noexcept
Returns the camera's forward vector.
constexpr const view_frustum_type & get_view_frustum() const noexcept
Returns the camera's view frustum.
constexpr std::uint32_t get_layer_mask() const noexcept
Returns the layer mask of the object.
constexpr const vector_type & get_translation() const noexcept
Returns the translation of the object.
constexpr const vector_type & get_scale() const noexcept
Returns the scale of the object.
constexpr const transform_type & get_transform() const noexcept
Returns the transform of the object.
math::vec3< T > project_on_plane(const math::vec3< T > &v, const math::vec3< T > &p, const math::vec3< T > &n)
@ static_draw
Data will be modified once, by the application, and used many times, for drawing commands.
@ triangle_strip
Connected triangle primitives with consecutive triangles sharing an edge.
quaternion< T > normalize(const quaternion< T > &q)
Normalizes a quaternion.
quaternion< T > look_rotation(const vec3< T > &forward, vec3< T > up)
Creates a unit quaternion rotation using forward and up vectors.
constexpr vector< T, 3 > cross(const vector< T, 3 > &x, const vector< T, 3 > &y) noexcept
Calculates the cross product of two vectors.
@ uv
Vertex UV texture coordinates (vec2)
@ position
Vertex position (vec3)
billboard_type
Billboard types.
@ flat
Billboard is unaligned.
@ spherical
Billboard aligns to face camera.
@ cylindrical
Billboard rotates about an alignment axis to face camera.
constexpr T distance(const vector_type &point) const noexcept
Calculates the signed distance from the hyperplane to a point.
constexpr const plane_type & near() const noexcept
Returns the near clipping plane.
const scene::camera * camera
Pointer to the camera.
std::vector< const operation * > operations
Render operations generated by visible objects.
std::uint32_t vertex_count
std::uint32_t instance_count
std::size_t vertex_offset
std::size_t vertex_stride
std::uint32_t first_instance
gl::primitive_topology primitive_topology
std::uint32_t first_vertex
const gl::vertex_buffer * vertex_buffer
std::shared_ptr< render::material > material
const gl::vertex_array * vertex_array