Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
jop::World Class Reference

#include <World.hpp>

Inheritance diagram for jop::World:
jop::Drawable jop::CullerComponent jop::PhantomBody jop::Collider jop::Component jop::SafeReferenceable< Collider >

Classes

struct  BroadphaseCallback
 

Public Member Functions

 World (Object &obj, Renderer &renderer)
 Constructor. More...
 
 ~World () override
 Destructor. More...
 
void update (const float deltaTime) override
 Update the world. More...
 
void draw (const ProjectionInfo &proj, const LightContainer &lights) const override
 Debug draw the world. More...
 
RayInfo checkRayClosest (const glm::vec3 &start, const glm::vec3 &ray, const short group=1, const short mask=32767) const
 Check if a ray hits a collider and return the closest one. More...
 
std::vector< RayInfocheckRayAllHits (const glm::vec3 &start, const glm::vec3 &ray, const short group=1, const short mask=32767) const
 Check if a ray hits a collider and return all hits. More...
 
std::vector< Collider * > checkOverlapAll (const glm::vec3 &aabbStart, const glm::vec3 &aabbEnd, const short group=1, const short mask=32767) const
 Get all the colliders that overlap with the bounding box. More...
 
void setDebugMode (const bool enable)
 Enable/disable debug drawing. More...
 
bool debugMode () const
 Check if debug drawing is enabled. More...
 
void setGravity (const glm::vec3 &gravity)
 Set gravity for world. More...
 
glm::vec3 getGravity () const
 Get gravity for world. More...
 
void setBroadphaseBallback (const BroadphaseCallback &callback)
 Set the broad phase callback. More...
 
void setDefaultBroadphaseCallback ()
 Restore the default broad phase callback. More...
 
- Public Member Functions inherited from jop::Drawable
 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...
 
RenderergetRendrer ()
 Get the renderer this drawable is bound to. More...
 
const RenderergetRenderer () const
 Get the renderer this drawable is bound to. More...
 
DrawablesetRenderGroup (const uint8 group)
 Set the render group. More...
 
uint8 getRenderGroup () const
 Get the render group. More...
 
DrawablesetModel (const Model &model)
 Set the model. More...
 
ModelgetModel ()
 Get the model. More...
 
const ModelgetModel () const
 Get the model. More...
 
DrawablesetColor (const Color &color)
 Set the color. More...
 
const ColorgetColor () 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...
 
DrawablesetFlags (const uint32 flags)
 Set flags. More...
 
bool hasFlag (const uint32 flag) const
 Check if this drawable has a flag. More...
 
ShaderProgramgetShader () 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...
 
- Public Member Functions inherited from jop::PhantomBody
 PhantomBody (Object &object, World &world, CollisionShape &shape, const bool attachToWorld)
 Constructor. More...
 
virtual ~PhantomBody () override
 
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...
 
- Public Member Functions inherited from jop::Collider
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...
 
WorldgetWorld ()
 Get the world this collider belongs to. More...
 
const WorldgetWorld () 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 CollisionShapegetCollisionShape () const
 Get the collision shape. More...
 
- Public Member Functions inherited from jop::Component
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< ObjectgetObject ()
 Get the object this component is bound to. More...
 
WeakReference< const ObjectgetObject () 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...
 
- Public Member Functions inherited from jop::SafeReferenceable< Collider >
WeakReference< CollidergetReference () const
 Get a weak reference to the bound object. More...
 

Protected Member Functions

Message::Result receiveMessage (const Message &message) override
 Receive a message. More...
 
- Protected Member Functions inherited from jop::Drawable
 JOP_GENERIC_COMPONENT_CLONE (Drawable)
 
- Protected Member Functions inherited from jop::CullerComponent
 JOP_GENERIC_COMPONENT_CLONE (CullerComponent)
 
 CullerComponent (Object &object, World &world, const Type type, const bool attach)
 
- Protected Member Functions inherited from jop::PhantomBody
 JOP_GENERIC_COMPONENT_CLONE (PhantomBody)
 
- Protected Member Functions inherited from jop::Collider
 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...
 
- Protected Member Functions inherited from jop::Component
 Component (Object &object, const uint32 ID)
 Constructor. More...
 
 Component (const Component &other, Object &newObj)
 Copy constructor. More...
 
- Protected Member Functions inherited from jop::SafeReferenceable< Collider >
 SafeReferenceable (Collider *ref)
 Constructor. More...
 
 SafeReferenceable (SafeReferenceable< Collider > &&other)
 Move constructor. More...
 
SafeReferenceableoperator= (SafeReferenceable< Collider > &&other)
 Move assignment operator. More...
 
 ~SafeReferenceable ()
 Protected destructor. More...
 

Protected Attributes

std::unique_ptr< detail::WorldImpl > m_worldData
 The world data. More...
 
std::unique_ptr< detail::GhostCallback > m_ghostCallback
 Internal ghost callback. More...
 
