This commit is contained in:
parent
60b5326d52
commit
5b2be54bd9
7 changed files with 308 additions and 170 deletions
|
@ -16,6 +16,7 @@ int TPBase=-1,TPW=-1,TPH=-1;
|
|||
GString IncDir;
|
||||
int PakW=0,PakH=0;
|
||||
bool LocalGeom=false;
|
||||
float SnapThresh=0;
|
||||
|
||||
//***************************************************************************
|
||||
char * CycleCommands(char *String,int Num)
|
||||
|
@ -75,6 +76,11 @@ int Count;
|
|||
TextPtr+=strlen(TextPtr)+1;
|
||||
PakH=atol(TextPtr);
|
||||
break;
|
||||
case 'z':
|
||||
TpStr= CheckFileString(String);
|
||||
SnapThresh=atof(TpStr);
|
||||
break;
|
||||
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"Unknown switch %s",String);
|
||||
break;
|
||||
|
@ -105,6 +111,7 @@ void Usage(char *ErrStr)
|
|||
printf(" -q: Enable Quadding\n");
|
||||
printf(" -l: Enable Local Geom\n");
|
||||
printf(" -p: Level Chunk Pak Info (X,Y) (Default=None(0,0)\n");
|
||||
printf(" -z: Snap Threshold\n");
|
||||
GObject::Error(ERR_FATAL,ErrStr);
|
||||
}
|
||||
|
||||
|
@ -120,7 +127,7 @@ std::vector<GString> const &Files = MyFiles.GetFileInfoVector();
|
|||
if (Files.size()>1) Usage("Too many Levels specified\n");
|
||||
|
||||
Level.SetAppDir(argv[0]);
|
||||
Level.Init(Files[0],OutStr,IncDir,TPBase,TPW,TPH,PakW,PakH,LocalGeom);
|
||||
Level.Init(Files[0],OutStr,IncDir,TPBase,TPW,TPH,PakW,PakH,LocalGeom,SnapThresh);
|
||||
Level.Load();
|
||||
Level.Process();
|
||||
Level.Write();
|
||||
|
|
|
@ -55,32 +55,40 @@ int TSize,QSize,VSize;
|
|||
int Tile2dSize,Tile3dSize;
|
||||
const char *ModelExcludeGroupName="ModelExcludeList";
|
||||
const char *ModelOtOfsGroupName="ModelOtOfs";
|
||||
|
||||
int LocalOptCount=0;
|
||||
//***************************************************************************
|
||||
const GString ConfigFilename="MkLevel.ini";
|
||||
sExpLayerTile BlankTile={0,0};
|
||||
|
||||
|
||||
const float InElemXMin=-0.5f;
|
||||
const float InElemXMax=+0.5f;
|
||||
const float InElemYMin=-0.0f;
|
||||
const float InElemYMax=+1.0f;
|
||||
const float InElemZMin=-4.0f;
|
||||
const float InElemZMax=+4.0f;
|
||||
|
||||
const float OutElemXMin=-0.5f;
|
||||
const float OutElemXMax=+0.5f;
|
||||
const float OutElemYMin=-0.5f;
|
||||
const float OutElemYMax=+0.5f;
|
||||
const float OutElemZMin=-4.0f;
|
||||
const float OutElemZMax=+4.0f;
|
||||
|
||||
Vector3 DefVtxTable[8]=
|
||||
{
|
||||
Vector3(+0.5f,+1.0f,-4.0f),
|
||||
Vector3(-0.5f,+1.0f,-4.0f),
|
||||
Vector3(+0.5f, 0.0f,-4.0f),
|
||||
Vector3(-0.5f, 0.0f,-4.0f),
|
||||
Vector3(OutElemXMin,OutElemYMin,OutElemZMin), // FLU
|
||||
Vector3(OutElemXMax,OutElemYMin,OutElemZMin), // FRU
|
||||
Vector3(OutElemXMin,OutElemYMax,OutElemZMin), // FLD
|
||||
Vector3(OutElemXMax,OutElemYMax,OutElemZMin), // FRD
|
||||
|
||||
Vector3(+0.5f,+1.0f,+4.0f),
|
||||
Vector3(-0.5f,+1.0f,+4.0f),
|
||||
Vector3(+0.5f, 0.0f,+4.0f),
|
||||
Vector3(-0.5f, 0.0f,+4.0f),
|
||||
Vector3(OutElemXMin,OutElemYMin,OutElemZMax), // BLU
|
||||
Vector3(OutElemXMax,OutElemYMin,OutElemZMax), // BRU
|
||||
Vector3(OutElemXMin,OutElemYMax,OutElemZMax), // BLD
|
||||
Vector3(OutElemXMax,OutElemYMax,OutElemZMax), // BRD
|
||||
};
|
||||
#define DefVtxTableSize sizeof(DefVtxTable)/sizeof(Vector3)
|
||||
|
||||
float SnapThresh=0.05f;
|
||||
float SnapXMin=-0.5f;
|
||||
float SnapXMax=+0.5f;
|
||||
float SnapYMin=-0.0f;
|
||||
float SnapYMax=+1.0f;
|
||||
float SnapZMin=-4.0f;
|
||||
float SnapZMax=+4.0f;
|
||||
|
||||
//***************************************************************************
|
||||
CMkLevel::CMkLevel()
|
||||
|
@ -113,7 +121,7 @@ GFName Path=AppPath;
|
|||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkLevel::Init(const char *Filename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH,int _PakW,int _PakH,bool _LocalGeom)
|
||||
void CMkLevel::Init(const char *Filename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH,int _PakW,int _PakH,bool _LocalGeom,float _SnapThresh)
|
||||
{
|
||||
// Setup filenames and paths
|
||||
GFName Path;
|
||||
|
@ -187,8 +195,8 @@ char Buffer[256];
|
|||
PakW=_PakW;
|
||||
PakH=_PakH;
|
||||
LocalGeom=_LocalGeom;
|
||||
SnapThresh=_SnapThresh;
|
||||
AddDefVtx(OutVtxList);
|
||||
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -403,7 +411,12 @@ u8 *ByteHdr=(u8*)FileHdr;
|
|||
void CMkLevel::SnapTiles()
|
||||
{
|
||||
int i,ListSize=InTileList.size();
|
||||
int Count=0;
|
||||
float SnapXMin=InElemXMin+SnapThresh;
|
||||
float SnapXMax=InElemXMax-SnapThresh;
|
||||
float SnapYMin=InElemYMin+SnapThresh;
|
||||
float SnapYMax=InElemYMax-SnapThresh;
|
||||
float SnapZMin=InElemZMin+SnapThresh;
|
||||
float SnapZMax=InElemZMax-SnapThresh;
|
||||
|
||||
for (i=0;i<ListSize;i++)
|
||||
{
|
||||
|
@ -415,20 +428,17 @@ int Count=0;
|
|||
{
|
||||
Vector3 &V=ThisTri.vtx[p];
|
||||
|
||||
if (V.x<SnapXMin+SnapThresh) {V.x=SnapXMin;Count++;}
|
||||
if (V.x>SnapXMax-SnapThresh) {V.x=SnapXMax;Count++;}
|
||||
if (V.y<SnapYMin+SnapThresh) {V.y=SnapYMin;Count++;}
|
||||
if (V.y>SnapYMax-SnapThresh) {V.y=SnapYMax;Count++;}
|
||||
if (V.z<SnapZMin+SnapThresh) {V.z=SnapZMin;Count++;}
|
||||
if (V.z>SnapZMax-SnapThresh) {V.z=SnapZMax;Count++;}
|
||||
if (V.x<SnapXMin) V.x=InElemXMin;
|
||||
if (V.x>SnapXMax) V.x=InElemXMax;
|
||||
if (V.y<SnapYMin) V.y=InElemYMin;
|
||||
if (V.y>SnapYMax) V.y=InElemYMax;
|
||||
if (V.z<SnapZMin) V.z=InElemZMin;
|
||||
if (V.z>SnapZMax) V.z=InElemZMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Count)
|
||||
{
|
||||
printf("Snapped %i Vtx Coords - Bad Artists\n",Count);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
//*** Process ***************************************************************
|
||||
//***************************************************************************
|
||||
|
@ -540,7 +550,7 @@ int i,ListSize=UsedTile3dList.size();
|
|||
}
|
||||
|
||||
//***************************************************************************
|
||||
int MaxElemTri=0,MaxElemQuad=0;
|
||||
int MaxElemTri=0,MaxElemQuad=0,MaxElemVtx=0;
|
||||
void CMkLevel::ProcessElemBank3d()
|
||||
{
|
||||
//int i,ListSize=UsedTile3dList.size(); <--- UsedTile3dList is tiles only!!
|
||||
|
@ -550,7 +560,12 @@ int i,ListSize=OutElem3d.size();
|
|||
{
|
||||
ProcessElem3d(OutElem3d[i]);
|
||||
}
|
||||
printf("Max Elem Tri =%i\tMax Elem Quad =%i\n",MaxElemTri,MaxElemQuad);
|
||||
printf("Max Elem Tri =%i\tMax Elem Quad =%i\tMax Elem Vtx =%i\n",MaxElemTri,MaxElemQuad,MaxElemVtx);
|
||||
if (LocalGeom)
|
||||
{
|
||||
printf("LocalGeom Optimised %i/%i\n",LocalOptCount,ListSize);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -570,19 +585,29 @@ CFaceStore &ThisList=ThisElem.FaceStore;
|
|||
else
|
||||
{ // Local Geom
|
||||
vector<sVtx> LocalVtxList;
|
||||
// AddDefVtx(LocalVtxList);
|
||||
AddDefVtx(LocalVtxList);
|
||||
ThisList.Process(OutTriList,OutQuadList,LocalVtxList);
|
||||
ThisElem.Elem3d.VtxIdxStart=OutLocalVtxIdxList.size();
|
||||
// printf("%i\n",LocalVtxList.size());
|
||||
|
||||
int VtxListSize=LocalVtxList.size();
|
||||
for (int v=0; v<VtxListSize; v++)
|
||||
int ListSize=LocalVtxList.size();
|
||||
int LocalVtxCount=0;
|
||||
|
||||
for (int v=8; v<ListSize; v++)
|
||||
{
|
||||
u16 Idx=CFaceStore::AddVtx(OutVtxList,LocalVtxList[v]);
|
||||
|
||||
OutLocalVtxIdxList.push_back(Idx);
|
||||
LocalVtxCount++;
|
||||
}
|
||||
ThisElem.Elem3d.VtxTriCount=VtxListSize/3;
|
||||
if (VtxListSize%3) ThisElem.Elem3d.VtxTriCount++;
|
||||
if (LocalVtxCount<=0)
|
||||
{
|
||||
LocalOptCount++;
|
||||
LocalVtxCount=0;
|
||||
}
|
||||
ThisElem.Elem3d.VtxTriCount=LocalVtxCount/3;
|
||||
if (LocalVtxCount%3) ThisElem.Elem3d.VtxTriCount++;
|
||||
// printf("%i=%i\n",LocalVtxCount,ThisElem.Elem3d.VtxTriCount);
|
||||
|
||||
|
||||
CalcOtOfs(OutTriList,LocalVtxList,ThisElem.Elem3d.TriStart,ThisList.GetTriFaceCount());
|
||||
CalcOtOfs(OutQuadList,LocalVtxList,ThisElem.Elem3d.QuadStart,ThisList.GetQuadFaceCount());
|
||||
|
@ -595,6 +620,7 @@ CFaceStore &ThisList=ThisElem.FaceStore;
|
|||
{ // Gen max polys per tile (NOT MODEL)
|
||||
if (MaxElemTri<ThisElem.Elem3d.TriCount) MaxElemTri=ThisElem.Elem3d.TriCount;
|
||||
if (MaxElemQuad<ThisElem.Elem3d.QuadCount) MaxElemQuad=ThisElem.Elem3d.QuadCount;
|
||||
if (MaxElemVtx<ThisElem.Elem3d.VtxTriCount*3) MaxElemVtx=ThisElem.Elem3d.VtxTriCount*3;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1064,8 +1090,11 @@ sVtx Max={-100,-100,-100};
|
|||
}
|
||||
printf("%i Vtx\t(%i Bytes)\n",ListSize,ListSize*sizeof(sVtx));
|
||||
|
||||
printf("Min %i %i %i\n",Min.vx,Min.vy,Min.vz);
|
||||
printf("Max %i %i %i\n",Max.vx,Max.vy,Max.vz);
|
||||
printf("MinX: %i\tMaxX: %i\n",Min.vx,Max.vx);
|
||||
printf("MinY: %i\tMaxY: %i\n",Min.vy,Max.vy);
|
||||
printf("MinZ: %i\tMaxZ: %i\n",Min.vz,Max.vz);
|
||||
// printf("Min %i %i %i\n",Min.vx,Min.vy,Min.vz);
|
||||
// printf("Max %i %i %i\n",Max.vx,Max.vy,Max.vz);
|
||||
|
||||
return(Pos);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
~CMkLevel();
|
||||
|
||||
void SetAppDir(const char *Path);
|
||||
void Init(const char *InFilename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH,int PakW,int PakH,bool LocalGeom);
|
||||
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);
|
||||
|
||||
void LoadModels();
|
||||
int AddModel(const char *Name,int TriStart,int TriCount);
|
||||
|
@ -201,6 +201,7 @@ protected:
|
|||
|
||||
int PakW,PakH;
|
||||
bool LocalGeom;
|
||||
float SnapThresh;
|
||||
|
||||
vector<sTri> OutTriList;
|
||||
vector<sQuad> OutQuadList;
|
||||
|
|
|
@ -82,6 +82,17 @@ int YPos=MapPos.vy>>MapXYShift;
|
|||
ShiftX=XPos & 15;
|
||||
ShiftY=YPos%TILE2D_HEIGHT;
|
||||
|
||||
if (MapXY.vx<0)
|
||||
{
|
||||
MapXY.vx=0;
|
||||
ShiftX=0;
|
||||
}
|
||||
if (MapXY.vy<0)
|
||||
{
|
||||
MapXY.vy=0;
|
||||
ShiftY=0;
|
||||
}
|
||||
|
||||
if (MapXY.vx+SCREEN_TILE2D_WIDTH<=MapWidth)
|
||||
RenderW=SCREEN_TILE2D_WIDTH;
|
||||
else
|
||||
|
|
|
@ -22,7 +22,7 @@ static FontBank *Font;
|
|||
static const int BLOCK_SIZE =16;
|
||||
static const int SCREEN_TILE_ADJ_U =2;
|
||||
static const int SCREEN_TILE_ADJ_D =1;
|
||||
static const int SCREEN_TILE_ADJ_L =2;
|
||||
static const int SCREEN_TILE_ADJ_L =3;
|
||||
static const int SCREEN_TILE_ADJ_R =3;
|
||||
|
||||
static const int SCREEN_TILE3D_WIDTH =(INGAME_SCREENW/BLOCK_SIZE)+SCREEN_TILE_ADJ_L+SCREEN_TILE_ADJ_R;
|
||||
|
@ -31,13 +31,59 @@ static const int SCREEN_TILE3D_HEIGHT =(INGAME_SCREENH/BLOCK_SIZE)+SCREEN_TILE_A
|
|||
static const int RENDER_X_OFS =INGAME_SCREENOFS_X-(SCREEN_TILE_ADJ_L*BLOCK_SIZE)+INGAME_RENDER_OFS_X;
|
||||
static const int RENDER_Y_OFS =INGAME_SCREENOFS_Y-(SCREEN_TILE_ADJ_U*BLOCK_SIZE)+INGAME_RENDER_OFS_Y;
|
||||
|
||||
static const int DeltaTableSizeX=SCREEN_TILE3D_WIDTH+1;
|
||||
static const int DeltaTableSizeY=SCREEN_TILE3D_HEIGHT+1;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
// 0 LUF
|
||||
// 1 RUF
|
||||
// 2 LDF
|
||||
// 3 RDF
|
||||
|
||||
// 4 LUB
|
||||
// 5 RUB
|
||||
// 6 LDB
|
||||
// 7 RDB
|
||||
|
||||
sFlipTable FlipTable[4]=
|
||||
{
|
||||
{{+4096,0,+4096,0},0<<31}, //00 <0
|
||||
{{-4096,0,+4096,0},1<<31}, //01 >0
|
||||
{{+4096,0,-4096,0},1<<31}, //10 >0
|
||||
{{-4096,0,-4096,0},0<<31} //11 <0
|
||||
/*00 <0*/ {{+4096,0,+4096,0}, { ((DVECTOR*)SCRATCH_RAM)+0,
|
||||
((DVECTOR*)SCRATCH_RAM)+1,
|
||||
((DVECTOR*)SCRATCH_RAM)+2,
|
||||
((DVECTOR*)SCRATCH_RAM)+3,
|
||||
((DVECTOR*)SCRATCH_RAM)+4,
|
||||
((DVECTOR*)SCRATCH_RAM)+5,
|
||||
((DVECTOR*)SCRATCH_RAM)+6,
|
||||
((DVECTOR*)SCRATCH_RAM)+7,
|
||||
}, 0<<31},
|
||||
/*01 >0*/ {{-4096,0,+4096,0}, { ((DVECTOR*)SCRATCH_RAM)+1,
|
||||
((DVECTOR*)SCRATCH_RAM)+0,
|
||||
((DVECTOR*)SCRATCH_RAM)+3,
|
||||
((DVECTOR*)SCRATCH_RAM)+2,
|
||||
((DVECTOR*)SCRATCH_RAM)+5,
|
||||
((DVECTOR*)SCRATCH_RAM)+4,
|
||||
((DVECTOR*)SCRATCH_RAM)+7,
|
||||
((DVECTOR*)SCRATCH_RAM)+6,
|
||||
},1<<31},
|
||||
/*10 >0*/ {{+4096,0,-4096,0}, { ((DVECTOR*)SCRATCH_RAM)+2,
|
||||
((DVECTOR*)SCRATCH_RAM)+3,
|
||||
((DVECTOR*)SCRATCH_RAM)+0,
|
||||
((DVECTOR*)SCRATCH_RAM)+1,
|
||||
((DVECTOR*)SCRATCH_RAM)+6,
|
||||
((DVECTOR*)SCRATCH_RAM)+7,
|
||||
((DVECTOR*)SCRATCH_RAM)+4,
|
||||
((DVECTOR*)SCRATCH_RAM)+5,
|
||||
},1<<31},
|
||||
/*11 <0*/ {{-4096,0,-4096,0}, { ((DVECTOR*)SCRATCH_RAM)+3,
|
||||
((DVECTOR*)SCRATCH_RAM)+2,
|
||||
((DVECTOR*)SCRATCH_RAM)+1,
|
||||
((DVECTOR*)SCRATCH_RAM)+0,
|
||||
((DVECTOR*)SCRATCH_RAM)+7,
|
||||
((DVECTOR*)SCRATCH_RAM)+6,
|
||||
((DVECTOR*)SCRATCH_RAM)+5,
|
||||
((DVECTOR*)SCRATCH_RAM)+4,
|
||||
},0<<31}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -71,6 +117,7 @@ CLayerTile3d::~CLayerTile3d()
|
|||
void CLayerTile3d::init(DVECTOR &MapPos,int Shift)
|
||||
{
|
||||
CLayerTile::init(MapPos,Shift);
|
||||
CalcDelta();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -80,10 +127,76 @@ void CLayerTile3d::shutdown()
|
|||
Font->dump();
|
||||
delete Font;
|
||||
#endif
|
||||
for (int i=0; i<16; i++)
|
||||
{
|
||||
MemFree(FTableX[i]);
|
||||
MemFree(FTableY[i]);
|
||||
MemFree(BTableX[i]);
|
||||
MemFree(BTableY[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile3d::CalcDelta()
|
||||
{
|
||||
VECTOR BlkPos;
|
||||
SVECTOR Pnt={-BLOCK_SIZE/2,-BLOCK_SIZE/2,-BLOCK_SIZE*4};
|
||||
s16 *FTab,*BTab;
|
||||
CGameScene::setCameraMtx();
|
||||
|
||||
for (int i=0; i<16; i++)
|
||||
{
|
||||
FTab=(s16*)MemAlloc(DeltaTableSizeX*sizeof(s16),"FTableXTable");
|
||||
BTab=(s16*)MemAlloc(DeltaTableSizeX*sizeof(s16),"BTableXTable");
|
||||
FTableX[i]=FTab;
|
||||
BTableX[i]=BTab;
|
||||
ASSERT(FTab);
|
||||
ASSERT(BTab);
|
||||
BlkPos.vx=RENDER_X_OFS-i;
|
||||
BlkPos.vy=RENDER_Y_OFS;
|
||||
for (int x=0; x<DeltaTableSizeX; x++)
|
||||
{
|
||||
s32 Tmp;
|
||||
DVECTOR O;
|
||||
CMX_SetTransMtxXY(&BlkPos);
|
||||
Pnt.vz=-BLOCK_SIZE*4;
|
||||
RotTransPers(&Pnt,(s32*)&O,&Tmp,&Tmp);
|
||||
FTab[x]=O.vx;
|
||||
Pnt.vz=+BLOCK_SIZE*4;
|
||||
RotTransPers(&Pnt,(s32*)&O,&Tmp,&Tmp);
|
||||
BTab[x]=O.vx;
|
||||
BlkPos.vx+=BLOCK_SIZE;
|
||||
}
|
||||
|
||||
FTab=(s16*)MemAlloc(DeltaTableSizeY*sizeof(s16),"FTableYTable");
|
||||
BTab=(s16*)MemAlloc(DeltaTableSizeY*sizeof(s16),"BTableYTable");
|
||||
FTableY[i]=FTab;
|
||||
BTableY[i]=BTab;
|
||||
ASSERT(FTab);
|
||||
ASSERT(BTab);
|
||||
BlkPos.vx=RENDER_X_OFS;
|
||||
BlkPos.vy=RENDER_Y_OFS-i;
|
||||
for (int y=0; y<DeltaTableSizeY; y++)
|
||||
{
|
||||
s32 Tmp;
|
||||
DVECTOR O;
|
||||
CMX_SetTransMtxXY(&BlkPos);
|
||||
Pnt.vz=-BLOCK_SIZE*4;
|
||||
RotTransPers(&Pnt,(s32*)&O,&Tmp,&Tmp);
|
||||
FTab[y]=O.vy;
|
||||
Pnt.vz=+BLOCK_SIZE*4;
|
||||
RotTransPers(&Pnt,(s32*)&O,&Tmp,&Tmp);
|
||||
BTab[y]=O.vy;
|
||||
BlkPos.vy+=BLOCK_SIZE;
|
||||
}
|
||||
}
|
||||
DeltaF=FTableX[0][1]-FTableX[0][0];
|
||||
DeltaB=BTableY[0][1]-BTableY[0][0];
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLayerTile3d::think(DVECTOR &MapPos)
|
||||
{
|
||||
MapXY.vx=MapPos.vx>>4;
|
||||
|
@ -96,14 +209,20 @@ void CLayerTile3d::think(DVECTOR &MapPos)
|
|||
ShiftY=(MapPos.vy & 15);
|
||||
|
||||
RenderOfs.vx=RenderOfs.vy=0;
|
||||
DeltaFOfs.vx=DeltaFOfs.vy=0;
|
||||
DeltaBOfs.vx=DeltaBOfs.vy=0;
|
||||
if (MapXY.vx<0)
|
||||
{
|
||||
RenderOfs.vx=-MapXY.vx*BLOCK_SIZE;
|
||||
DeltaFOfs.vx=-MapXY.vx*DeltaF;
|
||||
DeltaBOfs.vx=-MapXY.vx*DeltaB;
|
||||
MapXY.vx=0;
|
||||
}
|
||||
if (MapXY.vy<0)
|
||||
{
|
||||
RenderOfs.vy=-MapXY.vy*BLOCK_SIZE;
|
||||
DeltaFOfs.vy=-MapXY.vy*DeltaF;
|
||||
DeltaBOfs.vy=-MapXY.vy*DeltaB;
|
||||
MapXY.vy=0;
|
||||
}
|
||||
|
||||
|
@ -126,8 +245,10 @@ void CLayerTile3d::CacheElemVtx(sElem3d *Elem)
|
|||
int Count=Elem->VtxTriCount;
|
||||
sVtx *V0,*V1,*V2;
|
||||
u16 *IdxTable=&VtxIdxList[Elem->VtxIdxStart];
|
||||
u32 *OutVtx=(u32*)SCRATCH_RAM;
|
||||
u32 *OutPtr;
|
||||
s32 *OutVtx=(s32*)SCRATCH_RAM;
|
||||
s32 *OutPtr;
|
||||
|
||||
OutVtx+=8;
|
||||
|
||||
V0=&VtxList[*IdxTable++];
|
||||
V1=&VtxList[*IdxTable++];
|
||||
|
@ -160,6 +281,10 @@ u32 P0,P1,P2;
|
|||
s32 ClipZ;
|
||||
sOT *ThisOT;
|
||||
VECTOR BlkPos;
|
||||
DVECTOR *DP0,*DP1,*DP2,*DP3;
|
||||
|
||||
s16 *DeltaFY=FTableY[ShiftY];
|
||||
s16 *DeltaBY=BTableY[ShiftY];
|
||||
|
||||
// Setup Trans Matrix
|
||||
BlkPos.vx=RENDER_X_OFS-(ShiftX)+RenderOfs.vx;
|
||||
|
@ -169,6 +294,8 @@ VECTOR BlkPos;
|
|||
{
|
||||
sTileMapElem *MapRow=MapPtr;
|
||||
s32 BlkXOld=BlkPos.vx;
|
||||
s16 *DeltaFX=FTableX[ShiftX];
|
||||
s16 *DeltaBX=BTableX[ShiftX];
|
||||
|
||||
for (int X=0; X<RenderW; X++)
|
||||
{
|
||||
|
@ -181,12 +308,49 @@ VECTOR BlkPos;
|
|||
int TriCount=Elem->TriCount;
|
||||
sTri *TList=&TriList[Elem->TriStart];
|
||||
|
||||
if (TriCount) // Blank tiles rejected here, to prevent over processing (as no tri-count)
|
||||
{
|
||||
CMX_SetTransMtxXY(&BlkPos);
|
||||
CMX_SetRotMatrixXY(&FTab->Mtx);
|
||||
CacheElemVtx(Elem);
|
||||
while (TriCount--) // Blank tiles rejected here (as no tri-count)
|
||||
{
|
||||
|
||||
CacheElemVtx(Elem);
|
||||
|
||||
s16 FL=DeltaFX[0]+DeltaFOfs.vx;
|
||||
s16 FR=DeltaFX[1]+DeltaFOfs.vx;
|
||||
s16 FU=DeltaFY[0]+DeltaFOfs.vy;
|
||||
s16 FD=DeltaFY[1]+DeltaFOfs.vy;
|
||||
DP0=FTab->DeltaTab[0];
|
||||
DP1=FTab->DeltaTab[1];
|
||||
DP2=FTab->DeltaTab[2];
|
||||
DP3=FTab->DeltaTab[3];
|
||||
DP0->vx=FL;
|
||||
DP0->vy=FU;
|
||||
DP1->vx=FR;
|
||||
DP1->vy=FU;
|
||||
DP2->vx=FL;
|
||||
DP2->vy=FD;
|
||||
DP3->vx=FR;
|
||||
DP3->vy=FD;
|
||||
|
||||
s16 BL=DeltaBX[0]+DeltaBOfs.vx;
|
||||
s16 BR=DeltaBX[1]+DeltaBOfs.vx;
|
||||
s16 BU=DeltaBY[0]+DeltaBOfs.vy;
|
||||
s16 BD=DeltaBY[1]+DeltaBOfs.vy;
|
||||
DP0=FTab->DeltaTab[4];
|
||||
DP1=FTab->DeltaTab[5];
|
||||
DP2=FTab->DeltaTab[6];
|
||||
DP3=FTab->DeltaTab[7];
|
||||
DP0->vx=BL;
|
||||
DP0->vy=BU;
|
||||
DP1->vx=BR;
|
||||
DP1->vy=BU;
|
||||
DP2->vx=BL;
|
||||
DP2->vy=BD;
|
||||
DP3->vx=BR;
|
||||
DP3->vy=BD;
|
||||
|
||||
while (TriCount--)
|
||||
{
|
||||
P0=XYList[TList->P0];
|
||||
P1=XYList[TList->P1];
|
||||
P2=XYList[TList->P2];
|
||||
|
@ -219,12 +383,15 @@ VECTOR BlkPos;
|
|||
TPrimPtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
MapRow++;
|
||||
BlkPos.vx+=BLOCK_SIZE;
|
||||
DeltaFX++; DeltaBX++;
|
||||
}
|
||||
MapPtr+=MapWidth;
|
||||
BlkPos.vx=BlkXOld;
|
||||
BlkPos.vy+=BLOCK_SIZE;
|
||||
DeltaFY++; DeltaBY++;
|
||||
}
|
||||
|
||||
SetPrimPtr((u8*)TPrimPtr);
|
||||
|
@ -238,92 +405,3 @@ int QCount=0;
|
|||
#endif
|
||||
|
||||
}
|
||||
/*
|
||||
void CLayerTile3d::render()
|
||||
{
|
||||
sTileMapElem *MapPtr=GetMapPos();
|
||||
u8 *PrimPtr=GetPrimPtr();
|
||||
POLY_FT3 *TPrimPtr=(POLY_FT3*)PrimPtr;
|
||||
sVtx *P0,*P1,*P2;
|
||||
u32 T0,T1,T2;
|
||||
s32 ClipZ;
|
||||
sOT *ThisOT;
|
||||
VECTOR BlkPos;
|
||||
|
||||
// Setup Trans Matrix
|
||||
BlkPos.vx=RENDER_X_OFS-(ShiftX)+RenderOfs.vx;
|
||||
BlkPos.vy=RENDER_Y_OFS-(ShiftY)+RenderOfs.vy;
|
||||
|
||||
for (int Y=0; Y<RenderH; Y++)
|
||||
{
|
||||
sTileMapElem *MapRow=MapPtr;
|
||||
s32 BlkXOld=BlkPos.vx;
|
||||
|
||||
for (int X=0; X<RenderW; X++)
|
||||
{
|
||||
u16 Tile=MapRow->Tile;
|
||||
u16 TileIdx=Tile>>2;
|
||||
u16 Flip=Tile&3;
|
||||
sFlipTable *FTab=&FlipTable[Flip];
|
||||
sElem3d *Elem=&ElemBank3d[TileIdx];
|
||||
int TriCount=Elem->TriCount;
|
||||
sTri *TList=&TriList[Elem->TriStart];
|
||||
u16 *IdxTable=&VtxIdxList[Elem->VtxIdxStart];
|
||||
|
||||
// P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2];
|
||||
P0=&VtxList[IdxTable[TList->P0]];
|
||||
P1=&VtxList[IdxTable[TList->P1]];
|
||||
P2=&VtxList[IdxTable[TList->P2]];
|
||||
CMX_SetTransMtxXY(&BlkPos);
|
||||
CMX_SetRotMatrixXY(&FTab->Mtx);
|
||||
while (TriCount--) // Blank tiles rejected here (as no tri-count)
|
||||
{
|
||||
gte_ldv3(P0,P1,P2);
|
||||
setlen(TPrimPtr, GPU_PolyFT3Tag);
|
||||
TPrimPtr->code=TList->PolyCode;
|
||||
gte_rtpt_b();
|
||||
// setShadeTex(TPrimPtr,1);
|
||||
|
||||
T0=*(u32*)&TList->uv0; // Get UV0 & TPage
|
||||
T1=*(u32*)&TList->uv1; // Get UV1 & Clut
|
||||
T2=*(u16*)&TList->uv2; // Get UV2
|
||||
*(u32*)&TPrimPtr->u0=T0; // Set UV0
|
||||
*(u32*)&TPrimPtr->u1=T1; // Set UV1
|
||||
*(u16*)&TPrimPtr->u2=T2; // Set UV2
|
||||
extern u8 GlobalRGB[];
|
||||
setRGB0(TPrimPtr,GlobalRGB[1],GlobalRGB[1],GlobalRGB[1]);
|
||||
|
||||
ThisOT=OtPtr+TList->OTOfs;
|
||||
TList++;
|
||||
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2]; // Pre-fetch next Tri
|
||||
gte_nclip_b();
|
||||
gte_stsxy3_ft3(TPrimPtr);
|
||||
gte_stopz(&ClipZ);
|
||||
ClipZ^=FTab->ClipCode;
|
||||
if (ClipZ<0)
|
||||
{
|
||||
addPrim(ThisOT,TPrimPtr);
|
||||
TPrimPtr++;
|
||||
}
|
||||
}
|
||||
MapRow++;
|
||||
BlkPos.vx+=BLOCK_SIZE;
|
||||
}
|
||||
MapPtr+=MapWidth;
|
||||
BlkPos.vx=BlkXOld;
|
||||
BlkPos.vy+=BLOCK_SIZE;
|
||||
}
|
||||
|
||||
SetPrimPtr((u8*)TPrimPtr);
|
||||
|
||||
#if defined(_SHOW_POLYZ_)
|
||||
char Txt[256];
|
||||
int TCount=((u8*)TPrimPtr-PrimPtr)/sizeof(POLY_FT3);
|
||||
int QCount=0;
|
||||
sprintf(Txt,"TC %i\nQC %i",TCount,QCount);
|
||||
Font->print( 128, 32, Txt);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
*/
|
|
@ -18,6 +18,7 @@
|
|||
struct sFlipTable
|
||||
{
|
||||
s16 Mtx[4];
|
||||
DVECTOR *DeltaTab[8];
|
||||
s32 ClipCode;
|
||||
};
|
||||
extern sFlipTable FlipTable[];
|
||||
|
@ -37,6 +38,7 @@ public:
|
|||
|
||||
protected:
|
||||
void CacheElemVtx(sElem3d *Elem);
|
||||
void CalcDelta();
|
||||
|
||||
sElem3d *ElemBank3d;
|
||||
sTri *TriList;
|
||||
|
@ -44,6 +46,16 @@ protected:
|
|||
sVtx *VtxList;
|
||||
u16 *VtxIdxList;
|
||||
DVECTOR RenderOfs;
|
||||
|
||||
s16 *FTableX[16];
|
||||
s16 *FTableY[16];
|
||||
s16 *BTableX[16];
|
||||
s16 *BTableY[16];
|
||||
DVECTOR DeltaFOfs;
|
||||
DVECTOR DeltaBOfs;
|
||||
s16 DeltaF,DeltaB;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue