1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 09:07:19 +02:00
openrw/framework2/GTAPlayerAIController.cpp

43 lines
941 B
C++
Raw Normal View History

2013-08-12 23:35:23 +02:00
#include "renderwure/ai/GTAPlayerAIController.hpp"
#include <renderwure/engine/GTAObjects.hpp>
GTAPlayerAIController::GTAPlayerAIController(GTACharacter* character)
: GTAAIController(character), running(false)
{
}
void GTAPlayerAIController::setRunning(bool run)
{
running = run;
}
void GTAPlayerAIController::updateCameraDirection(const glm::quat& rot)
{
cameraRotation = rot;
}
void GTAPlayerAIController::updateMovementDirection(const glm::vec3& dir)
{
direction = dir;
}
void GTAPlayerAIController::update(float dt)
{
if( glm::length(direction) > 0.001f ) {
character->changeAction(running ? GTACharacter::Run : GTACharacter::Walk);
}
else {
character->changeAction(GTACharacter::Idle);
}
}
glm::vec3 GTAPlayerAIController::getTargetPosition()
{
return glm::vec3();
}
glm::quat GTAPlayerAIController::getTargetRotation()
{
return cameraRotation * glm::quat(glm::vec3(0.f, 0.f, -atan2(direction.x, direction.y)));
}