#include "objecteditor.h"

#include "engine.h"
#include "defaultkeysmap.h"

#include <SparrowInput/input.h>

#include <SparrowRenderer/trackballcamera.h>

ObjectEditor::ObjectEditor() :
    m_camera(new TrackBallCamera())
{

}

void ObjectEditor::update()
{
    Input* input = getEngine().getInput();
    glm::vec2 diff = input->getDeltaPosition();
    for(Action action : input->getActions())
    {
        if(action.action == DefaultKeysMap::MAIN_ACTION_HOLD)
            m_camera->rotateCamera(diff.x, diff.y);
        else if(action.action == DefaultKeysMap::SECONDARY_ACTION_HOLD)
            m_camera->moveCamera(diff.x, diff.y);
    }
    m_camera->zoom(input->getDeltaVerticalScroll()*120.f);
}
