载入中...
搜索中...
未找到
eve::physics::Body类 参考

2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFixture/newCircleFixture. 更多...

#include <Body.h>

Public 成员函数

 Body (World *world, b2Body *body, int id)
 Internal: wraps a Box2D body (use World::newBody).
 
 ~Body ()
 
 Body (const Body &)=delete
 
Bodyoperator= (const Body &)=delete
 
int getId () const
 Stable id used by contact/impact events.
 
void setPosition (float x, float y)
 Position in pixels.
 
float getX () const
 
float getY () const
 
void setAngle (float radians)
 Rotation in radians.
 
float getAngle () const
 
void setLinearVelocity (float vx, float vy)
 Linear velocity in pixels/s.
 
float getLinearVelocityX () const
 
float getLinearVelocityY () const
 
float getLinearSpeed () const
 Magnitude of the linear velocity.
 
float getMass () const
 Mass in kilograms (Box2D units).
 
float getWorldCenterX () const
 World center of mass in pixels.
 
float getWorldCenterY () const
 
void setAngularVelocity (float omega)
 Angular velocity in radians/s.
 
float getAngularVelocity () const
 
void applyForce (float fx, float fy)
 Force (pixels/s² * kg) applied at the center of mass.
 
void applyForceAt (float fx, float fy, float x, float y)
 Force applied at a world pixel position.
 
void applyLinearImpulse (float ix, float iy)
 Instantaneous linear impulse.
 
void applyAngularImpulse (float impulse)
 Instantaneous angular impulse.
 
void setType (const std::string &bodyType)
 "static" | "kinematic" | "dynamic".
 
std::string getType () const
 
void setFixedRotation (bool fixed)
 Locks rotation so the body cannot spin.
 
bool isFixedRotation () const
 
void setActive (bool active)
 Disables/enables the body and its fixtures.
 
bool isActive () const
 
void setBullet (bool bullet)
 CCD bullet mode (recommended for fast small bodies).
 
bool isBullet () const
 
void setAwake (bool awake)
 Wakes / sleeps the body manually.
 
bool isAwake () const
 
FixturenewRectangleFixture (float width, float height, float density=1.f, float friction=0.2f, float restitution=0.f)
 width/height in pixels; density kg/m² (Box2D units).
 
FixturenewRectangleFixtureAt (float width, float height, float offsetX, float offsetY, float density=1.f, float friction=0.2f, float restitution=0.f)
 Rectangle fixture with a local pixel-space offset from the body origin.
 
FixturenewCircleFixture (float radius, float density=1.f, float friction=0.2f, float restitution=0.f)
 
void destroy ()
 Destroys the body inside its world.
 
WorldgetWorld ()
 Owning world / raw Box2D body.
 
b2Body * raw ()
 
const b2Body * raw () const
 
void invalidate ()
 Internal: marks the wrapper invalid after world destruction.
 

友元

class World
 
class Fixture
 

详细描述

2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFixture/newCircleFixture.

在文件 Body.h16 行定义.

构造及析构函数说明

◆ Body() [1/2]

eve::physics::Body::Body ( World world,
b2Body *  body,
int  id 
)

Internal: wraps a Box2D body (use World::newBody).

在文件 Body.cpp32 行定义.

◆ ~Body()

eve::physics::Body::~Body ( )

◆ Body() [2/2]

eve::physics::Body::Body ( const Body )
delete

成员函数说明

◆ applyAngularImpulse()

void eve::physics::Body::applyAngularImpulse ( float  impulse)

Instantaneous angular impulse.

在文件 Body.cpp168 行定义.

◆ applyForce()

void eve::physics::Body::applyForce ( float  fx,
float  fy 
)

Force (pixels/s² * kg) applied at the center of mass.

在文件 Body.cpp150 行定义.

引用了 eve::physics::World::toMeters().

◆ applyForceAt()

void eve::physics::Body::applyForceAt ( float  fx,
float  fy,
float  x,
float  y 
)

Force applied at a world pixel position.

在文件 Body.cpp156 行定义.

引用了 eve::physics::World::toMeters(), x , 以及 y.

◆ applyLinearImpulse()

void eve::physics::Body::applyLinearImpulse ( float  ix,
float  iy 
)

Instantaneous linear impulse.

在文件 Body.cpp162 行定义.

引用了 eve::physics::World::toMeters().

◆ destroy()

void eve::physics::Body::destroy ( )

Destroys the body inside its world.

在文件 Body.cpp61 行定义.

引用了 f, eve::physics::World::forgetBody(), eve::physics::World::forgetFixture(), invalidate() , 以及 eve::physics::World::raw().

◆ getAngle()

float eve::physics::Body::getAngle ( ) const

在文件 Body.cpp103 行定义.

◆ getAngularVelocity()

float eve::physics::Body::getAngularVelocity ( ) const

在文件 Body.cpp145 行定义.

◆ getId()

int eve::physics::Body::getId ( ) const
inline

Stable id used by contact/impact events.

在文件 Body.h26 行定义.

被这些函数引用 eve::physics::Fixture::getBodyId().

◆ getLinearSpeed()

float eve::physics::Body::getLinearSpeed ( ) const

Magnitude of the linear velocity.

在文件 Body.cpp123 行定义.

引用了 eve::physics::World::toPixels().

◆ getLinearVelocityX()

float eve::physics::Body::getLinearVelocityX ( ) const

在文件 Body.cpp113 行定义.

