#include "SceneEntity.h"
#include <iostream>

void SceneEntity::setName(string _name)
{
	name = _name;
}

string SceneEntity::getName()
{
	return name;
}

void SceneEntity::setTransformation(float* transform)
{
	entityTransform = D3DXMATRIX(transform);
}

void SceneEntity::addModel(PosModel* model,float* transform)
{
	models.insert(pair<Model*,D3DXMATRIX>(dynamic_cast<Model*>(model),D3DXMATRIX(transform)));
}

D3DXMATRIX SceneEntity::getTransformation()
{
	return entityTransform;
}

void SceneEntity::render(Effect* effect, ID3D10EffectPass* pass)
{
	effect->setModelMatrix(&entityTransform);
	for (ModelMap::iterator it = models.begin(); it!=models.end(); ++it)
	{
		
		(*it).first->render(effect,pass);
	}
}

void SceneEntity::createVBOs(ID3D10Effect* effect)
{
	for (ModelMap::iterator it = models.begin(); it!=models.end(); ++it)
	{
			(*it).first->createVBOs(effect);
	}
}

SceneEntity::~SceneEntity()
{
	models.clear();
}