//
// bg3d.h
//

#ifndef __BG3D
#define __BG3D

												
#define	MAX_BG3D_MATERIALS			400			// max # of materials in a bg3d file

#define	MAX_BG3D_GROUPS				5
#define	MAX_OBJECTS_IN_GROUP		100


		/* 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
};


		/***********************/
		/* 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;



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



		/* 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(FSSpec *theSpec);

void InitBG3DManager(void);
void ImportBG3D(FSSpec *spec, int groupNum);
void DisposeBG3DContainer(int groupNum);
void DisposeAllBG3DContainers(void);
void BG3D_SetContainerMaterialFlags(short group, short type, short geometryNum, u_long flags);
void ConvertTexture24To16(u_char *srcBuff24, u_short *destBuff16, int width, int height);
void BG3D_SphereMapGeomteryMaterial(short group, short type, short geometryNum, u_short combineMode, u_short envMapNum);
void SetSphereMapInfoOnVertexArrayData(MOMeshData *va, u_short combineMode, u_short envMapNum);
void BG3D_PlaneMapGeomteryMaterial(short group, short type, short geometryNum, u_short combineMode, u_short envMapNum);

#endif

