#include
Public Member Functions | |
virtual pe_type | GetType () const =0 |
returns pe_type | |
virtual int | AddRef ()=0 |
virtual int | Release ()=0 |
virtual int | SetParams (pe_params *params, int bThreadSafe=0)=0 |
virtual int | GetParams (pe_params *params) const =0 |
virtual int | GetStatus (pe_status *status) const =0 |
virtual int | Action (pe_action *, int bThreadSafe=0)=0 |
virtual int | AddGeometry (phys_geometry *pgeom, pe_geomparams *params, int id=-1, int bThreadSafe=0)=0 |
virtual void | RemoveGeometry (int id, int bThreadSafe=0)=0 |
returns !0 if successful; can get queued | |
virtual void * | GetForeignData (int itype=0) const =0 |
returns entity's pForeignData if itype matches iForeignData, 0 otherwise | |
virtual int | GetiForeignData () const =0 |
returns entity's iForegnData | |
virtual int | GetStateSnapshot (class CStream &stm, float time_back=0, int flags=0)=0 |
obsolete, was used in Far Cry | |
virtual int | GetStateSnapshot (TSerialize ser, float time_back=0, int flags=0)=0 |
virtual int | SetStateFromSnapshot (class CStream &stm, int flags=0)=0 |
obsolete | |
virtual int | PostSetStateFromSnapshot ()=0 |
obsolete | |
virtual unsigned int | GetStateChecksum ()=0 |
obsolete | |
virtual void | SetNetworkAuthority (int authoritive=-1, int paused=-1)=0 |
-1 dont change, 0 - set to false, 1 - set to true | |
virtual int | SetStateFromSnapshot (TSerialize ser, int flags=0)=0 |
virtual int | SetStateFromTypedSnapshot (TSerialize ser, int type, int flags=0)=0 |
virtual int | GetStateSnapshotTxt (char *txtbuf, int szbuf, float time_back=0)=0 |
packs state into ASCII text | |
virtual void | SetStateFromSnapshotTxt (const char *txtbuf, int szbuf)=0 |
virtual int | DoStep (float time_interval, int iCaller=MAX_PHYS_THREADS)=0 |
DoStep: evolves entity in time. Normally this is called from PhysicalWorld::TimeStep. | |
virtual void | StartStep (float time_interval)=0 |
must be called before DoStep | |
virtual void | StepBack (float time_interval)=0 |
virtual IPhysicalWorld * | GetWorld () const =0 |
returns physical world this entity belongs to | |
virtual void | GetMemoryStatistics (ICrySizer *pSizer) const =0 |
Represents a physical entity instance in the world Note that this is independent of entities (IEntity), but physical entities can be attached to entities via the entity system.
|
pure virtual |
Performs an action such as applying an impulse on an entity.
#include
// Applies an impulse on a physical entity
void ActionImpulse(IPhysicalEntity& physicalEntity)
{
pe_action_impulse actionImpulse;
// Apply the impulse one unit upwards
// This can be combined with pe_action_impulse::point to apply the impulse on a specific point
actionImpulse.impulse = Vec3(0, 0, 1);
// Apply spin to the entity
actionImpulse.angImpulse = Vec3(0, 0, 1);
// IPhysicalEntity::Action may be queued if the physics thread is empty or there are other commands queued.
// We can change isThreadSafe to 1 if we are operating on a physics thread to have to event processed immediately
int isThreadSafe = 0;
// Apply the impulse on the entity
physicalEntity.Action(&actionImpulse, isThreadSafe);
}
|
pure virtual |
AddGeometry - add a new entity part, containing pgeom; request can get queued params can be specialized depending on the entity type id is a requested geometry id (expected to be unique), if -1 - assign automatically returns geometry id (0..some number), -1 means error
|
pure virtual |
Gets the parameters of a physical entity, uses the same structures as SetParams;
#include
// Queries the simulation parameters of an entity, for example to check current gravitational influence or mass.
void GetSimulationParameters(IPhysicalEntity& physicalEntity)
{
pe_simulation_params simulationParameters;
if (physicalEntity.GetParams(&simulationParameters))
{
/* simulationParameters can now be used */
}
}
|
pure virtual |
Gets the status of a physical entity, using the pe_status structure.
#include
// Gets the position of a physical entity using the pe_status_pos structure
void GetPhysicalEntityPosition(IPhysicalEntity& physicalEntity)
{
// The pe_status_pos structure is used to query the world-coordinates of an entity
pe_status_pos positionStatus;
if (physicalEntity.GetStatus(&positionStatus))
{
/* positionStatus can now be used */
}
}
|
pure virtual |
Sets / changes parameters on a physical entity; can be queued and executed later if the physics is busy (unless bThreadSafe is flagged)
#include
// Sets the position of a physical entity using the pe_params_pos structure
void SetPhysicalEntityPosition(IPhysicalEntity& physicalEntity)
{
// The pe_params_pos structure is used to set position, orientation and scale
pe_params_pos positionParams;
// Move the entity to {50,50,50} in world coordinates
positionParams.pos = Vec3(50, 50, 50);
// Reset the entity orientation
positionParams.q = IDENTITY;
// Make sure we use default scaling (100%)
positionParams.scale = 1.f;
// IPhysicalEntity::SetParams may be queued if the physics thread is empty or there are other commands queued.
// We can change isThreadSafe to 1 if we are operating on a physics thread to have to event processed immediately
int isThreadSafe = 0;
// Set the position on the entity
physicalEntity.SetParams(&positionParams, isThreadSafe);
}