17 #include <GameObject.h> 18 #include "MoveComponent.h" 19 #include "linmath/float3x3.h" 21 MoveComponent::MoveComponent(){
25 MoveComponent::MoveComponent(
GameObject* meshObject) {
26 this->meshObject = meshObject;
29 MoveComponent::MoveComponent(
GameObject* meshObject, chag::Quaternion rotationSpeed,
30 chag::float3 velocity, chag::float3 acceleration,
33 this->velocity = velocity;
34 this->acceleration = acceleration;
35 this->rotationSpeed = rotationSpeed;
36 this->scaleSpeed = scaleSpeed;
39 void MoveComponent::update(
float dt){
41 velocity += acceleration*dt;
42 meshObject->setLocation(meshObject->getRelativeLocation() + velocity*dt);
44 chag::Quaternion q = slerp(chag::Quaternion(), rotationSpeed, dt);
45 meshObject->updateRotation(q);
46 meshObject->setScale(meshObject->getRelativeScale()+scaleSpeed*dt);
51 chag::float3 MoveComponent::getVelocity(){
return velocity; }
52 chag::float3 MoveComponent::getAcceleration(){
return acceleration; }
53 chag::Quaternion MoveComponent::getRotationSpeed(){
return rotationSpeed; }
54 chag::float3 MoveComponent::getScaleSpeed(){
return scaleSpeed; }
57 void MoveComponent::setVelocity(chag::float3 v){velocity = v;}
58 void MoveComponent::setAcceleration(chag::float3 a){acceleration = a;}
59 void MoveComponent::setRotationSpeed(chag::Quaternion rs){rotationSpeed = rs;}
60 void MoveComponent::setScaleSpeed(chag::float3 ss){scaleSpeed = ss;}
A class for containing all information about a object in the game world.