引用了 eve::physics::World::toPixels().

◆ getLinearVelocityY()

float eve::physics::Body::getLinearVelocityY ( ) const

在文件 Body.cpp118 行定义.

引用了 eve::physics::World::toPixels().

◆ getMass()

float eve::physics::Body::getMass ( ) const

Mass in kilograms (Box2D units).

在文件 Body.cpp128 行定义.

◆ getType()

std::string eve::physics::Body::getType ( ) const

在文件 Body.cpp178 行定义.

◆ getWorld()

World * eve::physics::Body::getWorld ( )
inline

Owning world / raw Box2D body.

在文件 Body.h96 行定义.

◆ getWorldCenterX()

float eve::physics::Body::getWorldCenterX ( ) const

World center of mass in pixels.

在文件 Body.cpp130 行定义.

引用了 eve::physics::World::toPixels().

◆ getWorldCenterY()

float eve::physics::Body::getWorldCenterY ( ) const

在文件 Body.cpp135 行定义.

引用了 eve::physics::World::toPixels().

◆ getX()

float eve::physics::Body::getX ( ) const

在文件 Body.cpp88 行定义.

引用了 eve::physics::World::toPixels().

◆ getY()

float eve::physics::Body::getY ( ) const

在文件 Body.cpp93 行定义.

引用了 eve::physics::World::toPixels().

◆ invalidate()

void eve::physics::Body::invalidate ( )

Internal: marks the wrapper invalid after world destruction.

在文件 Body.cpp55 行定义.

被这些函数引用 destroy().

◆ isActive()

bool eve::physics::Body::isActive ( ) const

在文件 Body.cpp195 行定义.

◆ isAwake()

bool eve::physics::Body::isAwake ( ) const

在文件 Body.cpp209 行定义.

◆ isBullet()

bool eve::physics::Body::isBullet ( ) const

在文件 Body.cpp202 行定义.

◆ isFixedRotation()

bool eve::physics::Body::isFixedRotation ( ) const

在文件 Body.cpp188 行定义.

◆ newCircleFixture()

Fixture * eve::physics::Body::newCircleFixture ( float  radius,
float  density = 1.f,
float  friction = 0.2f,
float  restitution = 0.f 
)

在文件 Body.cpp239 行定义.

引用了 Fixture, raw() , 以及 eve::physics::World::toMeters().

◆ newRectangleFixture()

Fixture * eve::physics::Body::newRectangleFixture ( float  width,
float  height,
float  density = 1.f,
float  friction = 0.2f,
float  restitution = 0.f 
)

width/height in pixels; density kg/m² (Box2D units).

在文件 Body.cpp211 行定义.

引用了 height, newRectangleFixtureAt() , 以及 width.

◆ newRectangleFixtureAt()

Fixture * eve::physics::Body::newRectangleFixtureAt ( float  width,
float  height,
float  offsetX,
float  offsetY,
float  density = 1.f,
float  friction = 0.2f,
float  restitution = 0.f 
)

Rectangle fixture with a local pixel-space offset from the body origin.

在文件 Body.cpp216 行定义.

引用了 Fixture, height, raw(), eve::physics::World::toMeters() , 以及 width.

被这些函数引用 newRectangleFixture().

◆ operator=()

Body & eve::physics::Body::operator= ( const Body )
delete

◆ raw() [1/2]

b2Body * eve::physics::Body::raw ( )
inline

◆ raw() [2/2]

const b2Body * eve::physics::Body::raw ( ) const
inline

在文件 Body.h98 行定义.

◆ setActive()

void eve::physics::Body::setActive ( bool  active)

Disables/enables the body and its fixtures.

在文件 Body.cpp190 行定义.

引用了 active.

◆ setAngle()

void eve::physics::Body::setAngle ( float  radians)

Rotation in radians.

在文件 Body.cpp98 行定义.

◆ setAngularVelocity()

void eve::physics::Body::setAngularVelocity ( float  omega)

Angular velocity in radians/s.

在文件 Body.cpp140 行定义.

◆ setAwake()

void eve::physics::Body::setAwake ( bool  awake)

Wakes / sleeps the body manually.

在文件 Body.cpp204 行定义.

◆ setBullet()

void eve::physics::Body::setBullet ( bool  bullet)

CCD bullet mode (recommended for fast small bodies).

在文件 Body.cpp197 行定义.

◆ setFixedRotation()

void eve::physics::Body::setFixedRotation ( bool  fixed)

Locks rotation so the body cannot spin.

在文件 Body.cpp183 行定义.

◆ setLinearVelocity()

void eve::physics::Body::setLinearVelocity ( float  vx,
float  vy 
)

Linear velocity in pixels/s.

在文件 Body.cpp108 行定义.

引用了 eve::physics::World::toMeters().

◆ setPosition()

void eve::physics::Body::setPosition ( float  x,
float  y 
)

Position in pixels.

在文件 Body.cpp83 行定义.

引用了 eve::physics::World::toMeters(), x , 以及 y.

◆ setType()

void eve::physics::Body::setType ( const std::string &  bodyType)

"static" | "kinematic" | "dynamic".

在文件 Body.cpp173 行定义.

友元及相关函数文档

◆ Fixture

friend class Fixture
friend

在文件 Body.h105 行定义.

被这些函数引用 newCircleFixture() , 以及 newRectangleFixtureAt().

◆ World

friend class World
friend

在文件 Body.h104 行定义.


该类的文档由以下文件生成: