4#ifndef PHYSICS_BULLET_MOTIONSTATES_H
5#define PHYSICS_BULLET_MOTIONSTATES_H
7#include <btBulletDynamicsCommon.h>
37 loc =
vec3(0.0f, 0.0f, 0.0f);
46 btVector3 translation;
47 translation.setX(loc.x);
48 translation.setY(loc.y);
49 translation.setZ(loc.z);
51 btQuaternion rotation;
58 transf.setRotation(rotation);
59 transf.setOrigin(translation);
65 if (
entity ==
nullptr)
return;
70 btQuaternion rot = worldTrans.getRotation();
71 btVector3 loc = worldTrans.getOrigin();
73 location.x = loc.getX();
74 location.y = loc.getY();
75 location.z = loc.getZ();
79 rotation.x = rot.getX();
80 rotation.y = rot.getY();
81 rotation.z = rot.getZ();
82 rotation.w = rot.getW();
110 btVector3 translation;
111 translation.setX(loc.x);
112 translation.setY(loc.y);
113 translation.setZ(loc.z);
115 btQuaternion rotation;
116 rotation.setX(rot.x);
117 rotation.setY(rot.y);
118 rotation.setZ(rot.z);
119 rotation.setW(rot.w);
122 transf.setRotation(rotation);
123 transf.setOrigin(translation);
132 btQuaternion rot = worldTrans.getRotation();
133 btVector3 loc = worldTrans.getOrigin();
135 location.x = loc.getX();
136 location.y = loc.getY();
137 location.z = loc.getZ();
139 rotation.x = rot.getX();
140 rotation.y = rot.getY();
141 rotation.z = rot.getZ();
142 rotation.w = rot.getW();
148 location = location - ent_loc;
149 location = glm::inverse(ent_rot) * location;
150 location = location -
offset;
152 rotation = rotation * glm::inverse(ent_rot);
158 arm->SetBoneKeyframe(
bone, kframe);
Definition: animation.h:13
void UpdateTransform(const vec3 &loc, const quat &rot)
Definition: entity.h:54
const vec3 & GetLocation()
Definition: entity.h:61
const quat & GetRotation()
Definition: entity.h:62
Definition: motionstates.h:92
virtual ~ArmMotionState()
Definition: motionstates.h:102
ArmMotionState(name_t boneName, AnimationComponent *armature, vec3 bindPos, Entity *entity, PhysicsComponent *physicsComp)
Definition: motionstates.h:94
PhysicsComponent * physcomp
Definition: motionstates.h:162
vec3 offset
Definition: motionstates.h:165
name_t bone
Definition: motionstates.h:166
AnimationComponent * arm
Definition: motionstates.h:163
Entity * ent
Definition: motionstates.h:164
virtual void getWorldTransform(btTransform &worldTrans) const
Definition: motionstates.h:104
virtual void setWorldTransform(const btTransform &worldTrans)
Definition: motionstates.h:128
Definition: motionstates.h:18
virtual void getWorldTransform(btTransform &worldTrans) const
Definition: motionstates.h:32
virtual void setWorldTransform(const btTransform &worldTrans)
Definition: motionstates.h:64
vec3 troffse
Definition: motionstates.h:89
Entity * entity
Definition: motionstates.h:88
virtual ~EntMotionState()
Definition: motionstates.h:25
EntMotionState(Entity *ent, vec3 &offset)
Definition: motionstates.h:20
void SetEntity(Entity *ent)
Definition: motionstates.h:28
glm::vec3 vec3
Definition: math.h:12
glm::quat quat
Definition: math.h:13
Definition: animation.h:28
vec3 location
Definition: animation.h:30
quat rotation
Definition: animation.h:31