This commit is contained in:
parent
47d017945d
commit
34e9720e26
7 changed files with 159 additions and 17 deletions
|
@ -104,6 +104,7 @@ CFace F;
|
|||
F.vtx[i] = P[T.p[i]];
|
||||
}
|
||||
F.TPageFlag=0;
|
||||
F.OtOfs=0;
|
||||
F.TexName=Tex;
|
||||
F.Mat = -1;
|
||||
SetTPageFlag(F,MatFlag);
|
||||
|
@ -393,6 +394,7 @@ int ListSize=OutTriList.size();
|
|||
ParseVtx4BBox(OutVtxList[OutFace.P2]);
|
||||
// Materials and other shit
|
||||
SetupUV(InFace,OutFace);
|
||||
OutFace.OTOfs=InFace.OtOfs;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -421,6 +423,7 @@ int ListSize=OutQuadList.size();
|
|||
|
||||
// Materials and other shit
|
||||
SetupUV(InFace,OutFace);
|
||||
OutFace.OTOfs=InFace.OtOfs;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
bool Avail;
|
||||
GString TexName;
|
||||
int TPageFlag;
|
||||
int OtOfs;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ sLayerNameTable LayerNameTable[]=
|
|||
int TSize,QSize,VSize;
|
||||
int Tile2dSize,Tile3dSize;
|
||||
const char *ModelExcludeGroupName="ModelExcludeList";
|
||||
const char *ModelOtOfsGroupName="ModelOtOfs";
|
||||
|
||||
//***************************************************************************
|
||||
const GString ConfigFilename="MkLevel.ini";
|
||||
|
@ -220,7 +221,14 @@ int i,ListSize=ModelList.size();
|
|||
for (i=0; i<ListSize; i++)
|
||||
{
|
||||
sMkLevelModel &ThisModel=ModelList[i];
|
||||
ThisModel.ElemID=Create3dElem(ThisModel.TriCount,ThisModel.TriStart,false,false); // always all models as global for the moment
|
||||
int OtOfs=0;
|
||||
|
||||
Config.GetInt(ModelOtOfsGroupName,ThisModel.Name,OtOfs);
|
||||
|
||||
if (OtOfs)
|
||||
printf("ModelOTOfs %s %i\n",ThisModel.Name,OtOfs);
|
||||
|
||||
ThisModel.ElemID=Create3dElem(ThisModel.TriCount,ThisModel.TriStart,false,false,OtOfs); // always all models as global for the moment
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,6 +262,7 @@ int Size;
|
|||
|
||||
LoadTiles(FileHdr);
|
||||
LoadLayers(FileHdr);
|
||||
SnapTiles();
|
||||
|
||||
free(FileHdr);
|
||||
}
|
||||
|
@ -383,6 +392,44 @@ u8 *ByteHdr=(u8*)FileHdr;
|
|||
}
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
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;
|
||||
|
||||
void CMkLevel::SnapTiles()
|
||||
{
|
||||
int i,ListSize=InTileList.size();
|
||||
int Count=0;
|
||||
|
||||
for (i=0;i<ListSize;i++)
|
||||
{
|
||||
sExpTile &ThisTile=InTileList[i];
|
||||
for (int T=0; T<ThisTile.TriCount; T++)
|
||||
{
|
||||
sExpTri &ThisTri=InTriList[ThisTile.TriStart+T];
|
||||
for (int p=0;p<3; p++)
|
||||
{
|
||||
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 (Count)
|
||||
{
|
||||
printf("Snapped %i Vtx Coords - Bad Artists\n",Count);
|
||||
}
|
||||
}
|
||||
//***************************************************************************
|
||||
//*** Process ***************************************************************
|
||||
//***************************************************************************
|
||||
|
@ -521,13 +568,17 @@ CFaceStore &ThisList=ThisElem.FaceStore;
|
|||
}
|
||||
else
|
||||
{ // Local Geom
|
||||
AddDefVtx(ThisElem.LocalVtxList);
|
||||
ThisList.Process(OutTriList,OutQuadList,ThisElem.LocalVtxList);
|
||||
int v,VtxListSize=ThisElem.LocalVtxList.size();
|
||||
vector<sVtx> LocalVtxList;
|
||||
AddDefVtx(LocalVtxList);
|
||||
ThisList.Process(OutTriList,OutQuadList,LocalVtxList);
|
||||
ThisElem.LocalVtxIdxStart=OutLocalVtxIdxList.size();
|
||||
printf("%i\n",LocalVtxList.size());
|
||||
|
||||
int v,VtxListSize=LocalVtxList.size();
|
||||
for (v=0; v<VtxListSize; v++)
|
||||
{
|
||||
u16 Idx=CFaceStore::AddVtx(OutVtxList,ThisElem.LocalVtxList[v]);
|
||||
ThisElem.LocalVtxIdxList.push_back(Idx);
|
||||
u16 Idx=CFaceStore::AddVtx(OutVtxList,LocalVtxList[v]);
|
||||
OutLocalVtxIdxList.push_back(Idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,7 +661,7 @@ sExpTile &SrcTile=InTileList[Tile];
|
|||
int ElemID;
|
||||
if (SrcTile.TriCount)
|
||||
{
|
||||
ElemID=Create3dElem(SrcTile.TriCount,SrcTile.TriStart,LocalGeom,true);
|
||||
ElemID=Create3dElem(SrcTile.TriCount,SrcTile.TriStart,LocalGeom,true,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -621,7 +672,7 @@ int ElemID;
|
|||
}
|
||||
|
||||
//***************************************************************************
|
||||
int CMkLevel::Create3dElem(int TriCount,int TriStart,bool Local,bool IsTile)
|
||||
int CMkLevel::Create3dElem(int TriCount,int TriStart,bool Local,bool IsTile,int OtOfs)
|
||||
{
|
||||
CFace F;
|
||||
int i,ListSize;
|
||||
|
@ -677,8 +728,10 @@ CFaceStore &FaceList=ThisElem.FaceStore;
|
|||
F.uvs[p].u=ThisTri.uv[p][0];
|
||||
F.uvs[p].v=ThisTri.uv[p][1];
|
||||
}
|
||||
F.OtOfs=OtOfs;
|
||||
FaceList.SetTPageFlag(F,ThisTri.Flags);
|
||||
FaceList.AddFace(F,true);
|
||||
|
||||
}
|
||||
if (IsTile)
|
||||
ThisElem.Model=false;
|
||||
|
@ -718,6 +771,7 @@ CFaceStore &FaceList=ThisElem.FaceStore;
|
|||
F.uvs[p].u=ThisTri.uv[p][0];
|
||||
F.uvs[p].v=ThisTri.uv[p][1];
|
||||
}
|
||||
F.OtOfs=0;
|
||||
FaceList.SetTPageFlag(F,0);
|
||||
FaceList.AddFace(F,true);
|
||||
}
|
||||
|
@ -911,6 +965,8 @@ int ZOfs=+4*Scale;
|
|||
OtOfs/=8;
|
||||
if (MinOT>OtOfs) MinOT=OtOfs;
|
||||
if (MaxOT<OtOfs) MaxOT=OtOfs;
|
||||
|
||||
OtOfs+=T.OTOfs;
|
||||
if (OtOfs>15) OtOfs=15;
|
||||
if (OtOfs<0) OtOfs=0;
|
||||
|
||||
|
|
|
@ -62,8 +62,10 @@ struct sOutElem3d
|
|||
bool Model;
|
||||
sElem3d Elem3d;
|
||||
CFaceStore FaceStore;
|
||||
vector<sVtx> LocalVtxList;
|
||||
CList<u16> LocalVtxIdxList;
|
||||
// CList<u16> LocalVtxIdxList;
|
||||
int LocalVtxIdxStart;
|
||||
int LocalVtxIdxCount;
|
||||
int OTOfs;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -116,7 +118,7 @@ public:
|
|||
protected:
|
||||
void BuildModel(CScene &ThisScene,GString &RootPath,int Node);
|
||||
|
||||
int Create3dElem(int TriCount,int TriStart,bool Local,bool IsTile);
|
||||
int Create3dElem(int TriCount,int TriStart,bool Local,bool IsTile,int OtOfs);
|
||||
int Create2dElem(int Tile,bool Local);
|
||||
|
||||
CMkLevelLayer *FindLayer(int Type,int SubType);
|
||||
|
@ -126,6 +128,7 @@ protected:
|
|||
void LoadLayers(sExpFileHdr *FileHdr);
|
||||
void LoadLayer(sExpLayerHdr *LayerHdr);
|
||||
|
||||
void SnapTiles();
|
||||
void AddDefVtx(vector<sVtx> &VtxList);
|
||||
|
||||
void PreProcessLayers();
|
||||
|
@ -199,6 +202,7 @@ protected:
|
|||
vector<sTri> OutTriList;
|
||||
vector<sQuad> OutQuadList;
|
||||
vector<sVtx> OutVtxList;
|
||||
vector<u16> OutLocalVtxIdxList;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -324,6 +324,7 @@ void CLevel::initLayers()
|
|||
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->CollisionLayer);
|
||||
CollisionLayer=new ("Collision Layer") CLayerCollision(Layer);
|
||||
CGameScene::setCollision(CollisionLayer);
|
||||
CreateTileStore();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -574,6 +575,7 @@ void CLevel::respawnLevel()
|
|||
|
||||
CThingManager::killAllThingsForRespawn();
|
||||
initThings(true);
|
||||
ApplyTileStore(); // Put dem tiles back
|
||||
}
|
||||
|
||||
|
||||
|
@ -604,6 +606,7 @@ void CLevel::shutdown()
|
|||
if (ActorList) MemFree(ActorList);
|
||||
if (PlatformList) MemFree(PlatformList);
|
||||
if (HazardList) MemFree(HazardList);
|
||||
if (m_TileStore) MemFree(m_TileStore);
|
||||
|
||||
MemFree(LevelHdr);
|
||||
CActorPool::Reset();
|
||||
|
@ -671,8 +674,6 @@ const int ColT=COLLISION_TYPE_DESTRUCTABLE_WALL;
|
|||
TL.vy=Pos.vy&-16;;
|
||||
BR=TL;
|
||||
|
||||
// if (CollisionLayer->getCollisionBlock(TL.vx,TL.vy)>>COLLISION_TYPE_FLAG_SHIFT==ColT)printf ("!!");
|
||||
|
||||
// Left
|
||||
while (CollisionLayer->getCollisionBlock(TL.vx-16,TL.vy)>>COLLISION_TYPE_FLAG_SHIFT==ColT) TL.vx-=16;
|
||||
// Top
|
||||
|
@ -766,3 +767,67 @@ DVECTOR DP;
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
void CLevel::CreateTileStore()
|
||||
{
|
||||
int MapW=CollisionLayer->getMapWidth();
|
||||
int MapH=CollisionLayer->getMapHeight();
|
||||
int X,Y;
|
||||
|
||||
m_TileStoreCount=0;
|
||||
m_TileStore=0;
|
||||
// CountEm
|
||||
for (Y=0; Y<MapH; Y++)
|
||||
{
|
||||
for (X=0; X<MapW; X++)
|
||||
{
|
||||
u8 *ColElem=CollisionLayer->getMapPtr(X*16,Y*16);
|
||||
int ColT = (*ColElem) & COLLISION_TYPE_MASK;
|
||||
if ( ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_FLOOR || ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_WALL)
|
||||
{
|
||||
m_TileStoreCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// StoreEm
|
||||
if (m_TileStoreCount)
|
||||
{
|
||||
m_TileStore=(sTileStore*)MemAlloc(m_TileStoreCount*sizeof(sTileStore),"TileStoreList");
|
||||
|
||||
sTileStore *Ptr=m_TileStore;
|
||||
for (Y=0; Y<MapH; Y++)
|
||||
{
|
||||
for (X=0; X<MapW; X++)
|
||||
{
|
||||
u8 *ColElem=CollisionLayer->getMapPtr(X*16,Y*16);
|
||||
int ColT = (*ColElem) & COLLISION_TYPE_MASK;
|
||||
if ( ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_FLOOR || ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_WALL)
|
||||
{
|
||||
Ptr->X=X;
|
||||
Ptr->Y=Y;
|
||||
Ptr->Col=*ColElem;
|
||||
Ptr->Tile=*TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]->getMapPtr(X*16,Y*16);
|
||||
Ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void CLevel::ApplyTileStore()
|
||||
{
|
||||
sTileStore *Ptr=m_TileStore;
|
||||
|
||||
for (int i=0; i<m_TileStoreCount; i++)
|
||||
{
|
||||
u8 *ColElem=CollisionLayer->getMapPtr(Ptr->X*16,Ptr->Y*16);
|
||||
sTileMapElem *MapElem=TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]->getMapPtr(Ptr->X*16,Ptr->Y*16);
|
||||
|
||||
*ColElem=Ptr->Col;
|
||||
*MapElem=Ptr->Tile;
|
||||
Ptr++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,14 @@ struct sLvlTab
|
|||
extern int s_globalLevelSelectThing;
|
||||
extern sLvlTab LvlTable[];
|
||||
|
||||
/*****************************************************************************/
|
||||
struct sTileStore
|
||||
{
|
||||
u16 X,Y;
|
||||
sTileMapElem Tile;
|
||||
u8 Col;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
class CLayer;
|
||||
class CLevel
|
||||
|
@ -83,6 +91,7 @@ private:
|
|||
|
||||
void DisplayLoadingScreen(sLvlTab *lvlTab);
|
||||
|
||||
|
||||
static sLevelHdr *LevelHdr;
|
||||
|
||||
static DVECTOR MapPos;
|
||||
|
@ -112,7 +121,11 @@ static DVECTOR s_playerSpawnPos;
|
|||
static u8 m_isBossRespawn;
|
||||
static s32 m_bossHealth;
|
||||
|
||||
|
||||
// Level Repair stuff
|
||||
void CreateTileStore();
|
||||
void ApplyTileStore();
|
||||
int m_TileStoreCount;
|
||||
sTileStore *m_TileStore;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -42,7 +42,6 @@ enum PSX_COLLSION_ENUM
|
|||
COLLISION_TYPE_FLAG_DEATH_LIQUID =COLLISION_TYPE_DEATH_LIQUID << COLLISION_TYPE_FLAG_SHIFT,
|
||||
COLLISION_TYPE_FLAG_SB_NOMOVE =COLLISION_TYPE_SB_NOMOVE << COLLISION_TYPE_FLAG_SHIFT,
|
||||
|
||||
|
||||
COLLISION_TYPE_MASK = ((0xff<<COLLISION_TYPE_FLAG_SHIFT)&0xff),
|
||||
COLLISION_TILE_MASK = (0xff - COLLISION_TYPE_MASK)
|
||||
|
||||
|
@ -232,6 +231,7 @@ struct sLevelHdr
|
|||
sTri *TriList;
|
||||
sQuad *QuadList;
|
||||
sVtx *VtxList;
|
||||
u16 *LocalVtxList;
|
||||
sModel *ModelList;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue