Enki  1.9
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Enki::PhysicalObject Class Reference

A situated object in the world with mass, geometry properties, physical properties, ... More...

#include <PhysicalEngine.h>

Inheritance diagram for Enki::PhysicalObject:
Enki::Robot Enki::DifferentialWheeled Enki::SbotActiveObject Enki::EPuck Enki::Khepera Enki::Marxbot Enki::Sbot Enki::Thymio2 Enki::SbotActiveSoundObject Enki::FeedableSbot Enki::SoundSbot

Classes

struct  Hull
 A hull is a vector of Hull. More...
 
class  Part
 A part is one of the convex geometrical element that composes the physical object. More...
 
class  UserData
 User specific data that can be attached to any object in the world. More...
 

Public Types

enum  ButtonCode { LEFT_MOUSE_BUTTON = 1<<0, RIGHT_MOUSE_BUTTON = 1<<1, MIDDLE_MOUSE_BUTTON = 1<<3 }
 

Public Member Functions

 PhysicalObject ()
 Constructor.
 
virtual ~PhysicalObject ()
 Destructor.
 
double getRadius () const
 
double getHeight () const
 
bool isCylindric () const
 
const HullgetHull () const
 
const ColorgetColor () const
 
double getMass () const
 
double getMomentOfInertia () const
 
double getInterlacedDistance () const
 
void setCylindric (double radius, double height, double mass)
 Make the object cylindric with a given mass.
 
void setRectangular (double l1, double l2, double height, double mass)
 Make the object rectangular of size l1 x l2 with a given mass.
 
void setCustomHull (const Hull &hull, double mass)
 Set a custom shape and mass to the object.
 
void setColor (const Color &color)
 Set the overall color of this object, if hull is empty or if it does not contain any texture.
 
virtual void clickedInteraction (bool pressed, unsigned int buttonCode, double pointX, double pointY, double pointZ)
 called for robot if a click is performed on it
 

Public Attributes

UserDatauserData
 Data attached by the user to this physical object. If non-null, will be destroyed with the object.
 
double collisionElasticity
 Elasticity of collisions of this object. If 0, soft collision, 100% energy dissipation; if 1, elastic collision, 0% energy dissipation. Actual elasticity is the product of the elasticity of the two colliding objects. Walls are fully elastics.
 
double dryFrictionCoefficient
 The dry friction coefficient mu.
 
double viscousFrictionCoefficient
 The viscous friction coefficient. Premultiplied by mass. A value of k applies a force of -k * speed * mass.
 
double viscousMomentFrictionCoefficient
 The viscous friction moment coefficient. Premultiplied by momentOfInertia. A value of k applies a force of -k * speed * momentOfInertia.
 
Point pos
 The position of the object.
 
double angle
 The orientation of the object in the world, standard trigonometric orientation.
 
Vector speed
 The speed of the object.
 
double angSpeed
 The rotation speed of the object, standard trigonometric orientation.
 

Static Public Attributes

static const double g = 9.81
 

Protected Member Functions

virtual void controlStep (double dt)
 Control step, not oversampled.
 
virtual void applyForces (double dt)
 Apply forces, typically friction to reduce speed, but one can override to change behaviour.
 
virtual void collisionEvent (PhysicalObject *o)
 The object collided with o during the current physical step, if o is null, it collided with walls. Called just before the object is de-interlaced.
 
virtual void initLocalInteractions (double dt, World *w)
 Initialize the object specific interactions, do nothing for PhysicalObject.
 
virtual void doLocalInteractions (double dt, World *w, PhysicalObject *o)
 Do the interactions with the other PhysicalObject, do nothing for PhysicalObject.
 
virtual void doLocalWallsInteraction (double dt, World *w)
 Do the interactions with the walls of world w, do nothing for PhysicalObject.
 
virtual void finalizeLocalInteractions (double dt, World *w)
 All interactions are finished, do nothing for PhysicalObject.
 
virtual void initGlobalInteractions (double dt, World *w)
 Initialize the global interactions, do nothing for PhysicalObject.
 
virtual void doGlobalInteractions (double dt, World *w)
 Do the global interactions with the world, do nothing for PhysicalObject.
 
virtual void finalizeGlobalInteractions (double dt, World *w)
 All global interactions are finished, do nothing for PhysicalObject.
 

Private Member Functions

void dirtyUserData ()
 When a physical parameter (color, shape, ...) has been changed, the user data must be updated.
 
void computeMomentOfInertia ()
 Compute the moment of inertia tensor depending on radius, mass, height, and hull, assuming that the hull is centered around the center of mass, which is done by setupCentorOfMass()
 
void setupCenterOfMass ()
 Compute the center of mass and move bounding surfaces accordingly. Does not update the moment of inertia tensor.
 
void computeTransformedShape ()
 Compute the hull of this object in world coordinates.
 
void initPhysicsInteractions (double dt)
 Initialize the collision logic.
 
void finalizePhysicsInteractions (double dt)
 All collisions are finished, deinterlace the object.
 
void collideWithStaticObject (const Vector &n, const Point &cp)
 Dynamics for collision with a static object at points cp with normal vector n.
 
void collideWithObject (PhysicalObject &that, const Point &cp, const Vector &dist)
 Dynamics for collision with that at point cp with a penetrated distance of dist.
 

Private Attributes

Vector posBeforeCollision
 position before collision, used to compute interlacedDistance
 
double interlacedDistance
 How much this object did penetrate other objects in the course of physics steps since last control step.
 
double mass
 The mass of the object. If below zero, the object can't move (infinite mass).
 
double momentOfInertia
 ! The moment of inertia tensor
 
Hull hull
 The hull of this object, which can be composed of several Hull.
 
double r
 The radius of circular objects or, if hull is not empty, the bounding circle.
 
double height
 The height of circular object or, if hull is not empty, the maximum height.
 
Color color
 The overall color of this object, if hull is empty or if it does not contain any texture.
 

Friends

class World
 

Detailed Description

A situated object in the world with mass, geometry properties, physical properties, ...


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