Terminus
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
terminus::AbstractPhysicsObject Class Referenceabstract

The AbstractPhysicsObject class represents a graphical scene element with a physics-based aspect, meaning that it can move and collide with other AbstractPhysicsObjects. More...

#include <abstractphysicsobject.h>

Inheritance diagram for terminus::AbstractPhysicsObject:
terminus::AbstractGraphicsObject terminus::DynamicPhysicsObject terminus::KinematicPhysicsObject terminus::Projectile terminus::AbstractWagon terminus::EngineWagon terminus::RepairWagon terminus::WeaponWagon

Public Member Functions

 AbstractPhysicsObject (World &world)
 
virtual void moveTo (const QVector3D &newPosition)
 Moves object to new position. More...
 
virtual void onCollisionWith (AbstractPhysicsObject *other)
 Gets called on collision with another AbstractPhysicsObject. More...
 
virtual void setSpawnedLocally (bool spawnedLocally)
 Set whether this PhysicsObject originated in this local game instance or in a remote instance. More...
 
- Public Member Functions inherited from terminus::AbstractGraphicsObject
 AbstractGraphicsObject (World &world)
 
virtual ~AbstractGraphicsObject ()
 
virtual void update () final
 update object hierarchy beginning at this object More...
 
virtual void render (QOpenGLFunctions &gl) final
 render object hierarchy beginning at this object More...
 
virtual void bindCamera (Camera *camera)
 binds a camera to track this object More...
 
virtual void unbindCamera (Camera *camera)
 release a camera so that it wont track this object any longer More...
 
virtual void onBindCamera ()
 override this method to perform specific actions once a camera has been bound More...
 
virtual void onUnbindCamera ()
 override this method to perform specific actions once a camera has been released More...
 
virtual void adjustCamera ()
 override this method to adjust the parameters of a bound camera according to this objects own state More...
 
virtual void moveEvent (QVector3D movement)
 override this method to react to move events received by a bound camera More...
 
virtual void rotateEvent (QVector2D rotation)
 override this method to react to rotate events received by a bound camera More...
 
const QVector3D & minBB () const
 
const QVector3D & maxBB () const
 
QVector3D worldUp ()
 
QVector3D worldFront ()
 
QVector3D worldSide ()
 
QVector3D position () const
 
QQuaternion rotation () const
 
QVector3D scale () const
 
QMatrix4x4 modelMatrix () const
 
QMatrix4x4 modelMatrixInverted () const
 

Protected Member Functions

virtual void initializePhysics (btCollisionShape *collisionShape, btScalar mass)
 
virtual void deallocatePhysics ()
 
virtual short myCollisionType () const =0
 The collision group that this object is member of. More...
 
virtual short possibleCollisionTypes () const =0
 The groups of objects that this object will collide with. More...
 
- Protected Member Functions inherited from terminus::AbstractGraphicsObject
virtual void localUpdate ()
 override this method to update this objects state More...
 
virtual void localRender (QOpenGLFunctions &gl) const
 this method contains the default render code using m_geometry, m_program and m_material More...
 
virtual void localRenderSetup (QOpenGLFunctions &gl, Program &program) const
 override this method to customize the rendering process More...
 
virtual void localRenderCleanup (QOpenGLFunctions &gl, Program &program) const
 override this method to customize the rendering process More...
 
virtual bool localRenderEnabled () const
 override this method to disable or enable rendering conditionally More...
 
virtual void doForAllChildren (std::function< void(AbstractGraphicsObject &)> callback)
 override this method to make child objects known More...
 
void setPosition (const QVector3D &position)
 sets the position and invalidates the model matrices More...
 
void setRotation (const QQuaternion &rotation)
 sets the rotation and invalidates the model matrices More...
 
void setScale (const QVector3D &scale)
 sets the scale and invalidates the model matrices More...
 
void setScale (float scale)
 sets the scale uniformly on all three axes and invalidates the model matrices More...
 
QVector3D worldToModel (const QVector3D &vWorld)
 
QVector3D modelToWorld (const QVector3D &vModel)
 
void dispose ()
 remove this object from the world and delete it as soon as it is safe to do so More...
 

Protected Attributes

std::shared_ptr< BulletWorldm_bulletWorld
 Shared pointer to the bullet world that this object lives in. More...
 
std::unique_ptr< btRigidBody > m_btRigidBody
 
bool m_spawnedLocally
 
- Protected Attributes inherited from terminus::AbstractGraphicsObject
Worldm_world
 
bool m_validState
 
Cameram_camera
 
std::shared_ptr< std::unique_ptr< Program > > m_program
 
std::shared_ptr< std::unique_ptr< Geometry > > m_geometry
 
std::shared_ptr< std::unique_ptr< Material > > m_material
 
QVector3D m_position
 
QQuaternion m_rotation
 
QVector3D m_scale
 
bool m_modelMatrixChanged
 
QMatrix4x4 m_modelMatrix
 
bool m_modelMatrixInvertedChanged
 
QMatrix4x4 m_modelMatrixInverted
 

Detailed Description

The AbstractPhysicsObject class represents a graphical scene element with a physics-based aspect, meaning that it can move and collide with other AbstractPhysicsObjects.

The most important aspect is that an AbstractPhysicsObject contains a Bullet representation in form of a btRigidBody.

See also
BulletWorld

Constructor & Destructor Documentation

terminus::AbstractPhysicsObject::AbstractPhysicsObject ( World world)

Member Function Documentation

void terminus::AbstractPhysicsObject::deallocatePhysics ( )
protectedvirtual
void terminus::AbstractPhysicsObject::initializePhysics ( btCollisionShape *  collisionShape,
btScalar  mass 
)
protectedvirtual
void terminus::AbstractPhysicsObject::moveTo ( const QVector3D &  newPosition)
virtual

Moves object to new position.

Parameters
newPositionThe position to move this object to
virtual short terminus::AbstractPhysicsObject::myCollisionType ( ) const
protectedpure virtual

The collision group that this object is member of.

Returns
a bitfield that defines the collision group.
See also
BulletWorld::CollisionTypes

Implemented in terminus::AbstractWagon, and terminus::Projectile.

void terminus::AbstractPhysicsObject::onCollisionWith ( AbstractPhysicsObject other)
virtual

Gets called on collision with another AbstractPhysicsObject.

Parameters
otherAbstractPhysicsObject that we collided with

This default implementation does nothing and only exists so that subclasses can override it with custom functionality (like dealing damage). Movement changes are handled by bullet.

Reimplemented in terminus::AbstractWagon, and terminus::Projectile.

virtual short terminus::AbstractPhysicsObject::possibleCollisionTypes ( ) const
protectedpure virtual

The groups of objects that this object will collide with.

Returns
a bitfield that defines with with groups this object will collide
See also
BulletWorld::CollisionTypes

Implemented in terminus::AbstractWagon, and terminus::Projectile.

void terminus::AbstractPhysicsObject::setSpawnedLocally ( bool  spawnedLocally)
virtual

Set whether this PhysicsObject originated in this local game instance or in a remote instance.

Parameters
spawnedLocally

Member Data Documentation

std::unique_ptr<btRigidBody> terminus::AbstractPhysicsObject::m_btRigidBody
protected
std::shared_ptr<BulletWorld> terminus::AbstractPhysicsObject::m_bulletWorld
protected

Shared pointer to the bullet world that this object lives in.

Every physics object holds a shared pointer to the BulletWorld it lives in in order to extend the BulletWorld's lifetime to the point where this physics object dies

bool terminus::AbstractPhysicsObject::m_spawnedLocally
protected

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