![]() |
Simulant
21.12-574
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
|
The MeshInstancer class. More...
#include <mesh_instancer.h>
Public Member Functions | |
MeshInstancer (Stage *stage, SoundDriver *sound_driver, MeshPtr mesh) | |
const AABB & | aabb () const override |
void | set_mesh (MeshPtr mesh) |
MeshPtr | mesh () const |
MeshInstanceID | new_mesh_instance (const smlt::Vec3 &position, const smlt::Quaternion &rotation=smlt::Quaternion()) |
bool | destroy_mesh_instance (MeshInstanceID mid) |
destroy_mesh_instance More... | |
bool | show_mesh_instance (MeshInstanceID mid) |
show_mesh_instance More... | |
bool | hide_mesh_instance (MeshInstanceID mid) |
hide_mesh_instance More... | |
void | _get_renderables (batcher::RenderQueue *render_queue, const CameraPtr camera, const DetailLevel detail_level) override |
![]() | |
TypedDestroyableObject (Stage *owner) | |
bool | destroy () override |
bool | destroy_immediately () override |
![]() | |
DEFINE_SIGNAL (DestroyedSignal, signal_destroyed) | |
bool | is_destroyed () const |
![]() | |
AncestorIteratorPair | each_ancestor () |
DescendentIteratorPair | each_descendent () |
SiblingIteratorPair | each_sibling () |
ChildIteratorPair | each_child () |
std::string | repr () const override |
StageNode (Stage *stage, StageNodeType node_type) | |
StageNodeType | node_type () const |
void | link_position (StageNode *other) |
void | move_to_absolute (const Vec3 &position) |
void | move_to_absolute (float x, float y, float z) |
void | rotate_to_absolute (const Quaternion &rotation) |
void | rotate_to_absolute (const Degrees °rees, float x, float y, float z) |
Vec3 | absolute_position () const |
Quaternion | absolute_rotation () const |
Vec3 | absolute_scaling () const |
Mat4 | absolute_transformation () const |
bool | is_visible () const |
bool | is_intended_visible () const |
void | set_visible (bool visible) |
template<typename T > | |
void | set_parent (const UniqueID< T > &id) |
void | set_parent (TreeNode *node) |
smlt::Promise< void > | destroy_after (const Seconds &seconds) |
void | update (float dt) override |
void | late_update (float dt) override |
void | fixed_update (float step) override |
bool | parent_is_stage () const |
void | clean_up () override |
const AABB | transformed_aabb () const override |
ShadowCast | shadow_cast () const |
void | set_shadow_cast (ShadowCast cast) |
ShadowReceive | shadow_receive () const |
void | set_shadow_receive (ShadowReceive receive) |
StageNode * | find_descendent_with_name (const std::string &name) |
void | set_cullable (bool v) |
bool | is_cullable () const |
UniqueIDKey | key () const |
![]() | |
void | set_parent (TreeNode *node) |
void | add_child (TreeNode *node) |
void | remove_from_parent () |
bool | is_root () const |
bool | is_leaf () const |
TreeNode * | parent () const |
uint32_t | child_count () const |
TreeNode * | first_child () const |
TreeNode * | next_node () const |
TreeNode * | previous_node () const |
TreeNode * | child_at (std::size_t i) const |
![]() | |
void | set_name (const std::string &name) |
const std::string & | name () const |
bool | has_name () const |
![]() | |
smlt::Vec3 | position () const |
smlt::Vec2 | position_2d () const |
smlt::Quaternion | rotation () const |
smlt::Vec3 | scale () const |
virtual void | move_to (const smlt::Vec3 &pos) |
virtual void | move_to (const smlt::Vec2 &pos) |
virtual void | move_to (float x, float y, float z) |
virtual void | move_to (float x, float y) |
virtual void | move_by (const smlt::Vec3 &pos) |
virtual void | move_by (const smlt::Vec2 &pos) |
virtual void | move_by (float x, float y, float z) |
virtual void | move_by (float x, float y) |
virtual void | move_forward_by (float amount) |
virtual void | move_right_by (float amount) |
virtual void | move_up_by (float amount) |
virtual void | rotate_to (const smlt::Degrees &angle, float axis_x, float axis_y, float axis_z) |
virtual void | rotate_to (const smlt::Degrees &angle, const smlt::Vec3 &axis) |
virtual void | rotate_to (const smlt::Quaternion &rotation) |
virtual void | rotate_x_by (const smlt::Degrees &angle) |
virtual void | rotate_y_by (const smlt::Degrees &angle) |
virtual void | rotate_z_by (const smlt::Degrees &angle) |
virtual void | rotate_by (const smlt::Degrees &angle_x, const smlt::Degrees &angle_y, const smlt::Degrees &angle_z) |
virtual void | rotate_by (const smlt::Vec3 &angles) |
virtual void | scale_x_by (const float scale) |
virtual void | scale_y_by (const float scale) |
virtual void | scale_z_by (const float scale) |
virtual void | scale_by (float x) |
virtual void | scale_by (const Vec3 &x) |
virtual void | scale_to (const float x, const float y, const float z) |
virtual void | rotate_around (const smlt::Vec3 &axis, const smlt::Degrees °rees) |
void | rotate_global_x_by (const smlt::Degrees °rees) |
void | rotate_global_y_by (const smlt::Degrees °rees) |
void | rotate_global_z_by (const smlt::Degrees °rees) |
virtual void | look_at (const smlt::Vec3 &target, const Vec3 &up=Vec3::POSITIVE_Y) |
virtual void | look_at (float x, float y, float z, const Vec3 &up=Vec3::POSITIVE_Y) |
Vec3 | right () const |
Vec3 | up () const |
Vec3 | forward () const |
void | constrain_to_aabb (const AABB ®ion) |
bool | is_constrained () const |
void | remove_constraint () |
![]() | |
virtual void | _update_thunk (float dt) |
virtual void | _late_update_thunk (float dt) |
virtual void | _fixed_update_thunk (float step) |
![]() | |
virtual const Vec3 | centre () const |
![]() | |
virtual float | width () const |
virtual float | height () const |
virtual float | depth () const |
virtual float | half_width () const |
virtual float | half_height () const |
virtual float | half_depth () const |
virtual float | diameter () const |
virtual float | radius () const |
![]() | |
template<typename T > | |
bool | has_behaviour () const |
template<typename T > | |
T * | behaviour () const |
template<typename T > | |
T * | new_behaviour () |
template<typename T , typename ... Params> | |
T * | new_behaviour (Params &&... params) |
void | fixed_update_behaviours (float step) |
void | update_behaviours (float dt) |
void | late_update_behaviours (float dt) |
![]() | |
uint64_t | auto_id () const |
![]() | |
virtual bool | init () |
![]() | |
Identifiable (MeshInstancerID id) | |
MeshInstancerID | id () const |
virtual bool | operator== (const Identifiable< MeshInstancerID > &rhs) const |
virtual bool | operator< (const Identifiable< MeshInstancerID > &rhs) const |
void | _bind_id_pointer (ResourceTypePtr ptr) |
void | _overwrite_id (MeshInstancerID new_id) |
![]() | |
AudioSource (Window *window) | |
AudioSource (Stage *stage, StageNode *this_as_node, SoundDriver *driver) | |
PlayingSoundPtr | play_sound (SoundPtr sound_id, AudioRepeat repeat=AUDIO_REPEAT_NONE, DistanceModel model=DISTANCE_MODEL_DEFAULT) |
bool | stop_sound (PlayingSoundID sound_id) |
uint8_t | playing_sound_count () const |
uint8_t | played_sound_count () const |
bool | is_sound_playing () const |
sig::signal< void()> & | signal_stream_finished () |
void | update_source (float dt) |
![]() | |
void | set_render_priority (RenderPriority priority) |
virtual RenderPriority | render_priority () const |
![]() | |
MeshInstancer * | set_name_and_get (const std::string &name) |
Additional Inherited Members | |
![]() | |
typedef MeshInstancerID | id_type |
![]() | |
static void | source_update_thread () |
![]() | |
friend | Owner |
![]() | |
Property< generic::DataCarrier StageNode::* > | data = { this, &StageNode::data_ } |
Property< Stage *StageNode::* > | stage = { this, &StageNode::stage_ } |
![]() | |
Stage * | stage_ = nullptr |
Window * | window_ = nullptr |
SoundDriver * | driver_ = nullptr |
StageNode * | node_ = nullptr |
std::list< PlayingSound::ptr > | instances_ |
sig::signal< void()> | signal_stream_finished_ |
thread::Mutex | mutex_ |
![]() | |
Stage * | get_stage () const |
void | on_transformation_changed () override |
void | on_parent_set (TreeNode *oldp, TreeNode *newp) override |
virtual void | update_transformation_from_parent () |
void | recalc_bounds_if_necessary () const |
void | mark_transformed_aabb_dirty () |
void | mark_absolute_transformation_dirty () |
![]() | |
TreeNode * | detach () |
TreeNode * | last_child () const |
![]() | |
void | set_position (const Vec3 &p) |
void | set_rotation (const Quaternion &q) |
void | set_scaling (const Vec3 &s) |
virtual void | on_transformation_change_attempted () |
![]() | |
SoundDriver * | _sound_driver () const |
![]() | |
bool | destroyed_ = false |
![]() | |
TreeNode * | root_ = nullptr |
TreeNode * | parent_ = nullptr |
TreeNode * | first_child_ = nullptr |
TreeNode * | prev_ = this |
TreeNode * | next_ = this |
![]() | |
Vec3 | position_ |
Quaternion | rotation_ |
Vec3 | scaling_ = Vec3(1, 1, 1) |
std::unique_ptr< AABB > | constraint_ |
The MeshInstancer class.
A MeshInstancer is the most basic way to include a mesh in a scene. It's designed as a lightweight way to create multiple instances of the same mesh in different locations.
Instantiated meshes do not form part of the stage hierarchy, they are not a StageNode, and are not directly accessible but they do behave as if they are a child of the MeshInstancer in that they are rotated and transformed relative to the MeshInstancer.
You can swap the Mesh associated with a MeshInstancer, and all instances will change immediately. You can also toggle the visibility of an individual instance, or remove an instance.
The bounds of a MeshInstancer are the sum bounds of all its instances.
Spawning animated meshes is currently unsupported.
bool smlt::MeshInstancer::destroy_mesh_instance | ( | MeshInstanceID | mid | ) |
destroy_mesh_instance
mid | The MeshInstanceID to destroy |
bool smlt::MeshInstancer::hide_mesh_instance | ( | MeshInstanceID | mid | ) |
hide_mesh_instance
mid | - The MeshInstanceID to hide |
MeshInstanceID smlt::MeshInstancer::new_mesh_instance | ( | const smlt::Vec3 & | position, |
const smlt::Quaternion & | rotation = smlt::Quaternion() |
||
) |
Create a new mesh_instance at the specified location. Returns a new non-zero MeshInstanceID on success. Returns 0 on failure.
bool smlt::MeshInstancer::show_mesh_instance | ( | MeshInstanceID | mid | ) |
show_mesh_instance
mid | - The MeshInstanceID to show |