This commit is contained in:
parent
16645de3b0
commit
b26a6d76bb
38 changed files with 517 additions and 137 deletions
|
@ -65,6 +65,7 @@ int i,ListSize=ThingList.size();
|
|||
OutThing.Flags=ThisThing.Data.Platform.PlatformCollisionFlag;
|
||||
OutThing.PointCount=PointCount;
|
||||
OutThing.Gfx=RemapTable[i];
|
||||
OutThing.Param0=ThisThing.Data.Platform.PlatformParam0;
|
||||
fwrite(&OutThing,sizeof(sThingPlatform),1,File);
|
||||
|
||||
for (p=0;p<PointCount;p++)
|
||||
|
|
|
@ -33,7 +33,6 @@ sRGBCol *RGB=(sRGBCol*)iPtr;
|
|||
ShadeHdr.RGB[i][2]=RGB->B;
|
||||
RGB++;
|
||||
}
|
||||
|
||||
iPtr=(int*)RGB;
|
||||
|
||||
ListSize=*iPtr++;
|
||||
|
@ -41,10 +40,11 @@ sRGBCol *RGB=(sRGBCol*)iPtr;
|
|||
sLayerShadeGfx *GfxPtr=(sLayerShadeGfx*)iPtr;
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sLayerShadeGfx &ThisGfx=GfxList[i];
|
||||
GfxList[i]=*GfxPtr++;
|
||||
}
|
||||
iPtr=(int*)GfxPtr;
|
||||
|
||||
iPtr=(int*)GfxPtr;
|
||||
ListSize=*iPtr++;
|
||||
TypeNameList.resize(ListSize);
|
||||
char *TypePtr=(char*)iPtr;
|
||||
|
@ -132,13 +132,20 @@ int ThisPos=ftell(File);
|
|||
Hdr.Height=Height;
|
||||
fwrite(&Hdr,sizeof(sLayerHdr),1,File);
|
||||
|
||||
// Write Gfx Stuff
|
||||
ShadeHdr.TypeList=(sLayerShadeBackGfxType*)WriteTypeList(File);
|
||||
ShadeHdr.GfxList=(sLayerShadeBackGfx*)WriteGfxList(File);
|
||||
|
||||
|
||||
int HdrPos=ftell(File);
|
||||
fwrite(&ShadeHdr,sizeof(sLayerShadeHdr),1,File);
|
||||
PadFile(File);
|
||||
|
||||
|
||||
// Write Gfx Stuff
|
||||
ShadeHdr.GfxList=(sLayerShadeBackGfx*)(WriteGfxList(File)-ThisPos);
|
||||
ShadeHdr.TypeList=(sLayerShadeBackGfxType*)(WriteTypeList(File)-ThisPos);
|
||||
|
||||
// rewrite header
|
||||
int RetPos=ftell(File);
|
||||
fseek(File,HdrPos,SEEK_SET);
|
||||
fwrite(&ShadeHdr,sizeof(sLayerShadeHdr),1,File);
|
||||
fseek(File,RetPos,SEEK_SET);
|
||||
|
||||
|
||||
return(ThisPos);
|
||||
}
|
||||
|
@ -164,11 +171,11 @@ int CMkLevelLayerShade::WriteGfxList(FILE *File)
|
|||
int Pos=ftell(File);
|
||||
int i,ListSize=GfxList.size();
|
||||
|
||||
ShadeHdr.GfxCount=GfxList.size();
|
||||
ShadeHdr.GfxCount=ListSize;
|
||||
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sLayerShadeGfx &ThisGfx=GfxList[i];
|
||||
sLayerShadeGfx &ThisGfx=GfxList[i];
|
||||
sLayerShadeBackGfx Out;
|
||||
|
||||
Out.Type=ThisGfx.Gfx;
|
||||
|
@ -177,12 +184,13 @@ int i,ListSize=GfxList.size();
|
|||
Out.Trans=ThisGfx.TransMode;
|
||||
for (int p=0; p<4; p++)
|
||||
{
|
||||
Out.Ofs[i][0]=ThisGfx.Ofs[i].x;
|
||||
Out.Ofs[i][1]=ThisGfx.Ofs[i].y;
|
||||
Out.RGB[i][0]=ThisGfx.RGB[i].R;
|
||||
Out.RGB[i][1]=ThisGfx.RGB[i].G;
|
||||
Out.RGB[i][2]=ThisGfx.RGB[i].B;
|
||||
Out.Ofs[p][0]=ThisGfx.Ofs[p].x;
|
||||
Out.Ofs[p][1]=ThisGfx.Ofs[p].y;
|
||||
Out.RGB[p][0]=ThisGfx.RGB[p].R;
|
||||
Out.RGB[p][1]=ThisGfx.RGB[p].G;
|
||||
Out.RGB[p][2]=ThisGfx.RGB[p].B;
|
||||
}
|
||||
fwrite(&Out,sizeof(sLayerShadeBackGfx),1,File);
|
||||
}
|
||||
return(Pos);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ int i,ListSize=ThingList.size();
|
|||
OutThing.Height=ThisThing.Data.Trigger.TriggerHeight;
|
||||
OutThing.TargetPos.X=ThisThing.Data.Trigger.TriggerTargetX;
|
||||
OutThing.TargetPos.Y=ThisThing.Data.Trigger.TriggerTargetY;
|
||||
OutThing.TargetSize.X=ThisThing.Data.Trigger.TriggerTargetW;
|
||||
OutThing.TargetSize.Y=ThisThing.Data.Trigger.TriggerTargetH;
|
||||
fwrite(&OutThing,sizeof(sThingTrigger),1,File);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ GFName Path;
|
|||
FlatFace[0].uv[0][0]=1; FlatFace[0].uv[0][1]=1;
|
||||
FlatFace[0].uv[1][0]=0; FlatFace[0].uv[1][1]=0;
|
||||
FlatFace[0].uv[2][0]=1; FlatFace[0].uv[2][1]=0;
|
||||
FlatFace[0].Flags=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[1].x=+0.5f; FlatFace[1].vtx[1].y=+1.0f; FlatFace[1].vtx[1].z=-4.0f;
|
||||
|
@ -112,6 +113,7 @@ GFName Path;
|
|||
FlatFace[1].uv[0][0]=0; FlatFace[1].uv[0][1]=0;
|
||||
FlatFace[1].uv[1][0]=1; FlatFace[1].uv[1][1]=1;
|
||||
FlatFace[1].uv[2][0]=0; FlatFace[1].uv[2][1]=1;
|
||||
FlatFace[1].Flags=0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,9 +168,7 @@ int TriCount=NodeTriList.size();
|
|||
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];
|
||||
|
||||
|
||||
CFace &F=ModelFaceList.AddFace( NodeVtxList, NodeTriList[T], NodeUVList[T], TexName,SceneMaterials[Mat].Flags,false);
|
||||
// ModelFaceList.SetTPageFlag(F,SceneMaterials[Mat].Flags);
|
||||
}
|
||||
|
||||
int ChildCount=ThisNode.GetPruneChildCount();
|
||||
|
@ -200,7 +200,7 @@ int Idx;
|
|||
CFace F;
|
||||
|
||||
ExpTri2Face(ThisTri,F);
|
||||
ModelFaceList.SetTPageFlag(F,ThisTri.Flags);
|
||||
ModelFaceList.SetTPageFlag(F,ThisTri.Flags*0);
|
||||
ModelFaceList.AddFace(F,false);
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ int TriStart=OutFaceList.GetFaceCount();
|
|||
ListSize=ModelList.size();
|
||||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
printf("%s = %i %i\n",ModelList[i].Name,ModelList[i].TriStart,ModelList[i].TriCount);
|
||||
// printf("%s = %i %i\n",ModelList[i].Name,ModelList[i].TriStart,ModelList[i].TriCount);
|
||||
ModelList[i].TriStart+=TriStart;
|
||||
}
|
||||
}
|
||||
|
@ -303,6 +303,7 @@ u8 *TilePtr=(u8*) &ByteHdr[FileHdr->TileOfs];
|
|||
sExpTile &InTile=InTileList[i];
|
||||
|
||||
InTile=*ThisTilePtr;
|
||||
// Skip RGB Image, not needed (and too buggy)
|
||||
// InTile.RGB=(u8*)malloc(RGBSize);
|
||||
// memcpy(InTile.RGB,TilePtr+sizeof(sExpTile),RGBSize);
|
||||
InTile.RGB=0;
|
||||
|
@ -573,7 +574,7 @@ int TileID=OutTile3dList.size();
|
|||
for (i=0; i<SrcTile.TriCount; i++)
|
||||
{
|
||||
int ListPos;
|
||||
sExpTri ThisTri=InTriList[SrcTile.TriStart+i];
|
||||
sExpTri &ThisTri=InTriList[SrcTile.TriStart+i];
|
||||
float ThisZPos;
|
||||
|
||||
ThisZPos=ThisTri.vtx[0].z;
|
||||
|
@ -592,15 +593,19 @@ int TileID=OutTile3dList.size();
|
|||
}
|
||||
else
|
||||
{ // create flat tile (This is WRONG, flip tex are gen, need to flip goem)
|
||||
int TexID=Create2dTex(InTile.Tile,InTile.Flags);
|
||||
// int TexID=Create2dTex(InTile.Tile,InTile.Flags);
|
||||
int TexID=Create2dTex(InTile.Tile,0);
|
||||
|
||||
ThisTile.TriCount=2;
|
||||
|
||||
for (int i=0; i<2; i++)
|
||||
{
|
||||
FlatFace[i].Flags=0;
|
||||
FlatFace[i].TexID=TexID;
|
||||
SortList.push_back(FlatFace[i]);
|
||||
}
|
||||
InTile.Flags=0;
|
||||
|
||||
// InTile.Flags=0;
|
||||
}
|
||||
|
||||
// Add sorted list to main list
|
||||
|
@ -668,24 +673,25 @@ int TileID=OutTile3dList.size();
|
|||
int CMkLevel::Create2dTex(int Tile,int Flags)
|
||||
{
|
||||
sExpTile &SrcTile=InTileList[Tile];
|
||||
//sMkLevelTex InTex;
|
||||
|
||||
// InTex.RGB=SrcTile.RGB;
|
||||
|
||||
// Try and find RGB data match
|
||||
// not working
|
||||
// Idx=FindRGBMatch(InTex);
|
||||
// if (Idx!=-1) return(Idx);
|
||||
|
||||
sMkLevelTex InTex;
|
||||
int Idx;
|
||||
// Must be new, add it
|
||||
// InTex.Set=SrcTile.Set;
|
||||
// InTex.Flags=Flags;
|
||||
// InTex.XOfs=SrcTile.XOfs;
|
||||
// InTex.YOfs=SrcTile.YOfs;
|
||||
InTex.Tile=Tile;
|
||||
InTex.Flags=Flags;
|
||||
|
||||
Idx=Tex2dList.Find(InTex);
|
||||
|
||||
int TexID=BuildTileTex(SrcTile,Flags);
|
||||
// Tex2dList.push_back(InTex);
|
||||
return(TexID);
|
||||
if (Idx!=-1)
|
||||
{
|
||||
return(Tex2dList[Idx].TexID);
|
||||
}
|
||||
|
||||
InTex.TexID=BuildTileTex(SrcTile,Flags);
|
||||
Tex2dList.push_back(InTex);
|
||||
return(InTex.TexID);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -980,7 +986,7 @@ int i,ListSize=QuadList.size();
|
|||
// Write It
|
||||
fwrite(&Q,1,sizeof(sQuad),File);
|
||||
}
|
||||
printf("Quad %i\n",ListSize,MaxOT);
|
||||
printf("Quad %i\n",ListSize);
|
||||
return(ThisPos);
|
||||
|
||||
}
|
||||
|
@ -1090,9 +1096,40 @@ int Ofs=ftell(File);
|
|||
|
||||
Out.TriCount=ThisModel.TriCount;
|
||||
Out.TriStart=ThisModel.TriStart;
|
||||
printf("Writing Model %s (%i/%i)- %i Tris\n",ThisModel.Name,i+1,ListSize,Out.TriCount);
|
||||
CalcModelBBox(ThisModel,Out.BBox);
|
||||
printf("Writing Model %s (%i/%i) (%i Tris) (BBox %i,%i->%i,%i)\n",ThisModel.Name,i+1,ListSize,Out.TriCount,Out.BBox.XMin,Out.BBox.YMin,Out.BBox.XMax,Out.BBox.YMax);
|
||||
fwrite(&Out,1,sizeof(sModel),File);
|
||||
}
|
||||
|
||||
return(Ofs);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkLevel::CalcModelBBox(sMkLevelModel &ThisModel,sBBox &BBox)
|
||||
{
|
||||
vector<sTri> &TriList=OutFaceList.GetOutTriList();
|
||||
vector<sVtx> const &VtxList=OutFaceList.GetVtxList();
|
||||
int Vtx[3];
|
||||
|
||||
BBox.XMin=+32000;
|
||||
BBox.XMax=-32000;
|
||||
BBox.YMin=+32000;
|
||||
BBox.YMax=-32000;
|
||||
|
||||
for (int T=0; T<ThisModel.TriCount; T++)
|
||||
{
|
||||
sTri &ThisTri=TriList[T+ThisModel.TriStart];
|
||||
Vtx[0]=ThisTri.P0;
|
||||
Vtx[1]=ThisTri.P1;
|
||||
Vtx[2]=ThisTri.P2;
|
||||
|
||||
for (int V=0; V<3; V++)
|
||||
{
|
||||
sVtx const &ThisVtx=VtxList[Vtx[V]];
|
||||
if (BBox.XMin>+ThisVtx.vx) BBox.XMin=+ThisVtx.vx;
|
||||
if (BBox.XMax<+ThisVtx.vx) BBox.XMax=+ThisVtx.vx;
|
||||
if (BBox.YMin>-ThisVtx.vy) BBox.YMin=-ThisVtx.vy;
|
||||
if (BBox.YMax<-ThisVtx.vy) BBox.YMax=-ThisVtx.vy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,26 @@ bool operator ==(sMkLevelTex const &v1)
|
|||
}
|
||||
};
|
||||
*/
|
||||
|
||||
struct sMkLevelTex
|
||||
{
|
||||
// int Set;
|
||||
// int XOfs,YOfs;
|
||||
int Tile;
|
||||
int Flags;
|
||||
int TexID;
|
||||
|
||||
bool operator ==(sMkLevelTex const &v1)
|
||||
{
|
||||
// if (Set!=v1.Set) return(false);
|
||||
// if (XOfs!=v1.XOfs) return(false);
|
||||
// if (YOfs!=v1.YOfs) return(false);
|
||||
if (Tile!=v1.Tile) return(false);
|
||||
if (Flags!=v1.Flags) return(false);
|
||||
return(true);
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
struct sMkLevelModel
|
||||
{
|
||||
|
@ -112,7 +132,7 @@ protected:
|
|||
int WriteQuadList();
|
||||
int WriteVtxList();
|
||||
void WriteTileBank();
|
||||
|
||||
void CalcModelBBox(sMkLevelModel &ThisModel,sBBox &BBox);
|
||||
void BuildTiles();
|
||||
|
||||
void ExpTri2Face(sExpTri &In,CFace &Out,bool ImportTex=true);
|
||||
|
@ -138,7 +158,7 @@ protected:
|
|||
|
||||
CList<sExpLayerTile> Tile2dList;
|
||||
CList<sExpLayerTile> Tile3dList;
|
||||
// CList<sMkLevelTex> Tex2dList;
|
||||
CList<sMkLevelTex> Tex2dList;
|
||||
CTexGrab TexGrab;
|
||||
CList<Frame> BmpList;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue