SBSPSS/Utils/MkLevel/MkLevel.h

215 lines
5.4 KiB
C
Raw Normal View History

2001-04-17 18:42:07 +02:00
/*************************/
/*** Base Level Holder ***/
/*************************/
#ifndef __MKLEVEL_HEADER__
#define __MKLEVEL_HEADER__
#include <vector>
#include <List.h>
#include <FaceStore.h>
#include "IniClass.h"
// Map Editor header files
#include "..\mapedit\LayerDef.h"
#include "..\mapedit\ExportHdr.h"
using namespace std;
//***************************************************************************
struct sMkLevelTex
{
2001-05-05 23:18:12 +02:00
int Tile;
int Flags;
int TexID;
2001-07-09 22:02:33 +02:00
int Height;
2001-05-05 23:18:12 +02:00
2001-07-09 22:02:33 +02:00
bool operator ==(sMkLevelTex const &v1) {return(Tile==v1.Tile && Flags==v1.Flags && Height==v1.Height);}
2001-05-05 23:18:12 +02:00
};
2001-05-23 18:03:10 +02:00
//***************************************************************************
struct sInfItem
{
GString Name;
int Val;
bool operator ==(sInfItem const &v1) {return(Name==v1.Name);}
};
2001-06-27 18:45:56 +02:00
//***************************************************************************
struct sUsedTile2d
{
int Tile;
int Flags;
int TexID;
bool operator ==(sUsedTile2d const &v1) {return(Tile==v1.Tile && Flags==v1.Flags);}
};
//***************************************************************************
struct sUsedTile3d
{
2001-07-09 22:02:33 +02:00
int Tile;
int Flags;
2001-06-27 18:45:56 +02:00
bool operator ==(sUsedTile3d const &v1) {return(Tile==v1.Tile);}
};
struct sOutElem3d
{
2001-07-24 22:17:50 +02:00
// bool LocalGeom;
2001-07-09 22:02:33 +02:00
bool Model;
2001-06-28 19:48:30 +02:00
sElem3d Elem3d;
CFaceStore FaceStore;
2001-07-11 21:02:00 +02:00
// CList<u16> LocalVtxIdxList;
2001-07-12 22:10:15 +02:00
// int LocalVtxIdxStart;
2001-07-11 21:02:00 +02:00
int LocalVtxIdxCount;
int OTOfs;
2001-06-28 19:48:30 +02:00
};
//***************************************************************************
struct sMkLevelModel
{
GString Name;
int TriStart,TriCount;
u16 ElemID;
bool operator ==(sMkLevelModel const &v1) {return(Name==v1.Name);}
2001-06-27 18:45:56 +02:00
};
2001-04-23 16:51:44 +02:00
//***************************************************************************
struct sMkLevelLayerThing;
2001-04-17 18:42:07 +02:00
class CMkLevelLayer;
class CMkLevel
{
public:
CMkLevel();
~CMkLevel();
2001-04-19 17:12:21 +02:00
void SetAppDir(const char *Path);
2001-07-18 18:45:39 +02:00
void Init(const char *InFilename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH,int PakW,int PakH,bool LocalGeom,float SnapThesh);
2001-04-17 18:42:07 +02:00
2001-04-27 18:16:23 +02:00
void LoadModels();
2001-04-30 23:49:54 +02:00
int AddModel(const char *Name,int TriStart,int TriCount);
2001-04-17 18:42:07 +02:00
void Load();
void Process();
2001-06-27 18:45:56 +02:00
int AddTile2d(sExpLayerTile &Tile);
int AddTile3d(sExpLayerTile &Tile);
2001-04-17 18:42:07 +02:00
2001-05-23 18:03:10 +02:00
void AddInfItem(const char *Name,int Val);
2001-04-17 18:42:07 +02:00
void Write();
2001-07-09 22:02:33 +02:00
int Create2dTile(int Tile,int Flags,int Height);
2001-06-27 18:45:56 +02:00
int Create3dTile(int Tile,int Flags);
2001-05-02 20:40:41 +02:00
void MakeTexName(sExpTile &SrcTile,int Flags,GString &OutStr);
2001-07-09 22:02:33 +02:00
int BuildTileTex(sExpTile &SrcTile,int Flags,int Height);
2001-04-17 18:42:07 +02:00
char *GetConfigStr(const char *Grp,const char *Key) {return(Config.GetStr(Grp,Key));}
2001-05-23 18:03:10 +02:00
int GetConfigInt(const char *Grp,const char *Key) {return(Config.GetInt(Grp,Key));}
2001-04-19 17:12:21 +02:00
CIni &GetConfig() {return(Config);}
2001-04-17 18:42:07 +02:00
CTexGrab &GetTexGrab() {return(TexGrab);}
2001-04-19 17:12:21 +02:00
void SetStart(int X,int Y) {LevelHdr.PlayerStartX=X; LevelHdr.PlayerStartY=Y;}
2001-06-25 17:54:07 +02:00
void GetPakWH(int &W,int &H) {W=PakW; H=PakH;}
2001-04-17 18:42:07 +02:00
protected:
2001-04-27 18:16:23 +02:00
void BuildModel(CScene &ThisScene,GString &RootPath,int Node);
2001-06-28 19:48:30 +02:00
2001-07-24 22:17:50 +02:00
int Create3dElem(int TriCount,int TriStart,bool IsTile,int OtOfs);
int Create2dElem(int Tile);
2001-06-28 19:48:30 +02:00
2001-04-17 18:42:07 +02:00
CMkLevelLayer *FindLayer(int Type,int SubType);
void LoadStrList(CList<GString> &List,char *TexPtr,int Count);
void LoadTiles(sExpFileHdr *FileHdr);
void LoadLayers(sExpFileHdr *FileHdr);
void LoadLayer(sExpLayerHdr *LayerHdr);
2001-07-11 21:02:00 +02:00
void SnapTiles();
2001-06-28 19:48:30 +02:00
void AddDefVtx(vector<sVtx> &VtxList);
2001-04-17 18:42:07 +02:00
void PreProcessLayers();
2001-06-27 18:45:56 +02:00
void ProcessElemBanks();
void PreProcessElemBank2d();
void ProcessElemBank2d();
void PreProcessElemBank3d();
void ProcessElemBank3d();
2001-06-28 19:48:30 +02:00
void ProcessElem3d(sOutElem3d &ThisElem);
2001-04-17 18:42:07 +02:00
void ProcessLayers();
2001-06-27 18:45:56 +02:00
void SetUpTileUV(sElem2d &Out, sTexOutInfo &Info);
2001-04-17 18:42:07 +02:00
2001-06-28 19:48:30 +02:00
void PreProcessModels();
2001-04-27 18:16:23 +02:00
void ProcessModels();
2001-06-27 18:45:56 +02:00
2001-04-17 18:42:07 +02:00
void WriteLevel();
void WriteLayers();
2001-06-25 17:54:07 +02:00
int WriteLayer(int Type,int SubType,bool Warn=false);
int WriteThings(int Type,bool Warn=false);
2001-04-27 18:16:23 +02:00
int WriteModelList();
2001-04-17 18:42:07 +02:00
int WriteTriList();
int WriteQuadList();
2001-04-19 17:12:21 +02:00
int WriteVtxList();
2001-06-27 18:45:56 +02:00
void WriteElemBanks();
2001-04-17 18:42:07 +02:00
void BuildTiles();
2001-05-23 18:03:10 +02:00
void WriteIncFile();
2001-06-25 17:54:07 +02:00
void ReportLayers();
char *GetLayerName(int Type,int SubType);
2001-04-23 16:51:44 +02:00
void ExpTri2Face(sExpTri &In,CFace &Out,bool ImportTex=true);
2001-07-12 22:10:15 +02:00
void CalcOtOfs(vector<sTri> &TList,vector<sVtx> &VtxList,int Start,int Count);
void CalcOtOfs(vector<sQuad> &TList,vector<sVtx> &VtxList,int Start,int Count);
2001-04-17 18:42:07 +02:00
FILE *File;
2001-05-23 18:03:10 +02:00
GString InFilename,InPath,LevelName,LevelFullName;
GString OutName,OutIncName;
2001-04-19 17:12:21 +02:00
GString AppDir;
2001-04-17 18:42:07 +02:00
int TileW,TileH;
CIni Config;
2001-04-27 18:16:23 +02:00
2001-04-17 18:42:07 +02:00
CList<sExpTri> InTriList;
CList<sExpTile> InTileList;
CList<GString> InSetNameList;
CList<GString> InTexNameList;
2001-06-27 18:45:56 +02:00
CList<sElem2d> OutElem2d;
CList<sOutElem3d> OutElem3d;
CList<sUsedTile2d> UsedTile2dList;
CList<sUsedTile3d> UsedTile3dList;
2001-05-05 23:18:12 +02:00
CList<sMkLevelTex> Tex2dList;
2001-04-17 18:42:07 +02:00
CTexGrab TexGrab;
CList<Frame> BmpList;
vector<CMkLevelLayer*> LayerList;
2001-04-27 18:16:23 +02:00
CList<sMkLevelModel> ModelList;
CFaceStore ModelFaceList;
2001-04-19 17:12:21 +02:00
sLevelHdr LevelHdr;
sExpTri FlatFace[2];
2001-04-17 18:42:07 +02:00
2001-05-23 18:03:10 +02:00
CList<sInfItem> InfList;
2001-06-25 17:54:07 +02:00
int PakW,PakH;
2001-06-28 19:48:30 +02:00
bool LocalGeom;
2001-07-18 18:45:39 +02:00
float SnapThresh;
2001-06-25 17:54:07 +02:00
2001-06-27 18:45:56 +02:00
vector<sTri> OutTriList;
vector<sQuad> OutQuadList;
vector<sVtx> OutVtxList;
2001-07-11 21:02:00 +02:00
vector<u16> OutLocalVtxIdxList;
2001-06-27 18:45:56 +02:00
2001-04-17 18:42:07 +02:00
};
//***************************************************************************
#endif