![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <Drawable.hpp>
Classes | |
struct | Attribute |
struct | ProjectionInfo |
Public Types | |
enum | Flag : uint32 { ReceiveLights = 1, ReceiveShadows = 1 << 1, CastShadows = 1 << 2, Reflected = 1 << 3 } |
Public Member Functions | |
Drawable (Object &object, Renderer &renderer, const RenderPass::Pass pass=RenderPass::Pass::BeforePost, const bool cull=true) | |
Constructor. More... | |
Drawable (Object &object, RenderPass &pass, const bool cull=true) | |
Overloaded constructor. More... | |
virtual | ~Drawable () override |
Virtual destructor. More... | |
virtual void | draw (const ProjectionInfo &proj, const LightContainer &lights) const |
Draw function. More... | |
Renderer & | getRendrer () |
Get the renderer this drawable is bound to. More... | |
const Renderer & | getRenderer () const |
Get the renderer this drawable is bound to. More... | |
Drawable & | setRenderGroup (const uint8 group) |
Set the render group. More... | |
uint8 | getRenderGroup () const |
Get the render group. More... | |
Drawable & | setModel (const Model &model) |
Set the model. More... | |
Model & | getModel () |
Get the model. More... | |
const Model & | getModel () const |
Get the model. More... | |
Drawable & | setColor (const Color &color) |
Set the color. More... | |
const Color & | getColor () const |
Get the color. More... | |
const std::pair< glm::vec3, glm::vec3 > & | getLocalBounds () const |
Get the local bounds. More... | |
std::pair< glm::vec3, glm::vec3 > | getGlobalBounds () const |
Get the global bounds. More... | |
Drawable & | setFlags (const uint32 flags) |
Set flags. More... | |
bool | hasFlag (const uint32 flag) const |
Check if this drawable has a flag. More... | |
ShaderProgram & | getShader () const |
Get the current shader. More... | |
void | setOverrideShader (ShaderProgram &shader) |
Set an override shader. More... | |
void | removeOverrideShader () |
Remove the override shader if one is bound. More... | |
bool | hasOverrideShader () const |
Check if using an override shader. More... | |
uint64 | getAttributes () const |
Get the internal attribute field. More... | |
![]() | |
PhantomBody (Object &object, World &world, CollisionShape &shape, const bool attachToWorld) | |
Constructor. More... | |
virtual | ~PhantomBody () override |
void | update (const float deltaTime) override |
Update function. More... | |
std::vector< Collider * > | getOverlaps () |
Get all the overlapping colliders. More... | |
std::vector< const Collider * > | getOverlaps () const |
Get all the overlapping colliders. More... | |
unsigned int | getOverlapAmount () const |
Get the number of overlapping colliders. More... | |
![]() | |
bool | checkOverlap (const Collider &other) const |
Check if this collider overlaps with another. More... | |
bool | checkContact (const Collider &other) const |
Check if this collider is in contact with another. More... | |
bool | checkRay (const glm::vec3 &start, const glm::vec3 &ray) const |
Check if a ray pierces this collider. More... | |
void | registerListener (ContactListener &listener) |
Register a listener for this collider. More... | |
World & | getWorld () |
Get the world this collider belongs to. More... | |
const World & | getWorld () const |
Get the world this collider belongs to. More... | |
void | detachFromWorld () |
Detach this body from its world. More... | |
void | attachToWorld () |
Attach this body to its world if it was previously detached. More... | |
bool | isDetachedFromWorld () const |
Check if this body is currently detached from its world. More... | |
void | updateWorldBounds () |
Force update of the world space bounds. More... | |
void | setCollisionShape (CollisionShape &shape) |
Set the collision shape. More... | |
const CollisionShape * | getCollisionShape () const |
Get the collision shape. More... | |
![]() | |
virtual | ~Component ()=0 |
Virtual destructor. More... | |
Message::Result | sendMessage (const Message &message) |
Send a message to this component. More... | |
uint32 | getID () const |
Get the identifier. More... | |
void | setID (const uint32 ID) |
Set the identifier. More... | |
WeakReference< Object > | getObject () |
Get the object this component is bound to. More... | |
WeakReference< const Object > | getObject () const |
Get the object this component is bound to. More... | |
bool | isActive () const |
Check if this component is active. More... | |
void | removeSelf () |
Remove this component from its object. More... | |
![]() | |
WeakReference< Collider > | getReference () const |
Get a weak reference to the bound object. More... | |
Protected Member Functions | |
JOP_GENERIC_COMPONENT_CLONE (Drawable) | |
virtual Message::Result | receiveMessage (const Message &message) override |
Receive a message. More... | |
![]() | |
JOP_GENERIC_COMPONENT_CLONE (CullerComponent) | |
CullerComponent (Object &object, World &world, const Type type, const bool attach) | |
![]() | |
JOP_GENERIC_COMPONENT_CLONE (PhantomBody) | |
![]() | |
Collider (Object &object, World &world, const uint32 ID) | |
Constructor. More... | |
Collider (const Collider &other, Object &newObj) | |
Copy constructor. More... | |
virtual | ~Collider () override=0 |
Virtual destructor. More... | |
void | setAllowSleep (const bool allow) |
Set whether the collider is allowed to sleep. More... | |
bool | isSleepAllowed () const |
Check if sleep is allowed. More... | |
![]() | |
Component (Object &object, const uint32 ID) | |
Constructor. More... | |
Component (const Component &other, Object &newObj) | |
Copy constructor. More... | |
![]() | |
SafeReferenceable (Collider *ref) | |
Constructor. More... | |
SafeReferenceable (SafeReferenceable< Collider > &&other) | |
Move constructor. More... | |
SafeReferenceable & | operator= (SafeReferenceable< Collider > &&other) |
Move assignment operator. More... | |
~SafeReferenceable () | |
Protected destructor. More... | |
Protected Attributes | |
uint64 | m_attributes |
Attribute flags. More... | |
![]() | |
std::unique_ptr< btCollisionObject > | m_body |
Body data. More... | |
World & | m_worldRef |
Reference to the world. More... | |
std::set< ContactListener * > | m_listeners |
Listeners registered for this collider. More... | |
bool | m_detached |
Is this body detached from the world? More... | |
bool | m_allowSleep |
Is sleep allowed? More... | |
Friends | |
class | ShaderAssembler |
Additional Inherited Members | |
![]() | |
enum | Type { Type::Drawable, Type::Camera, Type::LightSource, Type::EnvironmentRecorder } |
Definition at line 48 of file Drawable.hpp.
enum jop::Drawable::Flag : uint32 |
Drawable flags
Enumerator | |
---|---|
ReceiveLights |
Receive lights? |
ReceiveShadows |
Receive shadows? |
CastShadows |
Cast shadows? |
Reflected |
Reflect on dynamic environment maps? |
Definition at line 60 of file Drawable.hpp.
jop::Drawable::Drawable | ( | Object & | object, |
Renderer & | renderer, | ||
const RenderPass::Pass | pass = RenderPass::Pass::BeforePost , |
||
const bool | cull = true |
||
) |
Constructor.
object | Reference to the object this drawable will be bound to |
renderer | Reference to the renderer |
cull | Should this drawable be culled? |
pass | The render pass |
jop::Drawable::Drawable | ( | Object & | object, |
RenderPass & | pass, | ||
const bool | cull = true |
||
) |
Overloaded constructor.
object | Reference to the object this drawable will be bound to |
pass | The render pass to bind this drawable into |
cull | Should this drawable be culled? |
|
overridevirtual |
Virtual destructor.
|
virtual |
Draw function.
proj | The projection info |
lights | The light container |
Reimplemented in jop::World, jop::World2D, jop::SkySphere, jop::SkyBox, and jop::Sprite.
uint64 jop::Drawable::getAttributes | ( | ) | const |
Get the internal attribute field.
This is for internal use only.
const Color& jop::Drawable::getColor | ( | ) | const |
std::pair<glm::vec3, glm::vec3> jop::Drawable::getGlobalBounds | ( | ) | const |
Get the global bounds.
This will apply the current transformation to the local bounds and then return them.
const std::pair<glm::vec3, glm::vec3>& jop::Drawable::getLocalBounds | ( | ) | const |
Get the local bounds.
This is the same as calling getModel().getMesh()->getBounds().
Model& jop::Drawable::getModel | ( | ) |
Get the model.
const Model& jop::Drawable::getModel | ( | ) | const |
Get the model.
const Renderer& jop::Drawable::getRenderer | ( | ) | const |
Get the renderer this drawable is bound to.
uint8 jop::Drawable::getRenderGroup | ( | ) | const |
Get the render group.
Renderer& jop::Drawable::getRendrer | ( | ) |
Get the renderer this drawable is bound to.
ShaderProgram& jop::Drawable::getShader | ( | ) | const |
Get the current shader.
bool jop::Drawable::hasFlag | ( | const uint32 | flag | ) | const |
Check if this drawable has a flag.
flag | The flag to check |
bool jop::Drawable::hasOverrideShader | ( | ) | const |
Check if using an override shader.
|
protected |
|
overrideprotectedvirtual |
Receive a message.
Override this to handle messages sent to this. Don't forget to call the base class' method as well to ensure that the message gets forwarded correctly.
message | The message |
Reimplemented from jop::Component.
Reimplemented in jop::World.
void jop::Drawable::removeOverrideShader | ( | ) |
Remove the override shader if one is bound.
Set the color.
This sets the drawable-specific color to be used as a base. If the bound material has a texture, the color will be used as a multiplier. The default color is white with an alpha of 1.
color | The color to set |
Set the model.
The model will be copied.
model | Reference to the model |
void jop::Drawable::setOverrideShader | ( | ShaderProgram & | shader | ) |
Set the render group.
The value will be clamped between 0 and 31.
group | The new group to set |
|
friend |
Definition at line 54 of file Drawable.hpp.
|
protected |
Attribute flags.
Definition at line 276 of file Drawable.hpp.