easyx_framework V1.0.0
基于easyx的c++游戏框架
 
载入中...
搜索中...
未找到
RigidBody类 参考

刚体组件. 更多...

#include <RigidBody.h>

类 RigidBody 继承关系图:
Component base

Public 成员函数

 ~RigidBody ()
 清空关联的碰撞器附着的这个物理属性
 
virtual void BeginPlay ()
 设置纯虚函数,把不能写在构造却需要优先实现的写在这.
 
virtual void Update (float deltaTime) override
 
void SetGravity (float gravity)
 设置重力加速度
 
void SetVelocity (Vector2D velocity)
 设置速度
 
Vector2D GetVelocity ()
 获取速度
 
void SetAngularVelocity (float angularVelocity)
 设置角阻尼
 
void AddForce (Vector2D force)
 添加持续力
 
void AddPulse (Vector2D pulse)
 添加冲量
 
void SetMoveable (bool Moveable)
 是否可移动
 
void SetGravityEnable (bool GravityEnable)
 是否启用重力
 
void SetRotatable (bool Rotatable)
 是否可旋转
 
void SetMass (float mass)
 
void SetMaxSpeed (float maxSpeed)
 
void SetLinearDrag (float linearDrag)
 
void SetAngularDrag (float angularDrag)
 
- Public 成员函数 继承自 Component
virtual void EndPlay ()
 把一些不能写在析构函数的一些操作写在这里
 
void SetOwner (class Object *owner)
 设置绑定对象.
 
virtual void Destruct ()
 解除物体绑定组件,并销毁组件
 
virtual void Activate ()
 激活组件
 
virtual void Deactivate ()
 停用组件
 
ObjectGetOwner () const
 获取绑定对象指针
 
- Public 成员函数 继承自 base
 base ()
 
virtual ~base ()
 
std::string GetName () const
 
void SetName (const std::string &name)
 

Private 成员函数

void RestrictVelocity (Vector2D impactnolunit, RigidBody *another=nullptr)
 物理模拟计算.
 
void RestrictVelocity (Vector2D impactnolunit, const PhysicsMaterial &material, RigidBody *another=nullptr)
 物理模拟计算.
 

Private 属性

Vector2D velocity = Vector2D(0, 0)
 速度
 
float maxSpeed = 1000.f
 最大速度
 
float gravity = 9.8f
 重力加速度
 
float angularVelocity = 0.f
 角速度 实现自旋的角度
 
bool bGravityEnable = true
 是否实现重力计算
 
bool bMoveable = true
 是否实现移动
 
bool bRotatable = true
 是否实现旋转
 
float mass = 1.0f
 质量
 
float linearDrag = 0.f
 线性阻尼
 
float angularDrag = 0.f
 角阻尼
 
float deltaTime = 0.f
 每帧的时间
 
std::unordered_set< class Collider * > colliders
 存储附着的碰撞体
 

友元

class Collider
 

额外继承的成员函数

- Protected 属性 继承自 Component
class ObjectpOwner = nullptr
 处理控制逻辑 有对象物体的指针才能进行控制
 
bool bIsEnabled = true
 是否激活
 

详细描述

刚体组件.

利用物理 实现对物体坐标控制

构造及析构函数说明

◆ ~RigidBody()

RigidBody::~RigidBody ( )

清空关联的碰撞器附着的这个物理属性

成员函数说明

◆ AddForce()

void RigidBody::AddForce ( Vector2D force)
inline

添加持续力

备注
假设质量为1,牛二知道F=ma 持续力

◆ AddPulse()

void RigidBody::AddPulse ( Vector2D pulse)
inline

添加冲量

瞬间添加一个力 瞬时力

◆ BeginPlay()

virtual void RigidBody::BeginPlay ( )
inlinevirtual

设置纯虚函数,把不能写在构造却需要优先实现的写在这.

重载 Component .

◆ GetVelocity()

Vector2D RigidBody::GetVelocity ( )
inline

获取速度

◆ RestrictVelocity() [1/2]

void RigidBody::RestrictVelocity ( Vector2D impactnolunit,
const PhysicsMaterial & material,
RigidBody * another = nullptr )
private

物理模拟计算.

参数
[in]impactnolunit施加力的方向单位向量
[in]material材质类
[in]another碰撞到的物体刚体组件指针

◆ RestrictVelocity() [2/2]

void RigidBody::RestrictVelocity ( Vector2D impactnolunit,
RigidBody * another = nullptr )
private

物理模拟计算.

参数
[in]impactnolunit施加力的方向单位向量
[in]another碰撞到的物体刚体组件指针

◆ SetAngularDrag()

void RigidBody::SetAngularDrag ( float angularDrag)
inline

◆ SetAngularVelocity()

void RigidBody::SetAngularVelocity ( float angularVelocity)
inline

设置角阻尼

◆ SetGravity()

void RigidBody::SetGravity ( float gravity)
inline

设置重力加速度

◆ SetGravityEnable()

void RigidBody::SetGravityEnable ( bool GravityEnable)
inline

是否启用重力

◆ SetLinearDrag()

void RigidBody::SetLinearDrag ( float linearDrag)
inline

◆ SetMass()

void RigidBody::SetMass ( float mass)
inline

◆ SetMaxSpeed()

void RigidBody::SetMaxSpeed ( float maxSpeed)
inline

◆ SetMoveable()

void RigidBody::SetMoveable ( bool Moveable)
inline

是否可移动

◆ SetRotatable()

void RigidBody::SetRotatable ( bool Rotatable)
inline

是否可旋转

◆ SetVelocity()

void RigidBody::SetVelocity ( Vector2D velocity)
inline

设置速度

◆ Update()

void RigidBody::Update ( float deltaTime)
overridevirtual

重载 Component .

友元及相关符号说明

◆ Collider

friend class Collider
friend

类成员变量说明

◆ angularDrag

float RigidBody::angularDrag = 0.f
private

角阻尼

◆ angularVelocity

float RigidBody::angularVelocity = 0.f
private

角速度 实现自旋的角度

◆ bGravityEnable

bool RigidBody::bGravityEnable = true
private

是否实现重力计算

◆ bMoveable

bool RigidBody::bMoveable = true
private

是否实现移动

◆ bRotatable

bool RigidBody::bRotatable = true
private

是否实现旋转

◆ colliders

std::unordered_set<class Collider* > RigidBody::colliders
private

存储附着的碰撞体

◆ deltaTime

float RigidBody::deltaTime = 0.f
private

每帧的时间

◆ gravity

float RigidBody::gravity = 9.8f
private

重力加速度

◆ linearDrag

float RigidBody::linearDrag = 0.f
private

线性阻尼

◆ mass

float RigidBody::mass = 1.0f
private

质量

◆ maxSpeed

float RigidBody::maxSpeed = 1000.f
private

最大速度

◆ velocity

Vector2D RigidBody::velocity = Vector2D(0, 0)
private

速度