Aether3D Game Engine
SpriteRendererComponent.hpp
1 #ifndef SPRITE_RENDERER_COMPONENT_H
2 #define SPRITE_RENDERER_COMPONENT_H
3 
4 #include <type_traits>
5 #include <string>
6 
7 namespace ae3d
8 {
11  {
12  public:
15 
18 
21 
24 
26  class GameObject* GetGameObject() const { return gameObject; }
27 
29  std::string GetSerialized() const;
30 
32  void Clear();
33 
45  void SetTexture( class TextureBase* texture, const struct Vec3& position, const Vec3& dimensionPixels, const struct Vec4& tintColor );
46 
47  private:
48  friend class GameObject;
49  friend class Scene;
50 
51  /* \return Component's type code. Must be unique for each component type. */
52  static int Type() { return 1; }
53 
54  /* \return Component handle that uniquely identifies the instance. */
55  static unsigned New();
56 
57  /* \return Component at index or null if index is invalid. */
58  static SpriteRendererComponent* Get( unsigned index );
59 
60  /* \param projectionModelMatrix Projection and model matrix combined. */
61  void Render( const float* projectionModelMatrix );
62 
63  struct Impl;
64  Impl& m() { return reinterpret_cast<Impl&>(_storage); }
65  Impl const& m() const { return reinterpret_cast<Impl const&>(_storage); }
66 
67  static const std::size_t StorageSize = 1384;
68  static const std::size_t StorageAlign = 16;
69 
70  std::aligned_storage<StorageSize, StorageAlign>::type _storage = {};
71 
72  GameObject* gameObject = nullptr;
73  };
74 }
75 #endif
SpriteRendererComponent()
Constructor.
Definition: AudioClip.hpp:4
4-component vector.
Definition: Vec3.hpp:351
void Clear()
Removes all textures that were added using SetTexture.
std::string GetSerialized() const
3-component vector.
Definition: Vec3.hpp:12
~SpriteRendererComponent()
Destructor.
GameObject is composed of components that define its behavior.
Definition: GameObject.hpp:9
class GameObject * GetGameObject() const
Definition: SpriteRendererComponent.hpp:26
SpriteRendererComponent & operator=(const SpriteRendererComponent &other)
Renders sprites.
Definition: SpriteRendererComponent.hpp:10
void SetTexture(class TextureBase *texture, const struct Vec3 &position, const Vec3 &dimensionPixels, const struct Vec4 &tintColor)
Contains game objects in a transform hierarchy.
Definition: Scene.hpp:17
Base class for textures.
Definition: TextureBase.hpp:54