This commit is contained in:
Daveo 2001-04-27 16:16:23 +00:00
parent 5bdb644844
commit 0db77d2a36
4 changed files with 141 additions and 49 deletions

View File

@ -24,7 +24,7 @@ int i,ListSize;
for (i=0; i<ListSize; i++)
{
sMkLevelLayerThing &ThisThing=ThingList[i];
RemapTable[i]=Core->AddPlatform(ThisThing);
RemapTable[i]=Core->AddModel(ThisThing);
}
printf("%i Platforms\n",ThingList.size());

View File

@ -50,6 +50,10 @@ int Count;
TextPtr+=strlen(TextPtr)+1;
TPH=atol(TextPtr);
break;
case 'm':
TpStr= CheckFileString(String);
Level.AddModel(TpStr);
break;
case 'q':
StripLength=4;
break;
@ -78,10 +82,9 @@ void Usage(char *ErrStr)
printf(" -o:[FILE] Set output File (AND Dir)\n");
printf(" -s:nn Set Scaling value\n");
printf(" -t:p,w,h Set TPage No,Width,Height\n");
// printf(" -c: Set Chapter Name\n");
// printf(" -l: Set Level Name\n");
printf(" -m: Add Model\n");
printf(" -d: Enable Debug output\n");
// printf(" -q: Enable Quadding\n");
printf(" -q: Enable Quadding\n");
GObject::Error(ERR_FATAL,ErrStr);
}

View File

