This commit is contained in:
parent
d33f59257f
commit
aaaed92c9e
28 changed files with 322 additions and 188 deletions
|
@ -215,3 +215,25 @@ sTgaHdr FileHdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************
|
//***************************************************
|
||||||
|
Vector3 CalcNormal(Vector3 const &v0, Vector3 const &v1, Vector3 const &v2 )
|
||||||
|
{
|
||||||
|
Vector3 dv1, dv2;
|
||||||
|
Vector3 out;
|
||||||
|
|
||||||
|
dv1.x = v1.x - v0.x;
|
||||||
|
dv1.y = v1.y - v0.y;
|
||||||
|
dv1.z = v1.z - v0.z;
|
||||||
|
|
||||||
|
dv2.x = v2.x - v0.x;
|
||||||
|
dv2.y = v2.y - v0.y;
|
||||||
|
dv2.z = v2.z - v0.z;
|
||||||
|
|
||||||
|
out.x = (dv1.z * dv2.y) - (dv1.y * dv2.z);
|
||||||
|
out.y = (dv1.x * dv2.z) - (dv1.z * dv2.x);
|
||||||
|
out.z = (dv1.y * dv2.x) - (dv1.x * dv2.y);
|
||||||
|
|
||||||
|
out.Normalise();
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,6 @@ void PadFile(FILE *File);
|
||||||
|
|
||||||
char *FindFile(const char *Name);
|
char *FindFile(const char *Name);
|
||||||
void SaveTGA(char *Filename,int W,int H,u8 *Data,bool IsBGR=false);
|
void SaveTGA(char *Filename,int W,int H,u8 *Data,bool IsBGR=false);
|
||||||
|
Vector3 CalcNormal(Vector3 const &v0, Vector3 const &v1, Vector3 const &v2 );
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
#endif
|
#endif
|
|
@ -65,7 +65,7 @@ FILE *File;
|
||||||
int Size;
|
int Size;
|
||||||
char *Script;
|
char *Script;
|
||||||
File=fopen(Filename,"rt");
|
File=fopen(Filename,"rt");
|
||||||
if (!File) return;
|
if (!File) {printf("%s Not Found\n",Filename); return;}
|
||||||
fseek(File,0,SEEK_END);
|
fseek(File,0,SEEK_END);
|
||||||
Size=ftell(File);
|
Size=ftell(File);
|
||||||
fseek(File,0,SEEK_SET);
|
fseek(File,0,SEEK_SET);
|
||||||
|
|
|
@ -138,6 +138,9 @@ public:
|
||||||
|
|
||||||
CFace& operator []( int nIndex ) {return(FaceList[nIndex]);}
|
CFace& operator []( int nIndex ) {return(FaceList[nIndex]);}
|
||||||
|
|
||||||
|
vector<sTri> GetOutTriList() {return(OutTriList);}
|
||||||
|
vector<sQuad> GetOutQuadList() {return(OutQuadList);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Quad();
|
void Quad();
|
||||||
void SetupUV(CFace const &In, sTri &Out);
|
void SetupUV(CFace const &In, sTri &Out);
|
||||||
|
|
|
@ -41,9 +41,9 @@ int Height=InMap.GetHeight();
|
||||||
/*** Process *****************************************************************/
|
/*** Process *****************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
/*
|
||||||
void CMkLevelLayer3d::Process(CMkLevel *Core)
|
void CMkLevelLayer3d::Process(CMkLevel *Core)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int Width=InMap.GetWidth();
|
int Width=InMap.GetWidth();
|
||||||
int Height=InMap.GetHeight();
|
int Height=InMap.GetHeight();
|
||||||
int i,ListSize;
|
int i,ListSize;
|
||||||
|
@ -149,18 +149,19 @@ int i,ListSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/** Write ********************************************************************/
|
/** Write ********************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
/*
|
||||||
int CMkLevelLayer3d::Write(FILE *File,const char *LayerName,const char *MapName)
|
int CMkLevelLayer3d::Write(FILE *File,const char *LayerName,const char *MapName)
|
||||||
{
|
{
|
||||||
int ThisPos=ftell(File);
|
int ThisPos=ftell(File);
|
||||||
/*
|
CMkLevelLayerTile::Write(File,LayerName,MapName);
|
||||||
|
|
||||||
int Width=OutMap.GetWidth();
|
int Width=OutMap.GetWidth();
|
||||||
int Height=OutMap.GetHeight();
|
int Height=OutMap.GetHeight();
|
||||||
sLayerHdr LayerHdr;
|
sLayerHdr LayerHdr;
|
||||||
|
@ -203,11 +204,12 @@ int RetPos=ftell(File);
|
||||||
fseek(File,Pos3d,SEEK_SET);
|
fseek(File,Pos3d,SEEK_SET);
|
||||||
fwrite(&Hdr3d,sizeof(sLayer3d),1,File);
|
fwrite(&Hdr3d,sizeof(sLayer3d),1,File);
|
||||||
fseek(File,RetPos,SEEK_SET);
|
fseek(File,RetPos,SEEK_SET);
|
||||||
*/
|
|
||||||
return(ThisPos);
|
return(ThisPos);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
#if 0
|
||||||
void CMkLevelLayer3d::ProcessVtxList(vector<sVtx> const &InList,vector<sVtx> &OutList)
|
void CMkLevelLayer3d::ProcessVtxList(vector<sVtx> const &InList,vector<sVtx> &OutList)
|
||||||
{
|
{
|
||||||
int i,ListSize=InList.size();
|
int i,ListSize=InList.size();
|
||||||
|
@ -263,5 +265,5 @@ sVtx Ofs;
|
||||||
printf("MinXY %i,%i %i,%i\n",XMin,YMin,XMax,YMax);
|
printf("MinXY %i,%i %i,%i\n",XMin,YMin,XMax,YMax);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -15,13 +15,10 @@ public:
|
||||||
CMkLevelLayer3d(sExpLayerHdr *LayerHdr) : CMkLevelLayerTile(LayerHdr){};
|
CMkLevelLayer3d(sExpLayerHdr *LayerHdr) : CMkLevelLayerTile(LayerHdr){};
|
||||||
|
|
||||||
void PreProcess(CMkLevel *Core);
|
void PreProcess(CMkLevel *Core);
|
||||||
void Process(CMkLevel *Core);
|
// void Process(CMkLevel *Core);
|
||||||
int Write(FILE *File,const char *LayerName,const char *MapName);
|
// int Write(FILE *File,const char *LayerName,const char *MapName);
|
||||||
protected:
|
protected:
|
||||||
void ProcessVtxList(vector<sVtx> const &In,vector<sVtx> &Out);
|
// void ProcessVtxList(vector<sVtx> const &In,vector<sVtx> &Out);
|
||||||
|
|
||||||
// CFaceStore TriList;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -44,10 +44,10 @@ GString Player=Core->GetConfigStr("MISC","PlayerActor");
|
||||||
}
|
}
|
||||||
if (NotFound)
|
if (NotFound)
|
||||||
{
|
{
|
||||||
GObject::Error(ERR_FATAL,"No Start Point defined");
|
GObject::Error(ERR_WARNING,"No Start Point defined\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessList();
|
ProcessList(Core);
|
||||||
printf("%i actors\n",ThingList.size());
|
printf("%i actors\n",ThingList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ void CMkLevelLayerFX::PreProcess(CMkLevel *Core)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMkLevelLayerFX::Process(CMkLevel *Core)
|
void CMkLevelLayerFX::Process(CMkLevel *Core)
|
||||||
{
|
{
|
||||||
ProcessList();
|
ProcessList(Core);
|
||||||
printf("%i FX\n",ThingList.size());
|
printf("%i FX\n",ThingList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ void CMkLevelLayerItem::PreProcess(CMkLevel *Core)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMkLevelLayerItem::Process(CMkLevel *Core)
|
void CMkLevelLayerItem::Process(CMkLevel *Core)
|
||||||
{
|
{
|
||||||
ProcessList();
|
ProcessList(Core);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -25,7 +25,7 @@ void CMkLevelLayerPlatform::PreProcess(CMkLevel *Core)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMkLevelLayerPlatform::Process(CMkLevel *Core)
|
void CMkLevelLayerPlatform::Process(CMkLevel *Core)
|
||||||
{
|
{
|
||||||
ProcessList();
|
ProcessList(Core);
|
||||||
printf("%i Platforms\n",ThingList.size());
|
printf("%i Platforms\n",ThingList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,17 +71,17 @@ int i,ListSize=ThingList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMkLevelLayerThing::ProcessList()
|
void CMkLevelLayerThing::ProcessList(CMkLevel *Core)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int i,ListSize=ThingList.size();
|
int i,ListSize=ThingList.size();
|
||||||
|
CIni &Config=Core->GetConfig();
|
||||||
|
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sMkLevelLayerThing &ThisThing=ThingList[i];
|
sMkLevelLayerThing &ThisThing=ThingList[i];
|
||||||
bool Found=CMkLevel::Config.GetInt(GetTypeName(),ThisThing.Name,ThisThing.Type);
|
bool Found=Config.GetInt(GetTypeName(),ThisThing.Name,ThisThing.Type);
|
||||||
if (!Found)
|
if (!Found)
|
||||||
GObject::Error(ERR_FATAL,"%s not found in list\n",ThisThing.Name);
|
GObject::Error(ERR_FATAL,"%s not found in list\n",ThisThing.Name);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ virtual int Write(FILE *File,const char *LayerName,const char *MapName)=0;
|
||||||
protected:
|
protected:
|
||||||
u8 *LoadThing(sMkLevelLayerThing &ThisThing,u8 *Ptr);
|
u8 *LoadThing(sMkLevelLayerThing &ThisThing,u8 *Ptr);
|
||||||
void LoadThingNames(char *Ptr);
|
void LoadThingNames(char *Ptr);
|
||||||
void ProcessList();
|
void ProcessList(CMkLevel *Core);
|
||||||
|
|
||||||
CList<sMkLevelLayerThing> ThingList;
|
CList<sMkLevelLayerThing> ThingList;
|
||||||
|
|
||||||
|
|
|
@ -93,15 +93,18 @@ int Height=OutMap.GetHeight();
|
||||||
Hdr.Height=Height;
|
Hdr.Height=Height;
|
||||||
fwrite(&Hdr,sizeof(sLayerHdr),1,File);
|
fwrite(&Hdr,sizeof(sLayerHdr),1,File);
|
||||||
|
|
||||||
|
printf("%s (%i,%i)= %i\n",LayerName,Width,Height,Width*Height*sizeof(sTileMapElem));
|
||||||
|
|
||||||
for (int Y=0; Y<Height; Y++)
|
for (int Y=0; Y<Height; Y++)
|
||||||
{
|
{
|
||||||
for (int X=0; X<Width; X++)
|
for (int X=0; X<Width; X++)
|
||||||
{
|
{
|
||||||
sMkLevelElem &ThisElem=OutMap.Get(X,Y);
|
sMkLevelElem &ThisElem=OutMap.Get(X,Y);
|
||||||
|
sTileMapElem OutElem;
|
||||||
|
OutElem.Tile=ThisElem.Elem;
|
||||||
|
// OutElem.LightIdx=0;
|
||||||
|
|
||||||
ASSERT(Hdr.SubType!=LAYER_SUBTYPE_ACTION);
|
fwrite(&OutElem,sizeof(sTileMapElem),1,File);
|
||||||
fwrite(&ThisElem.Elem,sizeof(u16),1,File);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PadFile(File);
|
PadFile(File);
|
||||||
|
|
|
@ -25,7 +25,7 @@ void CMkLevelLayerTrigger::PreProcess(CMkLevel *Core)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CMkLevelLayerTrigger::Process(CMkLevel *Core)
|
void CMkLevelLayerTrigger::Process(CMkLevel *Core)
|
||||||
{
|
{
|
||||||
ProcessList();
|
ProcessList(Core);
|
||||||
printf("%i Trigger\n",ThingList.size());
|
printf("%i Trigger\n",ThingList.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ std::vector<GString> const &Files = MyFiles.GetFileInfoVector();
|
||||||
if (Files.size()==0) Usage("No Levels specified\n");
|
if (Files.size()==0) Usage("No Levels specified\n");
|
||||||
if (Files.size()>1) Usage("Too many Levels specified\n");
|
if (Files.size()>1) Usage("Too many Levels specified\n");
|
||||||
|
|
||||||
|
Level.SetAppDir(argv[0]);
|
||||||
Level.Init(Files[0],OutStr,TPBase,TPW,TPH);
|
Level.Init(Files[0],OutStr,TPBase,TPW,TPH);
|
||||||
Level.Load();
|
Level.Load();
|
||||||
Level.Process();
|
Level.Process();
|
||||||
|
|
|
@ -25,14 +25,19 @@
|
||||||
#include "Layers\MkLevelLayerTrigger.h"
|
#include "Layers\MkLevelLayerTrigger.h"
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
GString ConfigFilename="MkLevel";
|
const GString ConfigFilename="MkLevel.ini";
|
||||||
sExpLayerTile BlankTile={-1,-1};
|
sExpLayerTile BlankTile2d={-1,-1};
|
||||||
|
sExpLayerTile BlankTile3d={0,0};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
CMkLevel::CMkLevel()
|
CMkLevel::CMkLevel()
|
||||||
{
|
{
|
||||||
memset(&LvlHdr,0,sizeof(sLvlHdr));
|
memset(&LevelHdr,0,sizeof(sLevelHdr));
|
||||||
Tile2dList.Add(BlankTile);
|
Tile2dList.Add(BlankTile2d);
|
||||||
|
Tile3dList.Add(BlankTile3d);
|
||||||
|
OutTile3dList.resize(1);
|
||||||
|
OutTile3dList[0].TriCount=0;
|
||||||
|
OutTile3dList[0].QuadCount=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -41,24 +46,37 @@ CMkLevel::~CMkLevel()
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::Init(const char *Filename,const char *OutDir,int TPBase,int TPW,int TPH)
|
void CMkLevel::SetAppDir(const char *AppPath)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AppDir="\\spongebob\\tools\\data\\bin\\";
|
||||||
|
#else
|
||||||
|
GFName Path=AppPath;
|
||||||
|
|
||||||
|
Path.File("");
|
||||||
|
Path.Ext("");
|
||||||
|
AppDir=Path.FullName();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkLevel::Init(const char *Filename,const char *OutFilename,int TPBase,int TPW,int TPH)
|
||||||
{
|
{
|
||||||
// Setup filenames and paths
|
// Setup filenames and paths
|
||||||
GFName Path=Filename;
|
GFName Path;
|
||||||
|
|
||||||
InFilename=Filename;
|
InFilename=Filename;
|
||||||
|
Path=Filename;
|
||||||
LevelName=Path.File();
|
LevelName=Path.File();
|
||||||
Path.File("");
|
Path.File("");
|
||||||
Path.Ext("");
|
Path.Ext("");
|
||||||
InPath=Path.FullName();
|
InPath=Path.FullName();
|
||||||
OutPath=OutDir; OutPath.Append('\\');
|
Path=OutFilename;
|
||||||
OutName=OutPath+LevelName;
|
Path.Ext("");
|
||||||
|
OutName=Path.FullName();
|
||||||
|
|
||||||
// Load ini file
|
// Load ini file
|
||||||
#ifdef _DEBUG
|
Config.LoadAndImport(GString(AppDir+ConfigFilename));
|
||||||
ConfigFilename="\\spongebob\\tools\\data\\bin\\mklevel.ini";
|
|
||||||
#endif
|
|
||||||
Config.LoadAndImport(ConfigFilename);
|
|
||||||
|
|
||||||
// Setup Texgrab
|
// Setup Texgrab
|
||||||
if (TPBase==-1 || TPW==-1 || TPH==-1)
|
if (TPBase==-1 || TPW==-1 || TPH==-1)
|
||||||
|
@ -77,23 +95,22 @@ GFName Path=Filename;
|
||||||
TexGrab.ShrinkToFit(false);
|
TexGrab.ShrinkToFit(false);
|
||||||
|
|
||||||
// Setup TriList
|
// Setup TriList
|
||||||
OutTriList.SetTexGrab(TexGrab);
|
OutFaceList.SetTexGrab(TexGrab);
|
||||||
|
|
||||||
// Set up other stuph
|
// Set up other stuph
|
||||||
|
|
||||||
FlatFace[0].vtx[0].x=+0.5f; FlatFace[0].vtx[0].y=+1.0f; FlatFace[0].vtx[0].z=-4.0f;
|
FlatFace[0].vtx[0].x=+0.5f; FlatFace[0].vtx[0].y=+1.0f; FlatFace[0].vtx[0].z=-4.0f;
|
||||||
FlatFace[0].vtx[1].x=-0.5f; FlatFace[0].vtx[1].y= 0.0f; FlatFace[0].vtx[1].z=-4.0f;
|
FlatFace[0].vtx[1].x=-0.5f; FlatFace[0].vtx[1].y= 0.0f; FlatFace[0].vtx[1].z=-4.0f;
|
||||||
FlatFace[0].vtx[2].x=+0.5f; FlatFace[0].vtx[2].y= 0.0f; FlatFace[0].vtx[2].z=-4.0f;
|
FlatFace[0].vtx[2].x=+0.5f; FlatFace[0].vtx[2].y= 0.0f; FlatFace[0].vtx[2].z=-4.0f;
|
||||||
FlatFace[0].uvs[0].u=1; FlatFace[0].uvs[0].v=1;
|
FlatFace[0].uv[0][0]=1; FlatFace[0].uv[0][1]=1;
|
||||||
FlatFace[0].uvs[1].u=0; FlatFace[0].uvs[1].v=0;
|
FlatFace[0].uv[1][0]=0; FlatFace[0].uv[1][1]=0;
|
||||||
FlatFace[0].uvs[2].u=1; FlatFace[0].uvs[2].v=0;
|
FlatFace[0].uv[2][0]=1; FlatFace[0].uv[2][1]=0;
|
||||||
|
|
||||||
FlatFace[1].vtx[0].x=-0.5f; FlatFace[1].vtx[0].y= 0.0f; FlatFace[1].vtx[0].z=-4.0f;
|
FlatFace[1].vtx[0].x=-0.5f; FlatFace[1].vtx[0].y= 0.0f; FlatFace[1].vtx[0].z=-4.0f;
|
||||||
FlatFace[1].vtx[1].x=+0.5f; FlatFace[1].vtx[1].y=+1.0f; FlatFace[1].vtx[1].z=-4.0f;
|
FlatFace[1].vtx[1].x=+0.5f; FlatFace[1].vtx[1].y=+1.0f; FlatFace[1].vtx[1].z=-4.0f;
|
||||||
FlatFace[1].vtx[2].x=-0.5f; FlatFace[1].vtx[2].y=+1.0f; FlatFace[1].vtx[2].z=-4.0f;
|
FlatFace[1].vtx[2].x=-0.5f; FlatFace[1].vtx[2].y=+1.0f; FlatFace[1].vtx[2].z=-4.0f;
|
||||||
FlatFace[1].uvs[0].u=0; FlatFace[1].uvs[0].v=0;
|
FlatFace[1].uv[0][0]=0; FlatFace[1].uv[0][1]=0;
|
||||||
FlatFace[1].uvs[1].u=1; FlatFace[1].uvs[1].v=1;
|
FlatFace[1].uv[1][0]=1; FlatFace[1].uv[1][1]=1;
|
||||||
FlatFace[1].uvs[2].u=0; FlatFace[1].uvs[2].v=1;
|
FlatFace[1].uv[2][0]=0; FlatFace[1].uv[2][1]=1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +151,9 @@ GString FilePath;
|
||||||
|
|
||||||
for (int i=0; i<Count; i++)
|
for (int i=0; i<Count; i++)
|
||||||
{
|
{
|
||||||
if (!strcmp(TexPtr,"BLANK")) GObject::Error(ERR_FATAL,"Old Format. Please Re-export\n");
|
GString InName=InPath;
|
||||||
GFName::makeabsolute(InPath,TexPtr,FullName);
|
InName+=TexPtr;
|
||||||
|
GFName::makeabsolute(InPath,InName,FullName);
|
||||||
List.push_back(GString(FullName));
|
List.push_back(GString(FullName));
|
||||||
TexPtr+=strlen(TexPtr)+1;
|
TexPtr+=strlen(TexPtr)+1;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +275,7 @@ void CMkLevel::Process()
|
||||||
ProcessTileBanks();
|
ProcessTileBanks();
|
||||||
printf("Process Layers\n");
|
printf("Process Layers\n");
|
||||||
ProcessLayers();
|
ProcessLayers();
|
||||||
OutTriList.Process();
|
OutFaceList.Process();
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -329,8 +347,8 @@ void CMkLevel::PreProcessTileBank3d()
|
||||||
{
|
{
|
||||||
int i,ListSize=Tile3dList.size();
|
int i,ListSize=Tile3dList.size();
|
||||||
|
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=1; i<ListSize; i++)
|
||||||
{
|
{ // Skip Blank
|
||||||
sExpLayerTile &ThisTile=Tile3dList[i];
|
sExpLayerTile &ThisTile=Tile3dList[i];
|
||||||
ThisTile.Tile=Create3dTile(ThisTile);
|
ThisTile.Tile=Create3dTile(ThisTile);
|
||||||
}
|
}
|
||||||
|
@ -391,19 +409,25 @@ int CMkLevel::Create3dTile(sExpLayerTile &InTile)
|
||||||
{
|
{
|
||||||
sExpTile &SrcTile=InTileList[InTile.Tile];
|
sExpTile &SrcTile=InTileList[InTile.Tile];
|
||||||
CFace F;
|
CFace F;
|
||||||
int i,ListSize;
|
int i,ListSize,p;
|
||||||
CList<sExpTri> SortList;
|
CList<sExpTri> SortList;
|
||||||
CList<float> ZPosList;
|
CList<float> ZPosList;
|
||||||
|
sTile3d ThisTile;
|
||||||
|
int TileID=OutTile3dList.size();
|
||||||
|
|
||||||
|
ThisTile.TriStart=OutFaceList.GetFaceCount();
|
||||||
|
ThisTile.QuadCount=0;
|
||||||
|
ThisTile.QuadStart=0;
|
||||||
|
|
||||||
if (SrcTile.TriCount)
|
if (SrcTile.TriCount)
|
||||||
{
|
{
|
||||||
|
ThisTile.TriCount=SrcTile.TriCount;
|
||||||
for (i=0; i<SrcTile.TriCount; i++)
|
for (i=0; i<SrcTile.TriCount; i++)
|
||||||
{
|
{
|
||||||
int ListPos;
|
int ListPos;
|
||||||
sExpTri ThisTri=InTriList[SrcTile.TriStart+i];
|
sExpTri ThisTri=InTriList[SrcTile.TriStart+i];
|
||||||
float ThisZPos;
|
float ThisZPos;
|
||||||
|
|
||||||
|
|
||||||
ThisZPos=ThisTri.vtx[0].z;
|
ThisZPos=ThisTri.vtx[0].z;
|
||||||
if (ThisZPos>ThisTri.vtx[1].z) ThisZPos=ThisTri.vtx[1].z;
|
if (ThisZPos>ThisTri.vtx[1].z) ThisZPos=ThisTri.vtx[1].z;
|
||||||
if (ThisZPos>ThisTri.vtx[2].z) ThisZPos=ThisTri.vtx[2].z;
|
if (ThisZPos>ThisTri.vtx[2].z) ThisZPos=ThisTri.vtx[2].z;
|
||||||
|
@ -413,69 +437,86 @@ CList<float> ZPosList;
|
||||||
{
|
{
|
||||||
if (ZPosList[ListPos]<ThisZPos) break;
|
if (ZPosList[ListPos]<ThisZPos) break;
|
||||||
}
|
}
|
||||||
// Flip 3d tiles
|
|
||||||
bool SwapPnt=false;
|
|
||||||
|
|
||||||
if (InTile.Flags & PC_TILE_FLAG_MIRROR_X)
|
|
||||||
{
|
|
||||||
ThisTri.vtx[0].x=-ThisTri.vtx[0].x;
|
|
||||||
ThisTri.vtx[1].x=-ThisTri.vtx[1].x;
|
|
||||||
ThisTri.vtx[2].x=-ThisTri.vtx[2].x;
|
|
||||||
SwapPnt^=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (InTile.Flags & PC_TILE_FLAG_MIRROR_Y)
|
|
||||||
{
|
|
||||||
ThisTri.vtx[0].y =1.0-ThisTri.vtx[0].y;
|
|
||||||
ThisTri.vtx[1].y =1.0-ThisTri.vtx[1].y;
|
|
||||||
ThisTri.vtx[2].y =1.0-ThisTri.vtx[2].y;
|
|
||||||
SwapPnt^=1;
|
|
||||||
}
|
|
||||||
if (SwapPnt)
|
|
||||||
{
|
|
||||||
Vector3 TmpV=ThisTri.vtx[0];
|
|
||||||
ThisTri.vtx[0]=ThisTri.vtx[1];
|
|
||||||
ThisTri.vtx[1]=TmpV;
|
|
||||||
float TmpUVu=ThisTri.uv[0][0];
|
|
||||||
float TmpUVv=ThisTri.uv[0][1];
|
|
||||||
ThisTri.uv[0][0]=ThisTri.uv[1][0];
|
|
||||||
ThisTri.uv[0][1]=ThisTri.uv[1][1];
|
|
||||||
ThisTri.uv[1][0]=TmpUVu;
|
|
||||||
ThisTri.uv[1][1]=TmpUVv;
|
|
||||||
}
|
|
||||||
SortList.insert(ListPos,ThisTri);
|
SortList.insert(ListPos,ThisTri);
|
||||||
ZPosList.insert(ListPos,ThisZPos);
|
ZPosList.insert(ListPos,ThisZPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add sorted list to main list
|
}
|
||||||
|
else
|
||||||
|
{ // create flat tile
|
||||||
|
int TexID=Create2dTex(InTile);
|
||||||
|
|
||||||
for (i=0; i<SrcTile.TriCount; i++)
|
ThisTile.TriCount=2;
|
||||||
|
for (int i=0; i<2; i++)
|
||||||
|
{
|
||||||
|
FlatFace[i].TexID=TexID;
|
||||||
|
SortList.push_back(FlatFace[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add sorted list to main list
|
||||||
|
ListSize=SortList.size();
|
||||||
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sExpTri &ThisTri=SortList[i];
|
sExpTri &ThisTri=SortList[i];
|
||||||
CFace F;
|
CFace F;
|
||||||
|
bool SwapPnt=false;
|
||||||
|
|
||||||
|
if (SrcTile.TriCount)
|
||||||
|
{
|
||||||
F.TexName=InTexNameList[ThisTri.TexID];
|
F.TexName=InTexNameList[ThisTri.TexID];
|
||||||
F.Mat=-1;
|
F.Mat=-1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
F.Mat=ThisTri.TexID;
|
||||||
|
}
|
||||||
|
|
||||||
for (int p=0; p<3; p++)
|
for (p=0; p<3; p++)
|
||||||
{
|
{
|
||||||
F.vtx[p]=ThisTri.vtx[p];
|
F.vtx[p]=ThisTri.vtx[p];
|
||||||
F.uvs[p].u=ThisTri.uv[p][0];
|
F.uvs[p].u=ThisTri.uv[p][0];
|
||||||
F.uvs[p].v=ThisTri.uv[p][1];
|
F.uvs[p].v=ThisTri.uv[p][1];
|
||||||
}
|
}
|
||||||
OutTriList.AddFace(F,true);
|
// Flip 3d tiles
|
||||||
}
|
|
||||||
}
|
if (InTile.Flags & PC_TILE_FLAG_MIRROR_X)
|
||||||
else
|
|
||||||
{ // create flat tile
|
|
||||||
int TexID=Create2dTex(InTile);
|
|
||||||
for (int i=0; i<2; i++)
|
|
||||||
{
|
{
|
||||||
FlatFace[i].Mat=TexID;
|
F.vtx[0].x=-F.vtx[0].x;
|
||||||
OutTriList.AddFace(FlatFace[i],true);
|
F.vtx[1].x=-F.vtx[1].x;
|
||||||
}
|
F.vtx[2].x=-F.vtx[2].x;
|
||||||
|
SwapPnt^=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
if (InTile.Flags & PC_TILE_FLAG_MIRROR_Y)
|
||||||
|
{
|
||||||
|
F.vtx[0].y =1.0-F.vtx[0].y;
|
||||||
|
F.vtx[1].y =1.0-F.vtx[1].y;
|
||||||
|
F.vtx[2].y =1.0-F.vtx[2].y;
|
||||||
|
SwapPnt^=1;
|
||||||
|
}
|
||||||
|
if (SwapPnt)
|
||||||
|
{
|
||||||
|
Vector3 TmpV=F.vtx[0];
|
||||||
|
F.vtx[0]=F.vtx[1];
|
||||||
|
F.vtx[1]=TmpV;
|
||||||
|
sUV TmpUV=F.uvs[0];
|
||||||
|
F.uvs[0]=F.uvs[1];
|
||||||
|
F.uvs[1]=TmpUV;
|
||||||
|
}
|
||||||
|
// Adjust Depth
|
||||||
|
for (p=0;p<3;p++)
|
||||||
|
{
|
||||||
|
// F.vtx[p].z-=4.0f;
|
||||||
|
// printf("%f\n",F.vtx[p].z);
|
||||||
|
}
|
||||||
|
|
||||||
|
OutFaceList.AddFace(F,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
OutTile3dList.push_back(ThisTile);
|
||||||
|
|
||||||
|
return(TileID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -645,60 +686,68 @@ u8 *RGB1=Tex1.RGB;
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::Write()
|
void CMkLevel::Write()
|
||||||
{
|
{
|
||||||
|
GString OutFilename=OutName+".Lvl";
|
||||||
|
|
||||||
|
File=fopen(OutFilename,"wb");
|
||||||
|
|
||||||
|
fwrite(&LevelHdr,1,sizeof(sLevelHdr),File);
|
||||||
|
|
||||||
WriteLevel();
|
WriteLevel();
|
||||||
WriteTileBank();
|
WriteTileBank();
|
||||||
|
|
||||||
|
// rewrite header
|
||||||
|
fseek(File,0,SEEK_SET);
|
||||||
|
fwrite(&LevelHdr,1,sizeof(sLevelHdr),File);
|
||||||
|
|
||||||
|
fclose(File);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
int MinOT=123456,MaxOT=0;
|
||||||
|
|
||||||
void CMkLevel::WriteTileBank()
|
void CMkLevel::WriteTileBank()
|
||||||
{
|
{
|
||||||
GString OutFilename=OutName+".Tbk";
|
|
||||||
int i,ListSize;
|
int i,ListSize;
|
||||||
File=fopen(OutFilename,"wb");
|
|
||||||
|
|
||||||
fwrite(&TileBankHdr,1,sizeof(sTileBankHdr),File);
|
|
||||||
|
|
||||||
// 2d Tilebank
|
// 2d Tilebank
|
||||||
TileBankHdr.TileBank2d=(sTile2d*)ftell(File);
|
LevelHdr.TileBank2d=(sTile2d*)ftell(File);
|
||||||
ListSize=OutTile2dList.size();
|
ListSize=OutTile2dList.size();
|
||||||
|
printf("%i 2d tiles\n",ListSize);
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sTile2d &OutTile=OutTile2dList[i];
|
sTile2d &OutTile=OutTile2dList[i];
|
||||||
fwrite(&OutTile,1,sizeof(sTile2d),File);
|
fwrite(&OutTile,1,sizeof(sTile2d),File);
|
||||||
}
|
}
|
||||||
// 3d Tilebank
|
// 3d Tilebank
|
||||||
TileBankHdr.TileBank3d=(sTile3d*)ftell(File);
|
LevelHdr.TileBank3d=(sTile3d*)ftell(File);
|
||||||
ListSize=OutTile3dList.size();
|
ListSize=OutTile3dList.size();
|
||||||
|
printf("%i 3d tiles\n",ListSize);
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sTile3d &OutTile=OutTile3dList[i];
|
sTile3d &OutTile=OutTile3dList[i];
|
||||||
fwrite(&OutTile,1,sizeof(sTile3d),File);
|
fwrite(&OutTile,1,sizeof(sTile3d),File);
|
||||||
}
|
}
|
||||||
// TriList
|
// TriList
|
||||||
TileBankHdr.TriList=(sTri*)WriteTriList();
|
LevelHdr.TriList=(sTri*)WriteTriList();
|
||||||
|
|
||||||
// QuadList
|
// QuadList
|
||||||
|
LevelHdr.QuadList=(sQuad*)WriteQuadList();
|
||||||
|
printf("OT %i -> %i\n",MinOT,MaxOT);
|
||||||
|
|
||||||
// VtxList
|
// VtxList
|
||||||
TileBankHdr.VtxList=(sVtx*)ftell(File);
|
LevelHdr.VtxList=(sVtx*)WriteVtxList();
|
||||||
OutTriList.WriteVtxList(File);
|
|
||||||
|
|
||||||
// rewrite header
|
|
||||||
fseek(File,0,SEEK_SET);
|
|
||||||
fwrite(&TileBankHdr,1,sizeof(sTileBankHdr),File);
|
|
||||||
|
|
||||||
fclose(File);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
int CMkLevel::WriteTriList()
|
int CMkLevel::WriteTriList()
|
||||||
{
|
{
|
||||||
vector<sTri> &TriList=OutTriList.GetOutTriList();
|
vector<sTri> &TriList=OutFaceList.GetOutTriList();
|
||||||
vector<sVtx> const &VtxList=OutTriList.GetVtxList();
|
vector<sVtx> const &VtxList=OutFaceList.GetVtxList();
|
||||||
int ThisPos=ftell(File);
|
int ThisPos=ftell(File);
|
||||||
int i,ListSize=TriList.size();
|
int i,ListSize=TriList.size();
|
||||||
int MaxOT=0;
|
|
||||||
for (i=0;i<ListSize;i++)
|
for (i=0;i<ListSize;i++)
|
||||||
{
|
{
|
||||||
sTri &T=TriList[i];
|
sTri &T=TriList[i];
|
||||||
|
@ -713,57 +762,109 @@ int MaxOT=0;
|
||||||
{
|
{
|
||||||
if (OtOfs<Z[p]) OtOfs=Z[p];
|
if (OtOfs<Z[p]) OtOfs=Z[p];
|
||||||
}
|
}
|
||||||
|
OtOfs/=4;
|
||||||
|
if (MinOT>OtOfs) MinOT=OtOfs;
|
||||||
if (MaxOT<OtOfs) MaxOT=OtOfs;
|
if (MaxOT<OtOfs) MaxOT=OtOfs;
|
||||||
if (OtOfs>63) OtOfs=63;
|
if (OtOfs>15) OtOfs=15;
|
||||||
|
|
||||||
// Write It
|
// Write It
|
||||||
fwrite(&T,1,sizeof(sTri),File);
|
fwrite(&T,1,sizeof(sTri),File);
|
||||||
}
|
}
|
||||||
printf("MAXOT = %i\n",MaxOT);
|
printf("Tri %i\n",ListSize);
|
||||||
|
|
||||||
return(ThisPos);
|
return(ThisPos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
int CMkLevel::WriteQuadList()
|
||||||
|
{
|
||||||
|
vector<sQuad> &QuadList=OutFaceList.GetOutQuadList();
|
||||||
|
vector<sVtx> const &VtxList=OutFaceList.GetVtxList();
|
||||||
|
int ThisPos=ftell(File);
|
||||||
|
int i,ListSize=QuadList.size();
|
||||||
|
|
||||||
|
for (i=0;i<ListSize;i++)
|
||||||
|
{
|
||||||
|
sQuad &Q=QuadList[i];
|
||||||
|
int Z[4];
|
||||||
|
int OtOfs=0;
|
||||||
|
// Calc OtOfs
|
||||||
|
Z[0]=abs(VtxList[Q.P0].vz);
|
||||||
|
Z[1]=abs(VtxList[Q.P1].vz);
|
||||||
|
Z[2]=abs(VtxList[Q.P2].vz);
|
||||||
|
Z[3]=abs(VtxList[Q.P3].vz);
|
||||||
|
|
||||||
|
for (int p=0; p<4; p++)
|
||||||
|
{
|
||||||
|
if (OtOfs<Z[p]) OtOfs=Z[p];
|
||||||
|
}
|
||||||
|
if (MinOT>OtOfs) MinOT=OtOfs;
|
||||||
|
if (MaxOT<OtOfs) MaxOT=OtOfs;
|
||||||
|
if (OtOfs>63) OtOfs=63;
|
||||||
|
// Write It
|
||||||
|
fwrite(&Q,1,sizeof(sQuad),File);
|
||||||
|
}
|
||||||
|
printf("Quad %i\n",ListSize,MaxOT);
|
||||||
|
return(ThisPos);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
int CMkLevel::WriteVtxList()
|
||||||
|
{
|
||||||
|
vector<sVtx> const &VtxList=OutFaceList.GetVtxList();
|
||||||
|
int i,ListSize=VtxList.size();
|
||||||
|
int Pos=ftell(File);
|
||||||
|
sVtx Ofs;
|
||||||
|
|
||||||
|
Ofs.vx=-0;
|
||||||
|
Ofs.vy=-0;
|
||||||
|
Ofs.vz=-4*Scale;
|
||||||
|
|
||||||
|
for (i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
sVtx const &In=VtxList[i];
|
||||||
|
sVtx Out;
|
||||||
|
|
||||||
|
Out.vx=+(In.vx+Ofs.vx);
|
||||||
|
Out.vy=-(In.vy+Ofs.vy);
|
||||||
|
Out.vz=+(In.vz+Ofs.vz);
|
||||||
|
|
||||||
|
fwrite(&Out,1,sizeof(sVtx),File);
|
||||||
|
}
|
||||||
|
return(Pos);
|
||||||
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//*** Write *****************************************************************
|
//*** Write *****************************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::WriteLevel()
|
void CMkLevel::WriteLevel()
|
||||||
{
|
{
|
||||||
GString OutFilename=OutName+".Lvl";
|
|
||||||
|
|
||||||
File=fopen(OutFilename,"wb");
|
|
||||||
|
|
||||||
fwrite(&LvlHdr,1,sizeof(sLvlHdr),File);
|
|
||||||
|
|
||||||
WriteLayers();
|
WriteLayers();
|
||||||
|
|
||||||
// rewrite header
|
|
||||||
fseek(File,0,SEEK_SET);
|
|
||||||
fwrite(&LvlHdr,1,sizeof(sLvlHdr),File);
|
|
||||||
|
|
||||||
fclose(File);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::WriteLayers()
|
void CMkLevel::WriteLayers()
|
||||||
{
|
{
|
||||||
// Back (Shade)
|
// Back (Shade)
|
||||||
LvlHdr.BackLayer=WriteLayer(LAYER_TYPE_SHADE,LAYER_SUBTYPE_BACK,0);//"Shade");
|
LevelHdr.BackLayer=WriteLayer(LAYER_TYPE_SHADE,LAYER_SUBTYPE_BACK,0);//"Shade");
|
||||||
// Mid
|
// Mid
|
||||||
LvlHdr.MidLayer=WriteLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_MID,"Mid");
|
LevelHdr.MidLayer=WriteLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_MID,"Mid");
|
||||||
// Action
|
// Action
|
||||||
LvlHdr.ActionLayer=WriteLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION,"Action");
|
LevelHdr.ActionLayer=WriteLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_ACTION,"Action");
|
||||||
// Fore
|
// Fore
|
||||||
// LvlHdr.ForeLayer=WriteLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_FORE,"Fore");
|
// LevelHdr.ForeLayer=WriteLayer(LAYER_TYPE_TILE,LAYER_SUBTYPE_FORE,"Fore");
|
||||||
// Collision
|
// Collision
|
||||||
LvlHdr.CollisionLayer=WriteLayer(LAYER_TYPE_COLLISION,LAYER_SUBTYPE_NONE,"Collision");
|
LevelHdr.CollisionLayer=WriteLayer(LAYER_TYPE_COLLISION,LAYER_SUBTYPE_NONE,"Collision");
|
||||||
|
|
||||||
// Things
|
// Things
|
||||||
LvlHdr.ActorList=WriteThings(LAYER_TYPE_ACTOR,"Actor List");
|
LevelHdr.ActorList=WriteThings(LAYER_TYPE_ACTOR,"Actor List");
|
||||||
LvlHdr.ItemList=WriteThings(LAYER_TYPE_ITEM,"Item List");
|
LevelHdr.ItemList=WriteThings(LAYER_TYPE_ITEM,"Item List");
|
||||||
LvlHdr.PlatformList=WriteThings(LAYER_TYPE_PLATFORM,"Platform List");
|
LevelHdr.PlatformList=WriteThings(LAYER_TYPE_PLATFORM,"Platform List");
|
||||||
LvlHdr.TriggerList=WriteThings(LAYER_TYPE_TRIGGER,"FX List");
|
LevelHdr.TriggerList=WriteThings(LAYER_TYPE_TRIGGER,"Trigger List");
|
||||||
LvlHdr.FXList=WriteThings(LAYER_TYPE_FX,"FX List");
|
LevelHdr.FXList=WriteThings(LAYER_TYPE_FX,"FX List");
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -796,6 +897,7 @@ int Ofs;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
Ofs=ThisLayer->Write(File,LayerName,LevelName);
|
Ofs=ThisLayer->Write(File,LayerName,LevelName);
|
||||||
|
// printf("%s %i\n",LayerName,Ofs);
|
||||||
PadFile(File);
|
PadFile(File);
|
||||||
return(Ofs);
|
return(Ofs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ public:
|
||||||
CMkLevel();
|
CMkLevel();
|
||||||
~CMkLevel();
|
~CMkLevel();
|
||||||
|
|
||||||
void Init(const char *InFilename,const char *OutPath,int TPBase,int TPW,int TPH);
|
void SetAppDir(const char *Path);
|
||||||
|
void Init(const char *InFilename,const char *OutFilename,int TPBase,int TPW,int TPH);
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
|
|
||||||
|
@ -62,9 +63,10 @@ public:
|
||||||
int BuildTileTex(sMkLevelTex &InTex);
|
int BuildTileTex(sMkLevelTex &InTex);
|
||||||
|
|
||||||
char *GetConfigStr(const char *Grp,const char *Key) {return(Config.GetStr(Grp,Key));}
|
char *GetConfigStr(const char *Grp,const char *Key) {return(Config.GetStr(Grp,Key));}
|
||||||
|
CIni &GetConfig() {return(Config);}
|
||||||
CTexGrab &GetTexGrab() {return(TexGrab);}
|
CTexGrab &GetTexGrab() {return(TexGrab);}
|
||||||
|
|
||||||
void SetStart(int X,int Y) {LvlHdr.PlayerStartX=X; LvlHdr.PlayerStartY=Y;}
|
void SetStart(int X,int Y) {LevelHdr.PlayerStartX=X; LevelHdr.PlayerStartY=Y;}
|
||||||
protected:
|
protected:
|
||||||
CMkLevelLayer *FindLayer(int Type,int SubType);
|
CMkLevelLayer *FindLayer(int Type,int SubType);
|
||||||
void LoadStrList(CList<GString> &List,char *TexPtr,int Count);
|
void LoadStrList(CList<GString> &List,char *TexPtr,int Count);
|
||||||
|
@ -88,13 +90,15 @@ protected:
|
||||||
int WriteThings(int Type,const char *LayerName);
|
int WriteThings(int Type,const char *LayerName);
|
||||||
int WriteTriList();
|
int WriteTriList();
|
||||||
int WriteQuadList();
|
int WriteQuadList();
|
||||||
|
int WriteVtxList();
|
||||||
void WriteTileBank();
|
void WriteTileBank();
|
||||||
|
|
||||||
void BuildTiles();
|
void BuildTiles();
|
||||||
|
|
||||||
FILE *File;
|
FILE *File;
|
||||||
GString InFilename,InPath,LevelName;
|
GString InFilename,InPath,LevelName;
|
||||||
GString OutPath,OutName;
|
GString OutName;
|
||||||
|
GString AppDir;
|
||||||
|
|
||||||
int TileW,TileH;
|
int TileW,TileH;
|
||||||
CIni Config;
|
CIni Config;
|
||||||
|
@ -106,7 +110,7 @@ protected:
|
||||||
CList<GString> UsedSetNameList;
|
CList<GString> UsedSetNameList;
|
||||||
CList<GString> UsedTexNameList;
|
CList<GString> UsedTexNameList;
|
||||||
|
|
||||||
CFaceStore OutTriList;
|
CFaceStore OutFaceList;
|
||||||
CList<sTile2d> OutTile2dList;
|
CList<sTile2d> OutTile2dList;
|
||||||
CList<sTile3d> OutTile3dList;
|
CList<sTile3d> OutTile3dList;
|
||||||
|
|
||||||
|
@ -118,9 +122,9 @@ protected:
|
||||||
|
|
||||||
vector<CMkLevelLayer*> LayerList;
|
vector<CMkLevelLayer*> LayerList;
|
||||||
|
|
||||||
sLvlHdr LvlHdr;
|
sLevelHdr LevelHdr;
|
||||||
sTileBankHdr TileBankHdr;
|
// sTileBankHdr TileBankHdr;
|
||||||
CFace FlatFace[2];
|
sExpTri FlatFace[2];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -231,14 +231,15 @@ int Clut=getClut(R.x,R.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CActorPool::AddActor(FileEquate Filename)
|
int CActorPool::AddActor(FileEquate Filename)
|
||||||
{
|
{
|
||||||
sActorPool *Actor;
|
sActorPool *Actor;
|
||||||
int Idx=FindActorInPool(Filename);
|
int Idx=FindActorInPool(Filename);
|
||||||
|
|
||||||
if (Idx!=-1) return;
|
if (Idx!=-1) return(Idx);
|
||||||
// Load it
|
// Doesnt Exist, soooooo, Load it
|
||||||
LoadActor(Filename);
|
Idx=LoadActor(Filename);
|
||||||
|
return(Idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -249,7 +250,10 @@ int Idx;
|
||||||
|
|
||||||
// Find Actor in Pool
|
// Find Actor in Pool
|
||||||
Idx=FindActorInPool(Filename);
|
Idx=FindActorInPool(Filename);
|
||||||
if (Idx==-1) ASSERT(!"Actor Not Loaded");
|
if (Idx==-1)
|
||||||
|
{
|
||||||
|
AddActor(Filename);
|
||||||
|
}
|
||||||
|
|
||||||
sActorPool &ThisActor=ActorPool[Idx];
|
sActorPool &ThisActor=ActorPool[Idx];
|
||||||
Actor=new ("CActorGfx") CActorGfx;
|
Actor=new ("CActorGfx") CActorGfx;
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
|
|
||||||
static void AddActor(FileEquate Filename);
|
static int AddActor(FileEquate Filename);
|
||||||
static CActorGfx *GetActor(FileEquate Filename);
|
static CActorGfx *GetActor(FileEquate Filename);
|
||||||
static void DumpActors();
|
static void DumpActors();
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ sBackRGBTable CLayerBack::BackRGBTable[]=
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerBack::CLayerBack(sLvlHdr *LvlHdr,sLayerHdr *Hdr) : CLayerTile(LvlHdr,Hdr)
|
CLayerBack::CLayerBack(sLevelHdr *LevelHdr,sLayerHdr *Hdr) : CLayerTile(LevelHdr,Hdr)
|
||||||
{
|
{
|
||||||
Data=(sLayerShadeHdr*)MakePtr(Hdr,sizeof(sLayerHdr));
|
Data=(sLayerShadeHdr*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
COLOR=1<<3,
|
COLOR=1<<3,
|
||||||
};
|
};
|
||||||
|
|
||||||
CLayerBack(sLvlHdr *LvlHdr,sLayerHdr *Hdr);
|
CLayerBack(sLevelHdr *LevelHdr,sLayerHdr *Hdr);
|
||||||
~CLayerBack();
|
~CLayerBack();
|
||||||
|
|
||||||
void init(DVECTOR &MapPos,int Shift);
|
void init(DVECTOR &MapPos,int Shift);
|
||||||
|
|
|
@ -19,14 +19,14 @@ const u32 YInc=16<<16;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerTile::CLayerTile(sLvlHdr *LvlHdr,sLayerHdr *Hdr)
|
CLayerTile::CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr)
|
||||||
{
|
{
|
||||||
LayerHdr=Hdr;
|
LayerHdr=Hdr;
|
||||||
MapWidth=LayerHdr->Width;
|
MapWidth=LayerHdr->Width;
|
||||||
MapHeight=LayerHdr->Height;
|
MapHeight=LayerHdr->Height;
|
||||||
|
|
||||||
printf("%i %i\n",MapWidth,MapHeight);
|
printf("%i %i\n",MapWidth,MapHeight);
|
||||||
TileBank2d=LvlHdr->TileBank2d;
|
TileBank2d=LevelHdr->TileBank2d;
|
||||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
SCREEN_TILE_SIZE=SCREEN_TILE_WIDTH*SCREEN_TILE_HEIGHT
|
SCREEN_TILE_SIZE=SCREEN_TILE_WIDTH*SCREEN_TILE_HEIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
CLayerTile(sLvlHdr *LvlHdr,sLayerHdr *Hdr);
|
CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr);
|
||||||
virtual ~CLayerTile();
|
virtual ~CLayerTile();
|
||||||
|
|
||||||
virtual void init(DVECTOR &MapPos,int Shift);
|
virtual void init(DVECTOR &MapPos,int Shift);
|
||||||
|
|
|
@ -23,12 +23,12 @@ static FontBank *Font;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerTile3d::CLayerTile3d(sLvlHdr *LvlHdr,sLayerHdr *Hdr) : CLayerTile(LvlHdr,Hdr)
|
CLayerTile3d::CLayerTile3d(sLevelHdr *LevelHdr,sLayerHdr *Hdr) : CLayerTile(LevelHdr,Hdr)
|
||||||
{
|
{
|
||||||
TileBank3d=LvlHdr->TileBank3d;
|
TileBank3d=LevelHdr->TileBank3d;
|
||||||
TriList=LvlHdr->TriList;
|
TriList=LevelHdr->TriList;
|
||||||
QuadList=LvlHdr->QuadList;
|
QuadList=LevelHdr->QuadList;
|
||||||
VtxList=LvlHdr->VtxList;
|
VtxList=LevelHdr->VtxList;
|
||||||
|
|
||||||
#if defined(_SHOW_POLYZ_)
|
#if defined(_SHOW_POLYZ_)
|
||||||
Font=new ("PrimFont") FontBank;
|
Font=new ("PrimFont") FontBank;
|
||||||
|
|
|
@ -11,7 +11,7 @@ class FontBank;
|
||||||
class CLayerTile3d : public CLayerTile
|
class CLayerTile3d : public CLayerTile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CLayerTile3d(sLvlHdr *LvlHdr,sLayerHdr *Hdr);
|
CLayerTile3d(sLevelHdr *LevelHdr,sLayerHdr *Hdr);
|
||||||
~CLayerTile3d();
|
~CLayerTile3d();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -135,18 +135,18 @@ sLvlTab *lvlTab=&LvlTable[LevelNo];
|
||||||
|
|
||||||
DisplayLoadingScreen(lvlTab);
|
DisplayLoadingScreen(lvlTab);
|
||||||
|
|
||||||
LevelHdr=(sLvlHdr*)CFileIO::loadFile(lvlTab->LevelFilename,"Level");
|
LevelHdr=(sLevelHdr*)CFileIO::loadFile(lvlTab->LevelFilename,"Level");
|
||||||
LevelHdr->TileBank2d=(sTile2d*) MakePtr(LevelHdr,(int)LevelHdr->TileBank2d);
|
LevelHdr->TileBank2d=(sTile2d*) MakePtr(LevelHdr,(int)LevelHdr->TileBank2d);
|
||||||
LevelHdr->TileBank3d=(sTile3d*) MakePtr(LevelHdr,(int)LevelHdr->TileBank3d);
|
LevelHdr->TileBank3d=(sTile3d*) MakePtr(LevelHdr,(int)LevelHdr->TileBank3d);
|
||||||
LevelHdr->TriList=(sTri*) MakePtr(LevelHdr,(int)LevelHdr->TriList);
|
LevelHdr->TriList=(sTri*) MakePtr(LevelHdr,(int)LevelHdr->TriList);
|
||||||
LevelHdr->QuadList=(sQuad*) MakePtr(LevelHdr,(int)LevelHdr->QuadList);
|
LevelHdr->QuadList=(sQuad*) MakePtr(LevelHdr,(int)LevelHdr->QuadList);
|
||||||
LevelHdr->VtxList=(sVtx*) MakePtr(LevelHdr,(int)LevelHdr->VtxList);
|
LevelHdr->VtxList=(sVtx*) MakePtr(LevelHdr,(int)LevelHdr->VtxList);
|
||||||
|
|
||||||
LevelHdr->ActorList=0;
|
printf("ActorList %i\n",(int)LevelHdr->ActorList);
|
||||||
LevelHdr->FXList=0;
|
printf("ItemList %i\n",(int)LevelHdr->ItemList);
|
||||||
LevelHdr->ItemList=0;
|
printf("Platfrom List %i\n",(int)LevelHdr->PlatformList);
|
||||||
LevelHdr->PlatformList=0;
|
printf("TriggerList %i\n",(int)LevelHdr->TriggerList);
|
||||||
LevelHdr->TriggerList=0;
|
printf("FXList %i\n",(int)LevelHdr->FXList);
|
||||||
|
|
||||||
m_levelTPage=TPLoadTex(lvlTab->TexFilename);
|
m_levelTPage=TPLoadTex(lvlTab->TexFilename);
|
||||||
|
|
||||||
|
@ -244,7 +244,6 @@ void CLevel::initLayers()
|
||||||
// Actors
|
// Actors
|
||||||
if (LevelHdr->ActorList)
|
if (LevelHdr->ActorList)
|
||||||
{
|
{
|
||||||
|
|
||||||
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ActorList);
|
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ActorList);
|
||||||
ActorCount=Hdr->Count;
|
ActorCount=Hdr->Count;
|
||||||
ActorList=(sThingActor**)MemAlloc(ActorCount*sizeof(sThingActor**),"Actor List");
|
ActorList=(sThingActor**)MemAlloc(ActorCount*sizeof(sThingActor**),"Actor List");
|
||||||
|
@ -255,7 +254,6 @@ void CLevel::initLayers()
|
||||||
ThingPtr+=sizeof(sThingActor);
|
ThingPtr+=sizeof(sThingActor);
|
||||||
ThingPtr+=ActorList[i]->PointCount*sizeof(u16)*2;
|
ThingPtr+=ActorList[i]->PointCount*sizeof(u16)*2;
|
||||||
}
|
}
|
||||||
if (Hdr->Count>8) Hdr->Count=0;
|
|
||||||
}
|
}
|
||||||
// Items
|
// Items
|
||||||
if (LevelHdr->ItemList)
|
if (LevelHdr->ItemList)
|
||||||
|
@ -263,7 +261,6 @@ void CLevel::initLayers()
|
||||||
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ItemList);
|
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ItemList);
|
||||||
ItemCount=Hdr->Count;
|
ItemCount=Hdr->Count;
|
||||||
ItemList=(sThingItem*)MakePtr(Hdr,sizeof(sThingHdr));
|
ItemList=(sThingItem*)MakePtr(Hdr,sizeof(sThingHdr));
|
||||||
|
|
||||||
DVECTOR pos;
|
DVECTOR pos;
|
||||||
for(int i=0;i<ItemCount;i++)
|
for(int i=0;i<ItemCount;i++)
|
||||||
{
|
{
|
||||||
|
@ -287,7 +284,6 @@ void CLevel::initLayers()
|
||||||
ThingPtr+=sizeof(sThingPlatform);
|
ThingPtr+=sizeof(sThingPlatform);
|
||||||
ThingPtr+=PlatformList[i]->PointCount*sizeof(u16)*2;
|
ThingPtr+=PlatformList[i]->PointCount*sizeof(u16)*2;
|
||||||
}
|
}
|
||||||
if (Hdr->Count>8) Hdr->Count=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Triggers
|
// Triggers
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
void initLayers();
|
void initLayers();
|
||||||
void DisplayLoadingScreen(sLvlTab *lvlTab);
|
void DisplayLoadingScreen(sLvlTab *lvlTab);
|
||||||
|
|
||||||
sLvlHdr *LevelHdr;
|
sLevelHdr *LevelHdr;
|
||||||
|
|
||||||
static DVECTOR MapPos;
|
static DVECTOR MapPos;
|
||||||
static DVECTOR s_playerSpawnPos;
|
static DVECTOR s_playerSpawnPos;
|
||||||
|
|
|
@ -183,7 +183,7 @@ struct sLayerShadeHdr
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Header
|
// Header
|
||||||
struct sLvlHdr
|
struct sLevelHdr
|
||||||
{
|
{
|
||||||
u32 BackLayer;
|
u32 BackLayer;
|
||||||
u32 MidLayer;
|
u32 MidLayer;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue