#include "box.h"

using namespace kLibrary::factory;

namespace CBK
{
	namespace Shapes
	{
		Box::Box(const MeshParam& params, const std::string& name) : Mesh(params, name)
		{
			Width = 1.0f;
			Height = 1.0f;
			Depth = 1.0f;
		}

		Box::Box(const MeshParam& params, const FLOAT Width, const FLOAT Height, const FLOAT Depth, const std::string& name) : Mesh(params, name)
		{
			this->Width = Width;
			this->Width = Height;
			this->Width = Depth;
		}

		Box& Box::resize(const FLOAT Width, const FLOAT Height, const FLOAT Depth)
		{
			this->Width = Width;
			this->Width = Height;
			this->Width = Depth;

			return *this;
		}

		//Clean up
		Box::~Box(void)
		{
		}

		//Create is called automatically when a device is set
			//With no parameters, create should generate a default sized version
		item& Box::load(const std::string& name, const MeshParam& params)
		{
			if (params.device != 0)
				_device = params.device;
			if (_device == 0) return *this;
			if (_mesh != 0) d3d::Release<ID3DXMesh*>(_mesh);
			
			D3DXCreateBox(_device, Width, Height, Depth, &_mesh, 0);
			_subsets = 1;

			return *this;
		}
	}
}