#pragma once

#include <irrlicht.h>
using namespace irr;

class Building : public scene::ISceneNode
{
	public:
		Building(float hue, core::vector3df& _size, scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id);
		~Building();

		virtual void OnRegisterSceneNode();
		virtual void render();

		virtual const core::aabbox3d<f32>& getBoundingBox() const { return m_box; }
		virtual u32 getMaterialCount() const { return 1; }
		virtual video::SMaterial& getMaterial(u32 i) { return m_material; }	

	private:
		static const unsigned VERTEX_COUNT = 20;	// 4 vertex per face. 5 faces.
		static const unsigned INDEX_COUNT = 30;		// 6 values per face, 5 faces.
		static const unsigned PRIMITIVE_COUNT = 10;	// 2 triangles per face, 5 faces.
		const core::vector3df m_size;
		core::aabbox3d<f32> m_box;
		video::S3DVertex m_vertices[VERTEX_COUNT];
		u16 m_indices[INDEX_COUNT];
		video::SMaterial m_material;
		float m_hue;

	private:
		void addFace(unsigned& vertexIndex, unsigned& indexIndex, const core::vector3df* positions, 
			const core::vector3df& normal, unsigned v1, unsigned v2, unsigned v3, unsigned v4);
};

