//
// bg3d.h
//

#ifndef __BG3D
#define __BG3D

#include "metaobjects.h"
												
#define	MAX_BG3D_MATERIALS			400			// max # of materials in a bg3d file

#define	MAX_BG3D_GROUPS				5
#define	MAX_OBJECTS_IN_GROUP		100


		/***********************/
		/* BG3D FILE CONTAINER */
		/***********************/

typedef struct
{
	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 META TAG TYPES */
		//
		// NOTE:  NEVER CHANGE THE NUMERIC VALUES OF THESE OR EXISTING BG3D FILES WILL BE HOZED!!
		//
		
enum
{
	BG3D_TAGTYPE_MATERIALFLAGS				=	0,
	BG3D_TAGTYPE_MATERIALDIFFUSECOLOR		=	1,
	BG3D_TAGTYPE_TEXTUREMAP					=	2,
	BG3D_TAGTYPE_GROUPSTART					=	3,
	BG3D_TAGTYPE_GROUPEND					=	4,	
	BG3D_TAGTYPE_MESH					=	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 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_MULTITEXTURE	=	(1<<4),
	BG3D_MATERIALFLAG_CLAMP_U_TRUE	=	(1<<5),	// this flag is set after glTexParameterf has been called to set clamping for this texture
	BG3D_MATERIALFLAG_CLAMP_V_TRUE	=	(1<<6) 
	
};



		/* BG3D MESH HEADER */
		
typedef struct
{
	int		materialNum;						// index into material list (-1 means no material)
	u_long	flags;								// flags
	u_long	numPoints;							// (if applicable)
	u_long	numTriangles;						// (if applicable)
}BG3DMeshHeader;


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

void SaveBG3DModel(void);

Boolean TextureARGBContainsAlpha(short width, short height, u_long *data);

#endif

