25 #ifndef __I6ENGINE_MODULES_PHYSICSNODE_H__
26 #define __I6ENGINE_MODULES_PHYSICSNODE_H__
32 #include "LinearMath/btMotionState.h"
34 class btCollisionShape;
35 class btCompoundShape;
40 struct CollisionGroup;
46 class PhysicsVelocityComponent;
255 btTransform _transform;
256 btRigidBody * _rigidBody;
258 Vec3 _linearVelocity;
269 std::vector<PeriodicRaytest *> _rayTests;
275 btCompoundShape * _parentShape;
277 std::map<int64_t, std::pair<int64_t, btCollisionShape *>> _childShapes;
290 void startSimulatingBody();
295 void stopSimulatingBody();
312 Vec3 getVelocity()
const;
314 void applyForce(
const Vec3 & force,
const Vec3 & offset,
bool local);
void deleteVelocityComponent()
deletes a VelocityComponent
bool addChild(const int64_t compId, const Vec3 &position, const Quaternion &rotation, const Vec3 &scale, const api::CollisionGroup &cg, const api::PhysicalStateComponent::ShapeType shapeType, const api::attributeMap &shapeParams)
adds a new child shape to this node
Class describing a 3d rotation.
struct i6e::modules::PeriodicRaytest PeriodicRaytest
contains informations for periodic raytests
Vec3 getScale() const
returns the scale of the node
Vec3 getPosition() const
returns the position of the node
ShapeType
Different shape types supported by i6engine.
boost::shared_ptr< Message > Ptr
void Tick()
called during every physics tick
std::map< std::string, std::string > attributeMap
uint32_t crashMask
mask of all objects the given object gets collision feedback
ShatterInterest
Different flags for collision interest.
api::ShatterInterest getShatterInterest() const
get the collision interest
Handles the incoming messages on the physic channel and calls the corresponding methods.
Implements 3-dimensional vectors.
contains informations for periodic raytests
void setCollisionFlags(const api::CollisionGroup &cg)
sets the collision flags of the Node
void getWorldTransform(btTransform &worldTrans) const
Called by Bullet when the object is first scheduled for simulation to retrieve the initial transform...
uint32_t getCrashMask()
returns the CrashMask of the Node
void reset()
Clears all forces and sets the velocity to 0, so that e.g. a bike after shattering doesn't still move...
void setCrashMask(uint32_t cm)
sets the crash mask of the Node
#define ASSERT_THREAD_SAFETY_HEADER
api::RayTestResult HitTest(const Vec3 &from, const Vec3 &to)
Tests a Hit with a ray given by the vector.
void setScale(const Vec3 &scale, int64_t id)
Override from PhysicalStateComponent to update internal transform. Sets new scale by calling Physical...
struct containing information from raytest objID: id of GO hit first by the ray sourceID: id of the s...
void setCrashType(uint32_t ct)
sets the crashtype of the node
api::RayTestResult lastResult
struct containing the collision info for an object
api::PhysicalStateComponent::RayTestNotify raytestNotify
int64_t getID() const
returns the GO id of the Node
Represents the physical state of an object simulated by the Bullet library. Contains the btTransform ...
void setRotation(const Quaternion &rotation, int64_t id)
Override from PhysicalStateComponent to update internal transform. Sets new rotation by calling Physi...
void setWorldTransform(const btTransform &worldTrans)
Called by Bullet when the simulated object has moved.
void createVelocityComponent(double maxSpeed, double resistanceCoefficient, double windage)
creates a new VelocityComponent
void applyRotation(const Quaternion &rotation, int64_t id)
applies the new rotation transforming rotation and forces
uint32_t getCrashType()
returns the CrashType of the Node
Handles calculation of air friction.
PeriodicRaytest(const Vec3 &f, const Vec3 &t, api::PhysicalStateComponent::RayTestNotify rtn, api::GameMessage::Ptr msg)
btRigidBody * getRigidBody() const
returns the rigidBody of the PhysicsNode
RayTestNotify
Different flags for the kind of notify mechanism of raytest.
int64_t getCompID() const
api::GameMessage::Ptr message
void setPosition(const Vec3 &position, int64_t id)
Override from PhysicalStateComponent to update internal transform. Sets new position by calling Physi...
uint32_t crashType
type of the object
PhysicsNode(const int64_t id, const int64_t compId, const Vec3 &position, const Quaternion &rotation, const Vec3 &scale, const api::CollisionGroup &cg, const api::attributeMap ¶ms, api::ShatterInterest shatterInterest, PhysicsManager *pm)
constructor
Quaternion getRotation() const
returns the rotation of the node
void removeChild(int64_t compId)
removes a child shape