#pragma once

#include <irrlicht.h>
using namespace irr;

class TerrainBlockData
{
	public:
		TerrainBlockData(video::ITexture* pTexture);
		~TerrainBlockData();

		const video::S3DVertex* vertices() const;
		const u16* indices() const;
		const core::aabbox3d<f32>& boundingBox() const;
		video::SMaterial& material();

	public:
		static const unsigned VERTEX_COUNT = 24;	// 4 vertex per face. 6 faces.
		static const unsigned INDEX_COUNT = 36;		// 6 values per face, 6 faces.
		static const unsigned PRIMITIVE_COUNT = 12;	// 2 triangles per face, 6 faces.

	private:
		video::S3DVertex m_vertices[VERTEX_COUNT];
		u16 m_indices[INDEX_COUNT];
		video::SMaterial m_material;
		core::aabbox3d<f32> m_box;

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