std::unique_ptr< detail::ContactListenerImpl > m_contactListener
 Contact listener implementation. More...
 
std::unique_ptr< detail::BroadPhaseCallback > m_bpCallback
 Broad phase callback. More...
 
- Protected Attributes inherited from jop::Drawable
uint64 m_attributes
 Attribute flags. More...
 
- Protected Attributes inherited from jop::Collider
std::unique_ptr< btCollisionObject > m_body
 Body data. More...
 
Worldm_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 Collider
 
class Joint
 
class Renderer
 
class RigidBody
 
class PhantomBody
 

Additional Inherited Members

- Public Types inherited from jop::Drawable
enum  Flag : uint32 { ReceiveLights = 1, ReceiveShadows = 1 << 1, CastShadows = 1 << 2, Reflected = 1 << 3 }
 
- Protected Types inherited from jop::CullerComponent
enum  Type { Type::Drawable, Type::Camera, Type::LightSource, Type::EnvironmentRecorder }
 

Detailed Description

Definition at line 47 of file World.hpp.

Constructor & Destructor Documentation

jop::World::World ( Object obj,
Renderer renderer 
)

Constructor.

Parameters
objThe object to bind this world into
rendererReference to the renderer, needed for debug drawing
jop::World::~World ( )
override

Destructor.

Member Function Documentation

std::vector<Collider*> jop::World::checkOverlapAll ( const glm::vec3 &  aabbStart,
const glm::vec3 &  aabbEnd,
const short  group = 1,
const short  mask = 32767 
) const

Get all the colliders that overlap with the bounding box.

Parameters
aabbStartStarting point of the bounding box
aabbEndEnding point of the bounding box
groupThe collision group
maskThe collision mask
Returns
Vector of colliders, empty if none were overlapping
std::vector<RayInfo> jop::World::checkRayAllHits ( const glm::vec3 &  start,
const glm::vec3 &  ray,
const short  group = 1,
const short  mask = 32767 
) const

Check if a ray hits a collider and return all hits.

Parameters
startThe start position of the ray
rayRay to be shot from start
groupThe collision group
maskThe collision mask
Returns
Vector of ray infos, empty if none were hit
RayInfo jop::World::checkRayClosest ( const glm::vec3 &  start,
const glm::vec3 &  ray,
const short  group = 1,
const short  mask = 32767 
) const

Check if a ray hits a collider and return the closest one.

Parameters
startThe start position of the ray
rayRay to be shot from start
groupThe collision group
maskThe collision mask
Returns
Ray hit info
bool jop::World::debugMode ( ) const

Check if debug drawing is enabled.

Returns
True if enabled
void jop::World::draw ( const ProjectionInfo proj,
const LightContainer lights 
) const
overridevirtual

Debug draw the world.

Parameters
projThe projection info
lightsThe lights, not used

Reimplemented from jop::Drawable.

glm::vec3 jop::World::getGravity ( ) const

Get gravity for world.

Returns
The gravity
Message::Result jop::World::receiveMessage ( const Message message)
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.

Parameters
messageThe message
Returns
The message result

Reimplemented from jop::Drawable.

void jop::World::setBroadphaseBallback ( const BroadphaseCallback callback)

Set the broad phase callback.

Get gravity for world

Parameters
callbackReference to the callback object
void jop::World::setDebugMode ( const bool  enable)

Enable/disable debug drawing.

This method is exposed as command named setWorldDebugMode
Parameters
enableTrue to enable
void jop::World::setDefaultBroadphaseCallback ( )

Restore the default broad phase callback.

void jop::World::setGravity ( const glm::vec3 &  gravity)

Set gravity for world.

Parameters
gravityVector holding amplitude of gravity for each dimension
void jop::World::update ( const float  deltaTime)
overridevirtual

Update the world.

Parameters
deltaTimeThe delta time

Reimplemented from jop::PhantomBody.

Friends And Related Function Documentation

friend class Collider
friend

Definition at line 53 of file World.hpp.

friend class Joint
friend

Definition at line 54 of file World.hpp.

friend class PhantomBody
friend

Definition at line 57 of file World.hpp.

friend class Renderer
friend

Definition at line 55 of file World.hpp.

friend class RigidBody
friend

Definition at line 56 of file World.hpp.

Member Data Documentation

std::unique_ptr<detail::BroadPhaseCallback> jop::World::m_bpCallback
protected

Broad phase callback.

Definition at line 185 of file World.hpp.

std::unique_ptr<detail::ContactListenerImpl> jop::World::m_contactListener
protected

Contact listener implementation.

Definition at line 184 of file World.hpp.

std::unique_ptr<detail::GhostCallback> jop::World::m_ghostCallback
protected

Internal ghost callback.

Definition at line 183 of file World.hpp.

std::unique_ptr<detail::WorldImpl> jop::World::m_worldData
protected

The world data.

Definition at line 182 of file World.hpp.


The documentation for this class was generated from the following file: