VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
PolygonBody Class Reference

A QObject container for a Box2D b2Body that represents a polygon. More...

Inheritance diagram for PolygonBody:
Body QObject

Signals

void verticesChanged ()
 Emitted when vertices changes. More...
 
- Signals inherited from Body
void bodyTypeChanged ()
 Emitted when bodyType changes. More...
 
void activeChanged ()
 Emitted when active changes. More...
 
void linearDampingChanged ()
 Emitted when linearDamping changes. More...
 
void angularDampingChanged ()
 Emitted when angularDamping changes. More...
 
void gravityScaleChanged ()
 Emitted when gravityScale changes. More...
 
void magneticChanged ()
 Emitted when magnetic changes. More...
 
void magneticStrengthChanged ()
 Emitted when magneticStrength changes. More...
 
void positionSet ()
 Emitted when position is set. More...
 
void angleInRadiansSet ()
 Emitted when angleInRadians is set. More...
 
void linearVelocitySet ()
 Emitted when linearVelocity is set. More...
 
void angularVelocitySet ()
 Emitted when angularVelocity is set. More...
 
void sensorChanged ()
 Emitted when sensor changes. More...
 
void densityChanged ()
 Emitted when density changes. More...
 
void frictionChanged ()
 Emitted when friction changes. More...
 
void restitutionChanged ()
 Emitted when restitution changes. More...
 
void jointsChanged ()
 Emitted when joints changes. More...
 
void contactBegun (Body *otherBody, QPointF normal)
 Emitted when a contact begins. More...
 
void contactEnded (Body *otherBody, QPointF normal)
 Emitted when a contact ends. More...
 
void queuedContactBegun (Body *otherBody, QPointF normal)
 Queued version of contactBegun(). More...
 
void queuedContactEnded (Body *otherBody, QPointF normal)
 Queued version of contactEnded(). More...
 

Public Member Functions

 PolygonBody (QObject *parent=nullptr)
 Constructs a PolygonBody. More...
 
const QList< QPointF > & getVertices () const
 Returns vertices as a QList<QPointF>. More...
 
QVariantList getVerticesAsVariantList () const
 Returns vertices as a QVariantList. More...
 
void setVertices (const QList< QPointF > &value)
 Sets vertices. More...
 
void setVerticesFromVariantList (const QVariantList &value)
 Sets vertices. More...
 
const QList< QPolygonF > & getTriangles ()
 Returns a QList<QPolygonF> of this PolygonBody's triangles. More...
 
- Public Member Functions inherited from Body
 Body (QObject *parent=0)
 Constructs a Body. More...
 
virtual ~Body ()
 Destroys a Body. More...
 
ActorgetActor () const
 Returns actor. More...
 
BodyType getBodyType () const
 Returns bodyType. More...
 
void setBodyType (BodyType value)
 Sets bodyType. More...
 
bool isActive () const
 Returns active. More...
 
void setActive (bool value)
 Sets active. More...
 
float getLinearDamping () const
 Returns linearDamping. More...
 
void setLinearDamping (float value)
 Sets linearDamping. More...
 
float getAngularDamping () const
 Returns angularDamping. More...
 
void setAngularDamping (float value)
 Sets angularDamping. More...
 
float getGravityScale () const
 Returns gravityScale. More...
 
void setGravityScale (float value)
 Sets gravityScale. More...
 
bool isMagnetic () const
 Returns magnetic. More...
 
void setMagnetic (bool value)
 Sets magnetic. More...
 
float getMagneticStrength () const
 Returns magneticStrength. More...
 
void setMagneticStrength (float value)
 Sets magneticStrength. More...
 
QPointF getPosition () const
 Returns position. More...
 
bool isSensor () const
 Returns sensor. More...
 
void setSensor (bool value)
 Sets sensor. More...
 
float getDensity () const
 Returns density. More...
 
void setDensity (float value)
 Sets density. More...
 
float getFriction () const
 Returns friction. More...
 
void setFriction (float value)
 Sets friction. More...
 
float getRestitution () const
 Returns restitution. More...
 
void setRestitution (float value)
 Sets restitution. More...
 
const QList< Joint * > & getJoints () const
 Returns joints as a const QList<Joint*>&. More...
 
QQmlListProperty< JointgetJointListProperty ()
 Returns joints as a QQmlListProperty<Joint>. More...
 
void setJoints (const QList< Joint * > &value)
 Sets joints. More...
 
Q_INVOKABLE JointgetJoint (int index)
 Returns a Joint at a given index. More...
 
Q_INVOKABLE int getJointCount () const
 Returns the number of Joints associated with this Body. More...
 
Q_INVOKABLE void addJoint (Joint *joint)
 Add a Joint to the Body. More...
 
Q_INVOKABLE void removeJoint (Joint *joint)
 Remove a Joint from the Body. More...
 
Q_INVOKABLE void clearJoints ()
 Clear all the Joints owned by this Body. More...
 
