#include "Actor.h"
#include "MatrixManager.h"
#include "ShaderManager.h"

Actor::Actor(string sModel) : Transformable()
{
	m_psModel = sModel;
}

void Actor::drawActor(string sShader)
{
	MatrixManager::getInstance()->pushMatrix4(MODELVIEW, transformToMatrix(MatrixManager::getInstance()->getMatrix4(MODELVIEW)));
	MatrixManager::getInstance()->pushMatrix3(NORMAL, transformToMatrix(MatrixManager::getInstance()->getMatrix3(NORMAL)));
		GLSLProgram *glslProgram = ShaderManager::getInstance()->getShader(sShader);
		glslProgram->sendUniform("modelviewMatrix", &MatrixManager::getInstance()->getMatrix4(MODELVIEW)[0][0]);
		glslProgram->sendUniform("normalMatrix", &MatrixManager::getInstance()->getMatrix3(NORMAL)[0][0],false,3);
		ModelManager::getInstance()->getModel(m_psModel)->draw();
	MatrixManager::getInstance()->popMatrix4(MODELVIEW);
	MatrixManager::getInstance()->popMatrix3(NORMAL);
}

float Actor::getScaledRadius()
{
	return ModelManager::getInstance()->getModel(m_psModel)->getRadius()*max(max(m_nScale[0],m_nScale[1]),m_nScale[2]);
}

void Actor::setModel(string sModel) 
{
	m_psModel = sModel;
}

string Actor::getModel() 
{
	return m_psModel;
}