//
// bg3d.h
//

#ifndef BG3D_H
#define BG3D_H



/******************* MODEL GROUP LIST *************************/
			
enum
{
	MODEL_GROUP_SPHERES,
	
	NUM_MODEL_GROUPS
};


/******************* SPHERE MODELS *************************/

enum
{
	Spheres_GroupModel_Red,
	Spheres_GroupModel_Green,
	Spheres_GroupModel_Blue,
	Spheres_GroupModel_Gray
};


//=======================================================================================================



#define	MAX_OBJECTS_IN_GROUP		100			// max # of different models in each group
#define	MAX_BG3D_MATERIALS			400			// max # of materials in a bg3d file  WARNING: changing this may alter file format	


		/* BG3D FILE CONTAINER */

#define	BG3D_MEMORY_BLOCK_SIZE		2000000				// alloc ~2MB for each group

typedef struct
{
	Byte				memoryBlock[BG3D_MEMORY_BLOCK_SIZE];// block of memory to load all the vertex data into for VAR acceleration
	int					memoryIndex;						// current index into memoryBlock as we load data
	
	int					numMaterials;
	MOMaterialObject	*materials[MAX_BG3D_MATERIALS];		// references to all of the materials used in file
	MetaObjectPtr		root;								// the root object or group containing all geometry in file
}BG3DFileContainer;



		/* BG3D HEADER */
		
typedef struct
{
	char			headerString[16];			// header string
	NumVersion		version;					// version of file
}BG3DHeaderType;


	/* BG3D MATERIAL FLAGS */
		
enum
{
	BG3D_MATERIALFLAG_TEXTURED		= 	1,
	BG3D_MATERIALFLAG_ALWAYSBLEND	=	(1<<1),	// set if always want to GL_BLEND this texture when drawn
	BG3D_MATERIALFLAG_CLAMP_U		=	(1<<2),
	BG3D_MATERIALFLAG_CLAMP_V		=	(1<<3),
	BG3D_MATERIALFLAG_CLAMP_U_TRUE	=	(1<<4),	// this flag is set after glTexParameterf has been called to set clamping for this texture
	BG3D_MATERIALFLAG_CLAMP_V_TRUE	=	(1<<5) 
	
};


		/* TAG TYPES */
		
enum
{
	BG3D_TAGTYPE_MATERIALFLAGS				=	0,
	BG3D_TAGTYPE_MATERIALDIFFUSECOLOR		=	1,
	BG3D_TAGTYPE_TEXTUREMAP					=	2,
	BG3D_TAGTYPE_GROUPSTART					=	3,
	BG3D_TAGTYPE_GROUPEND					=	4,	
	BG3D_TAGTYPE_GEOMETRY					=	5,
	BG3D_TAGTYPE_VERTEXARRAY				=	6,
	BG3D_TAGTYPE_NORMALARRAY				=	7,
	BG3D_TAGTYPE_UVARRAY					=	8,
	BG3D_TAGTYPE_COLORARRAY					=	9,
	BG3D_TAGTYPE_TRIANGLEARRAY				= 	10,
	BG3D_TAGTYPE_ENDFILE					=	11
};


typedef struct
{
	u_long	width,height;					// dimensions of texture
	u_long	bufferSize;						// size of texture data to follow
}BG3DTextureHeader;



		/* BG3D MESH HEADER */
		
typedef struct
{
	u_long	materialNum;						// index into material list
	u_long	flags;								// flags
	u_long	numPoints;							// # points in mesh
	u_long	numTriangles;						// # triangles in mesh
}BG3DMeshHeader;
			
			


//-----------------------------------


void InitBG3DManager(void);
void ImportBG3D(Str255 fileName, int groupNum);
void DisposeBG3DContainer(int groupNum);
void DisposeAllBG3DContainers(void);

#endif

