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

47 lines
1.0 KiB
C++

#include "renderwure/ai/GTAPlayerAIController.hpp"
#include <renderwure/objects/GTACharacter.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()
{
if( glm::length(direction) > 0.001f ) {
return lastRotation = cameraRotation * glm::quat(glm::vec3(0.f, 0.f, -atan2(direction.x, direction.y)));
}
return lastRotation;
}