dataBase.H 4.52 KB
/******************************************************************************\
  Copyright 1995 The University of North Carolina at Chapel Hill.
  All Rights Reserved.

  Permission to use, copy, modify and distribute this software and its
  documentation for educational, research and non-profit purposes, without
  fee, and without a written agreement is hereby granted, provided that the
  above copyright notice and the following three paragraphs appear in all
  copies.

  IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA
  AT CHAPEL HILL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, 
  INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
  OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE
  UNIVERSITY OF NORTH CAROLINA HAS BEEN ADVISED OF THE POSSIBILITY OF
  SUCH DAMAGES.

  THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY WARRANTIES, 
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HERUNDER IS
  ON AN "AS IS" BASIS, AND THE UNIVERSITY OF NORTH CAROLINA HAS NO OBLIGATIONS
  TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

  The author may be contacted via:

  US Mail:             Mike Goslin
                       Department of Computer Science
                       Sitterson Hall, CB #3175
                       University of N. Carolina
                       Chapel Hill, NC 27599-3175

  Phone:               (919)962-1719

  EMail:               goslin@cs.unc.edu

*******************************************************************************/
/*******************************************************************************
* FILENAME:	dataBase.H
* CLASS:	DataBase
* DESCRIPTION:  A graphical database representation to serve as intermediary
*		for translations between various file formats.
* AUTHOR:	Mike Goslin
* CREATED:	2/7/95
* REVISIONS:	
*
*******************************************************************************/

#ifndef _DBASE_HPP_
#define _DBASE_HPP_

#include "flt14_1.h" 		  // MultiGen Flight format V. 14.1 header file
#include "bead.H"		  

typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;

class DataBase 
{
	Bead			*dbase,
				*current;
	HeaderBead		*hdr;
	VertexTableBead		*vpool;
	VertexListBead		*vlist;
	TextureBead		*texlist;
	ColorTableBead		*ctable;
	ushort			 ctableflag;
	ushort 			 addVert;
	ushort			 pastFirstPush;
	void printBead(const Bead *bead) const; 
	void traverse(Bead *bead) const;
    public:
	//---------------------------------------------------------------------
	//		database initialization functions
	//---------------------------------------------------------------------
	DataBase(void); 
	~DataBase();
	//---------------------------------------------------------------------
	// 		database traversal functions
	//---------------------------------------------------------------------
	Bead* data(void) { return dbase; }
	void up(void) { current = current->up(); }
	void down(void) { current = current->down(); }
	void left(void) { current = current->left(); }
	void right(void) { current = current->right(); }
	void reset(void) { current = dbase; }
	void pop(void) { current = current->up(); }
	//--------------------------------------------------------------------- 
	// 		database construction functions
	//---------------------------------------------------------------------
	int addVertex(double coord[3]) { return(vpool->addVertex(coord)); }
	int addVertex(double coord[3], float norm[3]) 
					{ return(vpool->addVertex(coord,norm));}
	int addVertex(double coord[3], float norm[3], float tex[2])
				{ return(vpool->addVertex(coord,norm,tex)); }	
	int addVertex(double coord[3], float norm[3], int col);
	int addVertex(double coord[3], float norm[3], uchar col[3]);
	void addSibling(Bead *bead);
	void addChild(Bead *bead);
	uint add(Bead& bead, short pushflag=NULL);
	ulong addColor(short r, short g, short b, int delta=0);

 	void nextGroup(short group) { hdr->nextGroup(group); }
	void nextObj(short obj) { hdr->nextObj(obj); }
	void nextPoly(short poly) { hdr->nextPoly(poly); }
	//---------------------------------------------------------------------
	char *getPolyTextureFile(PolygonBead *poly);
	//---------------------------------------------------------------------
	//		database write functions
	//---------------------------------------------------------------------
	void printTextures(void) const;
	void printVertPool(void) const { vpool->printVertPool(); } 
	void print(void) const;	// for debugging
};

#endif