diff --git a/Utils/MkLevel/Layers/MkLevelLayerPlatform.cpp b/Utils/MkLevel/Layers/MkLevelLayerPlatform.cpp index 2fd937121..fe682f5b3 100644 --- a/Utils/MkLevel/Layers/MkLevelLayerPlatform.cpp +++ b/Utils/MkLevel/Layers/MkLevelLayerPlatform.cpp @@ -24,7 +24,7 @@ int i,ListSize; for (i=0; iAddPlatform(ThisThing); + RemapTable[i]=Core->AddModel(ThisThing); } printf("%i Platforms\n",ThingList.size()); diff --git a/Utils/MkLevel/Main.cpp b/Utils/MkLevel/Main.cpp index 40e73a539..dd66b3611 100644 --- a/Utils/MkLevel/Main.cpp +++ b/Utils/MkLevel/Main.cpp @@ -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); } diff --git a/Utils/MkLevel/MkLevel.cpp b/Utils/MkLevel/MkLevel.cpp index e2695cdca..b41a67bc9 100644 --- a/Utils/MkLevel/MkLevel.cpp +++ b/Utils/MkLevel/MkLevel.cpp @@ -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 const &NodeTriList = ThisNode.GetTris(); +vector const &NodeVtxList = ThisNode.GetPts(); +vector const &NodeMatList = ThisNode.GetTriMaterial(); +vector const &NodeUVList = ThisNode.GetUVTris(); +vector const &SceneTexList= Scene.GetTexList(); +vector const &SceneUsedMatList=Scene.GetUsedMaterialIdx(); + +int TriCount=NodeTriList.size(); + + for (int T=0; TSceneTexList.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 &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 InTriList; CList InTileList; CList InSetNameList; @@ -135,9 +140,11 @@ protected: CTexGrab TexGrab; CList BmpList; - CList PlatformList; vector LayerList; + CList ModelList; + CFaceStore ModelFaceList; + sLevelHdr LevelHdr; sExpTri FlatFace[2];