SBSPSS/Utils/Libs/DaveLib/facestore.h

175 lines
4.8 KiB
C
Raw Normal View History

2001-02-08 15:04:49 +01:00
/****************************************/
/*** Generic Face Compilation Storage ***/
/****************************************/
#ifndef __FACESTORE_HEADER__
#define __FACESTORE_HEADER__
#include <ginio.h>
#include <gintex.h>
#include <Vector>
#include <TexGrab.h>
#include "..\..\..\tools\data\include\dStructs.h"
using namespace std;
//***************************************************************************
2001-03-08 00:20:09 +01:00
/*
2001-02-08 15:04:49 +01:00
struct sFaceTexList
{
GString Name;
int TexGrabId;
};
2001-03-08 00:20:09 +01:00
*/
2001-02-08 15:04:49 +01:00
//***************************************************************************
class CFace
{
2001-03-08 00:20:09 +01:00
public:
// int PntCount;
int Mat;
Vector3 vtx[4];
int pts[4];
int idx[4];
sUV uvs[4];
int vis[4];
Vector3 Normal;
bool Avail;
int ID;
GString TexName;
};
/*
class CFace
{
2001-02-08 15:04:49 +01:00
public:
CFace()
{
vtx.resize(3);
pts.resize(3);
idx.resize(3);
uvs.resize(3);
vis.resize(3);
}
2001-03-08 00:20:09 +01:00
// int PntCount;
2001-02-08 15:04:49 +01:00
int Mat;
vector<Vector3> vtx;
vector<int> pts;
vector<int> idx;
vector<sUV> uvs;
vector<int> vis;
Vector3 Normal;
bool Avail;
int ID;
GString TexName;
};
2001-03-08 00:20:09 +01:00
*/
2001-02-08 15:04:49 +01:00
//***************************************************************************
#ifndef sTriFace
struct sTriFace
{
int Mat;
Vector3 vtx[3];
int pts[3];
sUV uvs[3];
};
#endif
//***************************************************************************
class CFaceStore
{
public:
CFaceStore() {MaxStrip = 3;TexGrab=&FaceStoreTexGrab;}
CFaceStore(int Max) {MaxStrip=Max;TexGrab=&FaceStoreTexGrab;}
~CFaceStore(){};
2001-03-12 18:11:40 +01:00
CFace &AddFace(vector<Vector3> const &P, const sGinTri &T, const sUVTri &uv,GString const &Tex,int ID=0,bool ProcessTexFlag=false);
2001-03-08 00:20:09 +01:00
CFace &AddFace(CFace &F,bool TexFlag=true);
void AddFaces(vector<CFace>&Faces,bool TexFlag=true);
void AddFaces(CFaceStore &Faces,bool TexFlag=true);
2001-02-08 15:04:49 +01:00
CFace &AddFace(sTriFace &Face,int ID=0);
2001-02-08 17:30:06 +01:00
void SetTexGrab(CTexGrab &NewGrab) {TexGrab=&NewGrab;}
2001-02-08 15:04:49 +01:00
int AddTex(GString const &TexName);
2001-03-01 18:03:15 +01:00
2001-02-08 17:30:06 +01:00
void SetTexOut(GString &Name,int TPBase,int TPW,int TPH) {TexGrab->SetOutFile(Name); TexGrab->SetTPage(TPBase,TPW,TPH);}
void SetTexInclude(GString &Name) {TexGrab->SetIncFile(Name);}
void SetTexDebug(bool f) {TexGrab->SetDebug(f);}
void SetTexDebugOut(GString &Name) {TexGrab->SetDebugOut(Name);}
void SetTexShrinkToFit(bool f) {TexGrab->ShrinkToFit(f);}
void SetTexNoSort() {TexGrab->NoSort();}
void SetTexAnimatedHeadersOnly(bool f) {TexGrab->AnimatedHeadersOnly(f);}
void SetTexDontOutputBoxes(bool f) {TexGrab->DontOutputBoxes(f);}
void SetTexAllowRotate(bool f) {TexGrab->AllowRotate(f);}
2001-02-08 15:04:49 +01:00
CTexGrab &GetTexGrab() {return(FaceStoreTexGrab);}
vector<sTexOutInfo> &GetTexInfo() {return(TexGrab->GetTexInfo());}
void ProcessTextures();
void Process();
2001-03-12 18:11:40 +01:00
int WriteTriList(FILE *File) {return(WriteTriList(File,OutTriList));}
int WriteQuadList(FILE *File) {return(WriteQuadList(File,OutQuadList));}
int WriteVtxList(FILE *File) {return(WriteVtxList(File,OutVtxList));}
int WriteTriList(FILE *File,vector<sTri> &List);
int WriteQuadList(FILE *File,vector<sQuad> &List);
int WriteVtxList(FILE *File,vector<sVtx> &List);
2001-02-08 15:04:49 +01:00
vector<CFace> const &GetFaceList() {return(FaceList);}
int GetFaceCount() {return(FaceList.size());}
vector<CFace> const &GetTriFaceList() {return(TriFaceList);}
int GetTriFaceCount() {return(TriFaceList.size());}
vector<CFace> const &GetQuadFaceList() {return(QuadFaceList);}
int GetQuadFaceCount() {return(QuadFaceList.size());}
vector<sVtx> const &GetVtxList() {return(OutVtxList);}
int GetVtxCount() {return(OutVtxList.size());}
int AddVtx(Vector3 &Vtx);
void setMaxStripLength(int v) {MaxStrip = v;}
CFace& operator []( int nIndex ) {return(FaceList[nIndex]);}
private:
void Quad();
void SetupUV(CFace const &In, sTri &Out);
void SetupUV(CFace const &In, sQuad &Out);
void BuildOutTriLists();
void BuildOutQuadList();
// int QuadGetAttached(int FaceNo);
// void QuadGetPnts(CFace &F,int *Join0,int *Join1,int *Pnt);
// void QuadGetUVs(CFace &F,int *Join0,int *Join1,int *Pnt);
// void OrderPnts( CFace &F ,int unc);
// bool CanConnect( int f0, int f1 );
// int CountFacesAttached ( int f );
// void FollowFace( int id, CFace &F );
// int GetUnconnectedPoint( int f0, int f1, int &f0p0, int &f0p1 );
// bool GetFace( CFace & F );
int MaxStrip;
vector<CFace> FaceList;
2001-03-08 00:20:09 +01:00
// vector<sFaceTexList> TexList;
2001-02-08 15:04:49 +01:00
CTexGrab FaceStoreTexGrab,*TexGrab;
vector<CFace> TriFaceList;
vector<CFace> QuadFaceList;
vector<sTri> OutTriList;
vector<sQuad> OutQuadList;
vector<sVtx> OutVtxList;
};
#endif