Q_INVOKABLE void clearAllAttachedJoints ()
 Destroys all Joints associated with this Body, whether or not this Body is the Joint's parent. More...
 
b2Body * getBody ()
 Returns the b2Body associated with this Body. More...
 
Q_INVOKABLE void applyTorque (float torque)
 Apply torque to the associated b2Body. More...
 
Q_INVOKABLE void applyForceToCenter (const QPointF &force)
 Apply force to the associated b2Body. More...
 
void invalidateTransform ()
 Marks the transform for this Body as dirty. More...
 
virtual void updateBeforePhysics ()
 Called immediately preceding the physics step. More...
 
virtual void updateAfterPhysics ()
 Called immediately following the physics step. More...
 
QList< Body * > getContactedBodies () const
 Returns a QList containing the list of Bodys in contact with this Body. More...
 
void beginContact (Body *otherBody, const QPointF &normal)
 Called when this Body has made contact with another. More...
 
void endContact (Body *otherBody, const QPointF &normal)
 Called when this Body loses contact with another. More...
 
void setPosition (const QPointF &value)
 Sets position. More...
 
float getAngleInRadians () const
 Returns angleInRadians. More...
 
void setAngleInRadians (float value)
 Sets angleInRadians. More...
 
QPointF getLinearVelocity () const
 Returns linearVelocity. More...
 
void setLinearVelocity (const QPointF &value)
 Sets linearVelocity. More...
 
float getAngularVelocity () const
 Returns angularVelocity. More...
 
void setAngularVelocity (float value)
 Sets angularVelocity. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 

Protected Member Functions

virtual void forEachShape (const std::function< void(b2Shape *)> &func) override
 Calls func on the b2Shapes that represents this PolygonBody. More...
 
- Protected Member Functions inherited from Body
void invalidateFixtures ()
 Marks the Body's fixtures as dirty and that they need to be recreated. More...
 
void forEachFixture (const std::function< void(b2Fixture *)> &func)
 Applies func to each of the Body's fixtures. More...
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Properties

QVariantList vertices
 The vertices defining the PolygonBody. More...
 
- Properties inherited from Body
Actor actor
 Actor object associated with this Body. Always the parent in the item hierarchy. More...
 
BodyType bodyType
 BodyType of this Body. More...
 
bool active
 Whether or not the Body takes part in the physics simulation. More...
 
float linearDamping
 Dampens the linearVelocity of the Body. More...
 
float angularDamping
 Dampens the angularVelocity of the Body. More...
 
float gravityScale
 Coefficient on the continuous force of gravity. More...
 
bool magnetic
 Whether or not magnetism is set on for this Body. More...
 
float magneticStrength
 Intensity of the magnetic forces involving this Body. More...
 
bool sensor
 The sensor value for all of this Body's b2Fixtures. More...
 
float density
 The density value for all of this Body's b2Fixtures. More...
 
float friction
 The friction value for all of this Body's b2Fixtures. More...
 
float restitution
 The restitution value for all of this Body's b2Fixtures. More...
 
QQmlListProperty< Jointjoints
 List of Joint objects associated with this Body. More...
 
QPointF position
 Positional component of the b2Body's transform. More...
 
float angleInRadians
 Rotational component of the b2Body's transform, in radians. More...
 
QPointF linearVelocity
 The rate which the Bodys position changes. More...
 
float angularVelocity
 The rate which the Bodys angle changes. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Types inherited from Body
enum  BodyType { StaticBody = 0, KinematicBody, DynamicBody }
 Overarching category of how this Body interacts with the world. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Detailed Description

A QObject container for a Box2D b2Body that represents a polygon.

Constructor & Destructor Documentation

PolygonBody::PolygonBody ( QObject parent = nullptr)
explicit

Constructs a PolygonBody.

Member Function Documentation

virtual void PolygonBody::forEachShape ( const std::function< void(b2Shape *)> &  func)
overrideprotectedvirtual

Calls func on the b2Shapes that represents this PolygonBody.

Parameters
funcFunction to call, which receives the b2Shape as an argument

Reimplemented from Body.

const QList<QPolygonF>& PolygonBody::getTriangles ( )

Returns a QList<QPolygonF> of this PolygonBody's triangles.

Note
This function re-triangulates the PolygonBody's polygon, if necessary.
const QList<QPointF>& PolygonBody::getVertices ( ) const

Returns vertices as a QList<QPointF>.

QVariantList PolygonBody::getVerticesAsVariantList ( ) const

Returns vertices as a QVariantList.

void PolygonBody::setVertices ( const QList< QPointF > &  value)

Sets vertices.

Parameters
valueQList<QPointF> to set vertices to
void PolygonBody::setVerticesFromVariantList ( const QVariantList &  value)

Sets vertices.

Parameters
valueQVariantList to set vertices to
void PolygonBody::verticesChanged ( )
signal

Emitted when vertices changes.

Property Documentation

QVariantList PolygonBody::vertices
readwrite

The vertices defining the PolygonBody.