@ -113,6 +113,118 @@ GFName Path;
FlatFace[1].uv[2][0]=0; FlatFace[1].uv[2][1]=1;
}
//***************************************************************************
int CMkLevel::AddModel(GString &Filename)
{
GFName Path=Filename;
sMkLevelModel ThisModel;
int Idx;
CScene Scene;
ThisModel.Name=GFName(Filename).File();
Idx=ModelList.Find(ThisModel);
if (Idx!=-1)
{
return(Idx);
}
Idx=ModelList.size();
Path.File("");
Path.Ext("");
GString RootPath=Path.FullName();
// Load Model and add
int TriStart=ModelFaceList.GetFaceCount();;
Scene.Load(Filename);
BuildModel(Scene,RootPath,0);
ThisModel.TriStart=TriStart;
ThisModel.TriCount=ModelFaceList.GetFaceCount()-TriStart;
ModelList.Add(ThisModel);
return(Idx);
}
//***************************************************************************
void CMkLevel::BuildModel(CScene &Scene,GString &RootPath,int Node)
{
CNode &ThisNode=Scene.GetNode(Node);
vector<sGinTri> const &NodeTriList = ThisNode.GetTris();
vector<Vector3> const &NodeVtxList = ThisNode.GetPts();
vector<int> const &NodeMatList = ThisNode.GetTriMaterial();
vector<sUVTri> const &NodeUVList = ThisNode.GetUVTris();
vector<GString> const &SceneTexList= Scene.GetTexList();
vector<int> const &SceneUsedMatList=Scene.GetUsedMaterialIdx();
int TriCount=NodeTriList.size();
for (int T=0; T<TriCount; T++)
{
int Mat=SceneUsedMatList[NodeMatList[T]];
if (Mat>SceneTexList.size()) GObject::Error(ERR_FATAL,"Crap Material ID, wanted %i, only have %i\n",Mat,SceneTexList.size());
GString TexName=RootPath+SceneTexList[Mat];
ModelFaceList.AddFace( NodeVtxList, NodeTriList[T], NodeUVList[T], TexName,0,false);
}
int ChildCount=ThisNode.GetPruneChildCount();
for (int Loop=0;Loop<ChildCount ; Loop++) BuildModel(Scene,RootPath,ThisNode.PruneChildList[Loop]);
}
//***************************************************************************
int CMkLevel::AddModel(sMkLevelLayerThing &ThisThing)
{
sMkLevelModel ThisModel;
int Idx;
ThisModel.Name=ThisThing.Name;
Idx=ModelList.Find(ThisModel);
if (Idx!=-1)
{
return(Idx);
}
Idx=ModelList.size();
ThisModel.TriStart=ModelFaceList.GetFaceCount();
ThisModel.TriCount=ThisThing.Data.TriCount;
// Add tri data
for (int i=0;i<ThisModel.TriCount; i++)
{
sExpTri &ThisTri=InTriList[ThisThing.Data.TriStart+i];
CFace F;
ExpTri2Face(ThisTri,F);
ModelFaceList.AddFace(F,false);
}
ModelList.Add(ThisModel);
return(Idx);
}
//***************************************************************************
void CMkLevel::ProcessModels()
{
int i,ListSize;
int TriStart=OutFaceList.GetFaceCount();
// Add faces
ListSize=ModelFaceList.GetFaceCount();
for (i=0; i<ListSize; i++)
{
OutFaceList.AddFace(ModelFaceList[i],true);
}
// Update models
ListSize=ModelList.size();
for (i=0; i<ListSize; i++)
{
printf("%s = %i %i\n",ModelList[i].Name,ModelList[i].TriStart,ModelList[i].TriCount);
ModelList[i].TriStart+=TriStart;
}
}
//***************************************************************************
//*** Load ******************************************************************
//***************************************************************************
@ -273,6 +385,8 @@ void CMkLevel::Process()
{
printf("PreProcess Layers\n");
PreProcessLayers();
printf("Process Models\n");
ProcessModels();
printf("Process Tilebank\n");
ProcessTileBanks();
printf("Process Layers\n");
@ -392,38 +506,6 @@ u8 Outx0, Outy0;
Out.Clut=Info.Clut;
}
//***************************************************************************
int CMkLevel::AddPlatform(sMkLevelLayerThing &ThisThing)
{
sMkLevelPlatform ThisPlatform;
int Idx;
ThisPlatform.Name=ThisThing.Name;
Idx=PlatformList.Find(ThisPlatform);
if (Idx!=-1)
{
return(Idx);
}
Idx=PlatformList.size();
ThisPlatform.TriStart=OutFaceList.GetFaceCount();
ThisPlatform.TriCount=ThisThing.Data.TriCount;
PlatformList.Add(ThisPlatform);
// Add tri data
for (int i=0;i<ThisPlatform.TriCount; i++)
{
// sExpTri &ThisTri=InTriList[ThisPlatform.TriStart+i];
sExpTri &ThisTri=InTriList[i];
CFace F;
ExpTri2Face(ThisTri,F);
OutFaceList.AddFace(F);
}
return(Idx);
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
@ -915,7 +997,7 @@ void CMkLevel::WriteLayers()
LevelHdr.PlatformList=WriteThings(LAYER_TYPE_PLATFORM,"Platform List");
LevelHdr.TriggerList=WriteThings(LAYER_TYPE_TRIGGER,"Trigger List");
LevelHdr.FXList=WriteThings(LAYER_TYPE_FX,"FX List");
LevelHdr.PlatformGfx=(sModel*)WritePlatformGfx();
LevelHdr.ModelList=(sModel*)WriteModelList();
}
//***************************************************************************
@ -954,19 +1036,19 @@ int Ofs;
}
//***************************************************************************
int CMkLevel::WritePlatformGfx()
int CMkLevel::WriteModelList()
{
int i,ListSize=PlatformList.size();
int i,ListSize=ModelList.size();
int Ofs=ftell(File);
for (i=0; i<ListSize; i++)
{
sModel Out;
sMkLevelPlatform &ThisPlatform=PlatformList[i];
sMkLevelModel &ThisModel=ModelList[i];
Out.TriCount=ThisPlatform.TriCount;
Out.TriStart=ThisPlatform.TriStart;
printf("Writing Platform %s (%i/%i)- %i Tris\n",ThisPlatform.Name,i+1,ListSize,Out.TriCount);
Out.TriCount=ThisModel.TriCount;
Out.TriStart=ThisModel.TriStart;
printf("Writing Model %s (%i/%i)- %i Tris\n",ThisModel.Name,i+1,ListSize,Out.TriCount);
fwrite(&Out,1,sizeof(sModel),File);
}

View File

@ -37,13 +37,13 @@ bool operator ==(sMkLevelTex const &v1)
};
//***************************************************************************
struct sMkLevelPlatform
struct sMkLevelModel
{
GString Name;
int TriStart;
int TriCount;
bool operator ==(sMkLevelPlatform const &v1) {return(Name==v1.Name);}
bool operator ==(sMkLevelModel const &v1) {return(Name==v1.Name);}
};
//***************************************************************************
@ -58,12 +58,14 @@ public:
void SetAppDir(const char *Path);
void Init(const char *InFilename,const char *OutFilename,int TPBase,int TPW,int TPH);
void LoadModels();
int AddModel(GString &Filename);
int AddModel(sMkLevelLayerThing &ThisThing);
void Load();
void Process();
int AddTile3d(sExpLayerTile &Tile) {return(Tile3dList.Add(Tile));}
int AddTile2d(sExpLayerTile &Tile) {return(Tile2dList.Add(Tile));}
int AddPlatform(sMkLevelLayerThing &ThisThing);
void Write();
@ -80,6 +82,7 @@ public:
void SetStart(int X,int Y) {LevelHdr.PlayerStartX=X; LevelHdr.PlayerStartY=Y;}
protected:
void BuildModel(CScene &ThisScene,GString &RootPath,int Node);
CMkLevelLayer *FindLayer(int Type,int SubType);
void LoadStrList(CList<GString> &List,char *TexPtr,int Count);
@ -96,11 +99,13 @@ protected:
void ProcessLayers();
void SetUpTileUV(sTile2d &Out, sTexOutInfo &Info);
void ProcessModels();
void WriteLevel();
void WriteLayers();
int WriteLayer(int Type,int SubType,const char *LayerName);
int WriteThings(int Type,const char *LayerName);
int WritePlatformGfx();
int WriteModelList();
int WriteTriList();
int WriteQuadList();
int WriteVtxList();
@ -117,7 +122,7 @@ protected:
int TileW,TileH;
CIni Config;
CList<sExpTri> InTriList;
CList<sExpTile> InTileList;
CList<GString> InSetNameList;
@ -135,9 +140,11 @@ protected:
CTexGrab TexGrab;
CList<Frame> BmpList;
CList<sMkLevelPlatform> PlatformList;
vector<CMkLevelLayer*> LayerList;
CList<sMkLevelModel> ModelList;
CFaceStore ModelFaceList;
sLevelHdr LevelHdr;
sExpTri FlatFace[2];