This commit is contained in:
parent
cb4922cb43
commit
57211b9df3
17 changed files with 478 additions and 740 deletions
|
@ -2,7 +2,7 @@
|
||||||
/*** Generic Face Compilation Storage ***/
|
/*** Generic Face Compilation Storage ***/
|
||||||
/****************************************/
|
/****************************************/
|
||||||
// Contains tri data with texture data
|
// Contains tri data with texture data
|
||||||
// Will quad later
|
|
||||||
|
|
||||||
#include <ginio.h>
|
#include <ginio.h>
|
||||||
#include <gintex.h>
|
#include <gintex.h>
|
||||||
|
@ -100,15 +100,8 @@ CFace F;
|
||||||
|
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
F.pts[i] = T.p[i];
|
|
||||||
F.vis[i] = T.vis[i];
|
|
||||||
F.uvs[i] = uv.p[i];
|
F.uvs[i] = uv.p[i];
|
||||||
F.vtx[i] = P[T.p[i]];
|
F.vtx[i] = P[T.p[i]];
|
||||||
// Limit UV's
|
|
||||||
if (F.uvs[i].u < 0.f) F.uvs[i].u=0.f;
|
|
||||||
if (F.uvs[i].u > 1.f) F.uvs[i].u=1.f;
|
|
||||||
if (F.uvs[i].v < 0.f) F.uvs[i].v=0.f;
|
|
||||||
if (F.uvs[i].v > 1.f) F.uvs[i].v=1.f;
|
|
||||||
}
|
}
|
||||||
F.TPageFlag=0;
|
F.TPageFlag=0;
|
||||||
F.TexName=Tex;
|
F.TexName=Tex;
|
||||||
|
@ -119,15 +112,21 @@ CFace &NF=AddFace(F,ProcessTexFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
// All AddFace's lead to here!
|
||||||
CFace &CFaceStore::AddFace(CFace &F,bool ProcessTexFlag)
|
CFace &CFaceStore::AddFace(CFace &F,bool ProcessTexFlag)
|
||||||
{
|
{
|
||||||
int ListSize=FaceList.size();
|
int ListSize=FaceList.size();
|
||||||
FaceList.resize(ListSize+1);
|
FaceList.resize(ListSize+1);
|
||||||
|
|
||||||
// Process Vtx's
|
// Process Vtx's (for Quad)
|
||||||
for (int i=0; i<3; i++)
|
for (int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
F.pts[i]=AddVtx(F.vtx[i]);
|
F.pts[i]=AddVtx(VtxList,F.vtx[i]);
|
||||||
|
// Limit UV's
|
||||||
|
if (F.uvs[i].u < 0.f) F.uvs[i].u=0.f;
|
||||||
|
if (F.uvs[i].u > 1.f) F.uvs[i].u=1.f;
|
||||||
|
if (F.uvs[i].v < 0.f) F.uvs[i].v=0.f;
|
||||||
|
if (F.uvs[i].v > 1.f) F.uvs[i].v=1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProcessTexFlag && F.Mat==-1)
|
if (ProcessTexFlag && F.Mat==-1)
|
||||||
|
@ -163,38 +162,15 @@ int ListSize=Faces.GetFaceCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
/*
|
|
||||||
CFace &CFaceStore::AddFace(sTriFace &Face,int ID)
|
|
||||||
{
|
|
||||||
int ListSize = FaceList.size();
|
|
||||||
FaceList.resize(ListSize+1);
|
|
||||||
CFace &F = FaceList[ListSize];
|
|
||||||
|
|
||||||
for (int i=0; i<3; i++)
|
|
||||||
{
|
|
||||||
F.pts[i] = Face.pts[i];
|
|
||||||
F.uvs[i] = Face.uvs[i];
|
|
||||||
F.vtx[i] = Face.vtx[i];
|
|
||||||
// Limit UV's
|
|
||||||
if (F.uvs[i].u < 0.f) F.uvs[i].u=0.f;
|
|
||||||
if (F.uvs[i].u > 1.f) F.uvs[i].u=1.f;
|
|
||||||
if (F.uvs[i].v < 0.f) F.uvs[i].v=0.f;
|
|
||||||
if (F.uvs[i].v > 1.f) F.uvs[i].v=1.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
F.Mat = Face.Mat;
|
|
||||||
F.Normal = crossProduct( F.vtx[0], F.vtx[1], F.vtx[2] );
|
|
||||||
F.Avail = true;
|
|
||||||
F.ID=ID;
|
|
||||||
return(F);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//*** Texture Stuff *********************************************************
|
//*** Texture Stuff *********************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
int CFaceStore::AddTex(GString const &TexName)
|
int CFaceStore::AddTex(GString const &TexName)
|
||||||
{
|
{
|
||||||
|
if (!TexGrab)
|
||||||
|
{
|
||||||
|
GObject::Error(ERR_FATAL,"TexGrab Not Defined!!\n");
|
||||||
|
}
|
||||||
static GString LastTex;
|
static GString LastTex;
|
||||||
static int LastIdx=-1;
|
static int LastIdx=-1;
|
||||||
vector<FileInfo> const &TexList=TexGrab->GetTexInfoList();
|
vector<FileInfo> const &TexList=TexGrab->GetTexInfoList();
|
||||||
|
@ -220,109 +196,21 @@ GString Filename=TexName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CFaceStore::ProcessTextures()
|
void CFaceStore::Process(vector<sTri> &OutTriList,vector<sQuad> &OutQuadList,vector<sVtx> &OutVtxList)
|
||||||
{
|
{
|
||||||
// Set Texgrab Defaults
|
BBox.XMin=+30000;
|
||||||
TexGrab->ShrinkToFit(true);
|
BBox.YMin=+30000;
|
||||||
TexGrab->NoSort();
|
BBox.XMax=-30000;
|
||||||
|
BBox.YMax=-30000;
|
||||||
|
|
||||||
TexGrab->AnimatedHeadersOnly(true);
|
|
||||||
TexGrab->DontOutputBoxes(true);
|
|
||||||
TexGrab->AllowRotate(true);
|
|
||||||
TexGrab->Process();
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
void CFaceStore::Process()
|
|
||||||
{
|
|
||||||
Quad();
|
Quad();
|
||||||
BuildOutTriLists();
|
BuildOutTriList(OutTriList,OutVtxList);
|
||||||
|
BuildOutQuadList(OutQuadList,OutVtxList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CFaceStore::Quad()
|
|
||||||
{
|
|
||||||
int FaceCount=FaceList.size();
|
|
||||||
|
|
||||||
for (int i=0; i<FaceCount; i++)
|
|
||||||
{
|
|
||||||
TriFaceList.push_back(FaceList[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
//***************************************************************************
|
|
||||||
//***************************************************************************
|
|
||||||
/*
|
|
||||||
void CFaceStore::SetupUV(CFace const &In, sTri &Out)
|
|
||||||
{
|
|
||||||
vector<sTexOutInfo> &TexInfo=TexGrab->GetTexInfo();
|
|
||||||
sTexOutInfo &ThisTex=TexInfo[In.Mat];
|
|
||||||
ASSERT(In.Mat<TexInfo.size());
|
|
||||||
|
|
||||||
// Uses orig tex size to make sure mapping is corrent on 'shrunk' textures :o)
|
|
||||||
int W = ThisTex.OrigW - 1;
|
|
||||||
int H = ThisTex.OrigH - 1;
|
|
||||||
int XOfs=0,YOfs=0;
|
|
||||||
|
|
||||||
int uv0[2];
|
|
||||||
int uv1[2];
|
|
||||||
int uv2[2];
|
|
||||||
|
|
||||||
if (ThisTex.Rotated)
|
|
||||||
{
|
|
||||||
// uv0[0] = (ThisTex.u + H) - round(In.uvs[0].v * H);
|
|
||||||
// uv0[1] = (ThisTex.v + W) - round(In.uvs[0].u * W);
|
|
||||||
// uv1[0] = (ThisTex.u + H) - round(In.uvs[1].v * H);
|
|
||||||
// uv1[1] = (ThisTex.v + W) - round(In.uvs[1].u * W);
|
|
||||||
// uv2[0] = (ThisTex.u + H) - round(In.uvs[2].v * H);
|
|
||||||
// uv2[1] = (ThisTex.v + W) - round(In.uvs[2].u * W);
|
|
||||||
|
|
||||||
uv0[0] = (ThisTex.u ) - round(In.uvs[0].v * H);
|
|
||||||
uv0[1] = (ThisTex.v ) - round(In.uvs[0].u * W);
|
|
||||||
uv1[0] = (ThisTex.u ) - round(In.uvs[1].v * H);
|
|
||||||
uv1[1] = (ThisTex.v ) - round(In.uvs[1].u * W);
|
|
||||||
uv2[0] = (ThisTex.u ) - round(In.uvs[2].v * H);
|
|
||||||
uv2[1] = (ThisTex.v ) - round(In.uvs[2].u * W);
|
|
||||||
|
|
||||||
XOfs=H-((ThisTex.OrigW-ThisTex.h));
|
|
||||||
YOfs= +((ThisTex.OrigH-ThisTex.w)-W);
|
|
||||||
ASSERT(!"");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
W=ThisTex.w-1;
|
|
||||||
H=ThisTex.h-1;
|
|
||||||
// Out.uv0[0] = (ThisTex.u)+ round(In.uvs[0].u * W);
|
|
||||||
// Out.uv0[1] = (ThisTex.v + H) - round(In.uvs[0].v * H);
|
|
||||||
// Out.uv1[0] = (ThisTex.u)+ round(In.uvs[1].u * W);
|
|
||||||
// Out.uv1[1] = (ThisTex.v + H) - round(In.uvs[1].v * H);
|
|
||||||
// Out.uv2[0] = (ThisTex.u)+ round(In.uvs[2].u * W);
|
|
||||||
// Out.uv2[1] = (ThisTex.v + H) - round(In.uvs[2].v * H);
|
|
||||||
|
|
||||||
uv0[0] = (ThisTex.u) + round(In.uvs[0].u * W);
|
|
||||||
uv0[1] = (ThisTex.v) - round(In.uvs[0].v * H);
|
|
||||||
uv1[0] = (ThisTex.u) + round(In.uvs[1].u * W);
|
|
||||||
uv1[1] = (ThisTex.v) - round(In.uvs[1].v * H);
|
|
||||||
uv2[0] = (ThisTex.u) + round(In.uvs[2].u * W);
|
|
||||||
uv2[1] = (ThisTex.v) - round(In.uvs[2].v * H);
|
|
||||||
|
|
||||||
XOfs=(ThisTex.OrigW-ThisTex.w);
|
|
||||||
YOfs=(ThisTex.OrigH-ThisTex.h)-H;
|
|
||||||
XOfs=0;
|
|
||||||
YOfs=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Out.uv0[0]=uv0[0]-XOfs; Out.uv0[1]=uv0[1]-YOfs;
|
|
||||||
Out.uv1[0]=uv1[0]-XOfs; Out.uv1[1]=uv1[1]-YOfs;
|
|
||||||
Out.uv2[0]=uv2[0]-XOfs; Out.uv2[1]=uv2[1]-YOfs;
|
|
||||||
|
|
||||||
Out.TPage=ThisTex.Tpage;
|
|
||||||
Out.Clut=ThisTex.Clut;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
void CFaceStore::SetupUV(CFace const &In, sTri &Out)
|
void CFaceStore::SetupUV(CFace const &In, sTri &Out)
|
||||||
{
|
{
|
||||||
vector<sTexOutInfo> &TexInfo=TexGrab->GetTexInfo();
|
vector<sTexOutInfo> &TexInfo=TexGrab->GetTexInfo();
|
||||||
|
@ -347,18 +235,8 @@ int H = ThisTex.h - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// W=ThisTex.OrigW-1;
|
|
||||||
// H=ThisTex.OrigH-1;
|
|
||||||
if (ThisTex.w!=ThisTex.OrigW) printf("WW");
|
if (ThisTex.w!=ThisTex.OrigW) printf("WW");
|
||||||
if (ThisTex.h!=ThisTex.OrigH) printf("HH");
|
if (ThisTex.h!=ThisTex.OrigH) printf("HH");
|
||||||
/*
|
|
||||||
uv0[0] = (ThisTex.u)+ round(In.uvs[0].u * W);
|
|
||||||
uv0[1] = (ThisTex.v + H) - round(In.uvs[0].v * H);
|
|
||||||
uv1[0] = (ThisTex.u)+ round(In.uvs[1].u * W);
|
|
||||||
uv1[1] = (ThisTex.v + H) - round(In.uvs[1].v * H);
|
|
||||||
uv2[0] = (ThisTex.u)+ round(In.uvs[2].u * W);
|
|
||||||
uv2[1] = (ThisTex.v + H) - round(In.uvs[2].v * H);
|
|
||||||
*/
|
|
||||||
int U=ThisTex.u;
|
int U=ThisTex.u;
|
||||||
int V=ThisTex.v+H;
|
int V=ThisTex.v+H;
|
||||||
|
|
||||||
|
@ -369,10 +247,6 @@ int V=ThisTex.v+H;
|
||||||
uv2[0] = U + round(In.uvs[2].u * W);
|
uv2[0] = U + round(In.uvs[2].u * W);
|
||||||
uv2[1] = V - round(In.uvs[2].v * H);
|
uv2[1] = V - round(In.uvs[2].v * H);
|
||||||
|
|
||||||
// XOfs=(ThisTex.OrigW-ThisTex.w);
|
|
||||||
// XOfs=ThisTex.XOfs;
|
|
||||||
// YOfs=H-(ThisTex.OrigH-ThisTex.h);
|
|
||||||
// YOfs=H;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Out.uv0[0]=(uv0[0]-XOfs); Out.uv0[1]=(uv0[1]-YOfs);
|
Out.uv0[0]=(uv0[0]-XOfs); Out.uv0[1]=(uv0[1]-YOfs);
|
||||||
|
@ -391,7 +265,6 @@ int V=ThisTex.v+H;
|
||||||
Out.TPage|=In.TPageFlag<<5;
|
Out.TPage|=In.TPageFlag<<5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -401,6 +274,10 @@ void CFaceStore::SetupUV(CFace const &In, sQuad &Out)
|
||||||
{
|
{
|
||||||
vector<sTexOutInfo> &TexInfo=TexGrab->GetTexInfo();
|
vector<sTexOutInfo> &TexInfo=TexGrab->GetTexInfo();
|
||||||
sTexOutInfo &ThisTex=TexInfo[In.Mat];
|
sTexOutInfo &ThisTex=TexInfo[In.Mat];
|
||||||
|
ASSERT(In.Mat<TexInfo.size());
|
||||||
|
|
||||||
|
int uv0[2],uv1[2],uv2[2],uv3[2];
|
||||||
|
int XOfs=0,YOfs=0;
|
||||||
|
|
||||||
int W = ThisTex.w - 1;
|
int W = ThisTex.w - 1;
|
||||||
int H = ThisTex.h - 1;
|
int H = ThisTex.h - 1;
|
||||||
|
@ -413,29 +290,49 @@ int H = ThisTex.h - 1;
|
||||||
Out.uv1[1] = (ThisTex.v + W) - round(In.uvs[1].u * W);
|
Out.uv1[1] = (ThisTex.v + W) - round(In.uvs[1].u * W);
|
||||||
Out.uv2[0] = (ThisTex.u + H) - round(In.uvs[2].v * H);
|
Out.uv2[0] = (ThisTex.u + H) - round(In.uvs[2].v * H);
|
||||||
Out.uv2[1] = (ThisTex.v + W) - round(In.uvs[2].u * W);
|
Out.uv2[1] = (ThisTex.v + W) - round(In.uvs[2].u * W);
|
||||||
Out.uv3[0] = (ThisTex.u + H) - round(In.uvs[3].v * H);
|
ASSERT(0==1);
|
||||||
Out.uv3[1] = (ThisTex.v + W) - round(In.uvs[3].u * W);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Out.uv0[0] = (ThisTex.u)+ round(In.uvs[0].u * W);
|
if (ThisTex.w!=ThisTex.OrigW) printf("WW");
|
||||||
Out.uv0[1] = (ThisTex.v + H) - round(In.uvs[0].v * H);
|
if (ThisTex.h!=ThisTex.OrigH) printf("HH");
|
||||||
Out.uv1[0] = (ThisTex.u)+ round(In.uvs[1].u * W);
|
int U=ThisTex.u;
|
||||||
Out.uv1[1] = (ThisTex.v + H) - round(In.uvs[1].v * H);
|
int V=ThisTex.v+H;
|
||||||
Out.uv2[0] = (ThisTex.u)+ round(In.uvs[2].u * W);
|
|
||||||
Out.uv2[1] = (ThisTex.v + H) - round(In.uvs[2].v * H);
|
uv0[0] = U + round(In.uvs[0].u * W);
|
||||||
Out.uv3[0] = (ThisTex.u)+ round(In.uvs[3].u * W);
|
uv0[1] = V - round(In.uvs[0].v * H);
|
||||||
Out.uv3[1] = (ThisTex.v + H) - round(In.uvs[3].v * H);
|
uv1[0] = U + round(In.uvs[1].u * W);
|
||||||
|
uv1[1] = V - round(In.uvs[1].v * H);
|
||||||
|
uv2[0] = U + round(In.uvs[2].u * W);
|
||||||
|
uv2[1] = V - round(In.uvs[2].v * H);
|
||||||
|
uv3[0] = U + round(In.uvs[3].u * W);
|
||||||
|
uv3[1] = V - round(In.uvs[3].v * H);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Out.uv0[0]=(uv0[0]-XOfs); Out.uv0[1]=(uv0[1]-YOfs);
|
||||||
|
Out.uv1[0]=(uv1[0]-XOfs); Out.uv1[1]=(uv1[1]-YOfs);
|
||||||
|
Out.uv2[0]=(uv2[0]-XOfs); Out.uv2[1]=(uv2[1]-YOfs);
|
||||||
|
Out.uv3[0]=(uv3[0]-XOfs); Out.uv3[1]=(uv3[1]-YOfs);
|
||||||
|
|
||||||
Out.TPage=ThisTex.Tpage;
|
Out.TPage=ThisTex.Tpage;
|
||||||
Out.Clut=ThisTex.Clut;
|
Out.Clut=ThisTex.Clut;
|
||||||
|
Out.PolyCode=GPU_PolyFT3Code;
|
||||||
|
|
||||||
|
if (In.TPageFlag)
|
||||||
|
{
|
||||||
|
Out.PolyCode|=GPUCode_SemiTrans;
|
||||||
|
if (In.TPageFlag!=1)
|
||||||
|
{
|
||||||
|
Out.TPage|=In.TPageFlag<<5;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
int CFaceStore::AddVtx(Vector3 &InVtx)
|
int CFaceStore::AddVtx(vector<sVtx> &OutVtxList,Vector3 &InVtx)
|
||||||
{
|
{
|
||||||
int ListSize=OutVtxList.size();
|
int ListSize=OutVtxList.size();
|
||||||
sVtx ThisVtx;
|
sVtx ThisVtx;
|
||||||
|
@ -454,20 +351,46 @@ sVtx ThisVtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CFaceStore::BuildOutTriLists()
|
int CFaceStore::AddVtx(vector<sVtx> &OutVtxList,sVtx &ThisVtx)
|
||||||
|
{
|
||||||
|
int ListSize=OutVtxList.size();
|
||||||
|
|
||||||
|
for (int i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
if (OutVtxList[i]==ThisVtx) return(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
OutVtxList.push_back(ThisVtx);
|
||||||
|
return(ListSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CFaceStore::ParseVtx4BBox(sVtx &ThisVtx)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
//***************************************************************************
|
||||||
|
void CFaceStore::BuildOutTriList(vector<sTri> &OutTriList,vector<sVtx> &OutVtxList)
|
||||||
{
|
{
|
||||||
int FaceCount=TriFaceList.size();
|
int FaceCount=TriFaceList.size();
|
||||||
|
int ListSize=OutTriList.size();
|
||||||
OutTriList.resize(FaceCount);
|
OutTriList.resize(ListSize+FaceCount);
|
||||||
|
|
||||||
for (int i=0; i<FaceCount; i++)
|
for (int i=0; i<FaceCount; i++)
|
||||||
{
|
{
|
||||||
CFace &InFace=TriFaceList[i];
|
CFace &InFace=TriFaceList[i];
|
||||||
sTri &OutFace=OutTriList[i];
|
sTri &OutFace=OutTriList[ListSize+i];
|
||||||
|
|
||||||
OutFace.P0=InFace.pts[0];
|
OutFace.P0=AddVtx(OutVtxList,InFace.vtx[0]);
|
||||||
OutFace.P1=InFace.pts[1];
|
OutFace.P1=AddVtx(OutVtxList,InFace.vtx[1]);
|
||||||
OutFace.P2=InFace.pts[2];
|
OutFace.P2=AddVtx(OutVtxList,InFace.vtx[2]);
|
||||||
|
|
||||||
|
ParseVtx4BBox(OutVtxList[OutFace.P0]);
|
||||||
|
ParseVtx4BBox(OutVtxList[OutFace.P1]);
|
||||||
|
ParseVtx4BBox(OutVtxList[OutFace.P2]);
|
||||||
// Materials and other shit
|
// Materials and other shit
|
||||||
SetupUV(InFace,OutFace);
|
SetupUV(InFace,OutFace);
|
||||||
}
|
}
|
||||||
|
@ -475,25 +398,30 @@ int FaceCount=TriFaceList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CFaceStore::BuildOutQuadList()
|
void CFaceStore::BuildOutQuadList(vector<sQuad> &OutQuadList,vector<sVtx> &OutVtxList)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int FaceCount=QuadFaceList.size();
|
int FaceCount=QuadFaceList.size();
|
||||||
OutQuadList.resize(FaceCount);
|
int ListSize=OutQuadList.size();
|
||||||
|
OutQuadList.resize(ListSize+FaceCount);
|
||||||
|
|
||||||
for (int i=0; i<FaceCount; i++)
|
for (int i=0; i<FaceCount; i++)
|
||||||
{
|
{
|
||||||
CFace &InFace=QuadFaceList[i];
|
CFace &InFace=QuadFaceList[i];
|
||||||
sQuad &OutFace=OutQuadList[i];
|
sQuad &OutFace=OutQuadList[ListSize+i];
|
||||||
|
|
||||||
OutFace.P0=AddVtx(InFace.vtx[0]*Scale);
|
OutFace.P0=AddVtx(OutVtxList,InFace.vtx[0]);
|
||||||
OutFace.P1=AddVtx(InFace.vtx[1]*Scale);
|
OutFace.P1=AddVtx(OutVtxList,InFace.vtx[1]);
|
||||||
OutFace.P2=AddVtx(InFace.vtx[2]*Scale);
|
OutFace.P2=AddVtx(OutVtxList,InFace.vtx[2]);
|
||||||
OutFace.P3=AddVtx(InFace.vtx[3]*Scale);
|
OutFace.P3=AddVtx(OutVtxList,InFace.vtx[3]);
|
||||||
|
|
||||||
|
ParseVtx4BBox(OutVtxList[OutFace.P0]);
|
||||||
|
ParseVtx4BBox(OutVtxList[OutFace.P1]);
|
||||||
|
ParseVtx4BBox(OutVtxList[OutFace.P2]);
|
||||||
|
ParseVtx4BBox(OutVtxList[OutFace.P3]);
|
||||||
|
|
||||||
// Materials and other shit
|
// Materials and other shit
|
||||||
SetupUV(InFace,OutFace);
|
SetupUV(InFace,OutFace);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -547,22 +475,17 @@ int Pos=ftell(File);
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
#if 0 // quadding stuff
|
|
||||||
bool CFaceStore::CanConnect( int f0, int f1 )
|
bool CFaceStore::CanConnect( int f0, int f1 )
|
||||||
{
|
{
|
||||||
CFace &F0 = FaceList[f0];
|
CFace &F0 = FaceList[f0];
|
||||||
CFace &F1 = FaceList[f1];
|
CFace &F1 = FaceList[f1];
|
||||||
|
|
||||||
// check ID's match (used for nodes, weights)
|
|
||||||
if (F0.ID!=F1.ID) return false;
|
|
||||||
|
|
||||||
// check materials match
|
// check materials match
|
||||||
if (F0.Mat != F1.Mat) return false;
|
if (F0.Mat != F1.Mat) return false;
|
||||||
|
|
||||||
// check normals
|
// check normals
|
||||||
float dp = dotProduct( F0.Normal, F1.Normal );
|
float dp = dotProduct( F0.Normal, F1.Normal );
|
||||||
if (dp < 0.98f)
|
if (dp < 0.98f) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
// check pnt connections
|
// check pnt connections
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
@ -629,7 +552,7 @@ int CFaceStore::CountFacesAttached ( int f )
|
||||||
|
|
||||||
for (int i=0; i<c; i++)
|
for (int i=0; i<c; i++)
|
||||||
{
|
{
|
||||||
if (FaceList[i].avail && i!=f)
|
if (FaceList[i].Avail && i!=f)
|
||||||
{
|
{
|
||||||
if (CanConnect(f, i))
|
if (CanConnect(f, i))
|
||||||
{
|
{
|
||||||
|
@ -649,7 +572,7 @@ void CFaceStore::FollowFace( int id, CFace &F )
|
||||||
int c = FaceList.size();
|
int c = FaceList.size();
|
||||||
for (int i=0; i<c; i++)
|
for (int i=0; i<c; i++)
|
||||||
{
|
{
|
||||||
if (FaceList[i].avail && id != i && CanConnect(id, i))
|
if (FaceList[i].Avail && id != i && CanConnect(id, i))
|
||||||
{
|
{
|
||||||
int fec = CountFacesAttached( i );
|
int fec = CountFacesAttached( i );
|
||||||
if (fec < minC)
|
if (fec < minC)
|
||||||
|
@ -716,7 +639,7 @@ void CFaceStore::FollowFace( int id, CFace &F )
|
||||||
F.pts[ptc] = nf.pts[unc];
|
F.pts[ptc] = nf.pts[unc];
|
||||||
F.vtx[ptc] = nf.vtx[unc];
|
F.vtx[ptc] = nf.vtx[unc];
|
||||||
F.uvs[ptc] = nf.uvs[unc];
|
F.uvs[ptc] = nf.uvs[unc];
|
||||||
nf.avail = false;
|
nf.Avail = false;
|
||||||
|
|
||||||
if (minC && MaxStrip>F.pts.size()) FollowFace( minF, F );
|
if (minC && MaxStrip>F.pts.size()) FollowFace( minF, F );
|
||||||
}
|
}
|
||||||
|
@ -730,7 +653,7 @@ int c = FaceList.size();
|
||||||
|
|
||||||
for (int i=0; i<c; i++)
|
for (int i=0; i<c; i++)
|
||||||
{
|
{
|
||||||
if (FaceList[i].avail)
|
if (FaceList[i].Avail)
|
||||||
{
|
{
|
||||||
int fec = CountFacesAttached( i );
|
int fec = CountFacesAttached( i );
|
||||||
if (fec < minC)
|
if (fec < minC)
|
||||||
|
@ -748,9 +671,8 @@ int c = FaceList.size();
|
||||||
F.pts = FaceList[minF].pts;
|
F.pts = FaceList[minF].pts;
|
||||||
F.uvs = FaceList[minF].uvs;
|
F.uvs = FaceList[minF].uvs;
|
||||||
F.vtx = FaceList[minF].vtx;
|
F.vtx = FaceList[minF].vtx;
|
||||||
FaceList[minF].avail = false;
|
FaceList[minF].Avail = false;
|
||||||
F.Normal= FaceList[minF].Normal;
|
F.Normal= FaceList[minF].Normal;
|
||||||
F.ID= FaceList[minF].ID;
|
|
||||||
|
|
||||||
if (minC && MaxStrip>F.pts.size()) FollowFace( minF, F );
|
if (minC && MaxStrip>F.pts.size()) FollowFace( minF, F );
|
||||||
|
|
||||||
|
@ -760,124 +682,10 @@ int c = FaceList.size();
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CFaceStore::QuadGetPnts(CFace &F,int *Join0,int *Join1,int *Pnt)
|
void CFaceStore::Quad()
|
||||||
{
|
{
|
||||||
if (!F.vis[0])
|
|
||||||
{
|
|
||||||
*Join0= F.pts[0];
|
|
||||||
*Join1= F.pts[1];
|
|
||||||
*Pnt= 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (!F.vis[1])
|
|
||||||
{
|
|
||||||
*Join0= F.pts[1];
|
|
||||||
*Join1= F.pts[2];
|
|
||||||
*Pnt= 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*Join0= F.pts[2];
|
|
||||||
*Join1= F.pts[0];
|
|
||||||
*Pnt= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
int CFaceStore::QuadGetAttached(int FaceNo)
|
|
||||||
{
|
|
||||||
CFace ThisFace=FaceList[FaceNo];
|
|
||||||
int Vis=ThisFace.vis[0]+ThisFace.vis[1]+ThisFace.vis[2];
|
|
||||||
if (Vis==7) return(0); // Pure Tri
|
|
||||||
int FaceCount=FaceList.size();
|
|
||||||
int J00,J01,P0;
|
|
||||||
int J10,J11,P1;
|
|
||||||
|
|
||||||
QuadGetPnts(ThisFace,&J00,&J01,&P0);
|
|
||||||
|
|
||||||
for (int Loop=FaceNo+1;Loop<FaceCount;Loop++)
|
|
||||||
{
|
|
||||||
CFace &cFace=FaceList[Loop];
|
|
||||||
if (cFace.avail)
|
|
||||||
{
|
|
||||||
if (ThisFace.Normal.x==cFace.Normal.x &&
|
|
||||||
ThisFace.Normal.y==cFace.Normal.y &&
|
|
||||||
ThisFace.Normal.z==cFace.Normal.z)
|
|
||||||
{
|
|
||||||
if (ThisFace.Mat==cFace.Mat && ThisFace.ID==cFace.ID)
|
|
||||||
{
|
|
||||||
QuadGetPnts(cFace,&J10,&J11,&P1);
|
|
||||||
if ((J00==J10 && J01==J11) || (J00==J11 && J01==J10)) return(Loop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
void CFaceStore::OrderPnts( CFace &F ,int unc)
|
|
||||||
{
|
|
||||||
int idx;
|
|
||||||
if (!F.vis[0]) idx=2;
|
|
||||||
if (!F.vis[1]) idx=0;
|
|
||||||
if (!F.vis[2]) idx=1;
|
|
||||||
|
|
||||||
{
|
|
||||||
vector<int>::iterator pb, pe, pm;
|
|
||||||
vector<sUV>::iterator ub, ue, um;
|
|
||||||
vector<Vector3>::iterator vb, ve, vm;
|
|
||||||
pb = F.pts.begin(); pe = F.pts.end();
|
|
||||||
ub = F.uvs.begin(); ue = F.uvs.end();
|
|
||||||
vb = F.vtx.begin(); ve = F.vtx.end();
|
|
||||||
|
|
||||||
pm = pb + idx;
|
|
||||||
um = ub + idx;
|
|
||||||
vm = vb + idx;
|
|
||||||
|
|
||||||
rotate(pb, pm, pe);
|
|
||||||
rotate(ub, um, ue);
|
|
||||||
rotate(vb, vm, ve);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
void CFaceStore::Quad(vector<CFace> &TriList,vector<CFace> &QuadList)
|
|
||||||
{
|
|
||||||
int FaceCount=FaceList.size();
|
|
||||||
|
|
||||||
if (MaxStrip==4)
|
if (MaxStrip==4)
|
||||||
{
|
{
|
||||||
//vector<CFace> ThisTriList;
|
|
||||||
for (int Loop=0;Loop<FaceCount;Loop++)
|
|
||||||
{
|
|
||||||
if (FaceList[Loop].avail)
|
|
||||||
{
|
|
||||||
int Att=QuadGetAttached(Loop);
|
|
||||||
if (Att)
|
|
||||||
{
|
|
||||||
CFace &F=FaceList[Loop];
|
|
||||||
CFace &NF=FaceList[Att];
|
|
||||||
int J0,J1,P;
|
|
||||||
QuadGetPnts(NF,&J0,&J1,&P);
|
|
||||||
FaceList[Loop].avail=FaceList[Att].avail=false;
|
|
||||||
OrderPnts(F,P);
|
|
||||||
F.pts.push_back(NF.pts[P]);
|
|
||||||
F.vtx.push_back(NF.vtx[P]);
|
|
||||||
F.uvs.push_back(NF.uvs[P]);
|
|
||||||
QuadList.push_back(F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strip remaining tris
|
|
||||||
// for (Loop=0;Loop<FaceCount;Loop++)
|
|
||||||
// {
|
|
||||||
// if (FaceList[Loop].avail) ThisTriList.push_back(FaceList[Loop]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool strips = true;
|
bool strips = true;
|
||||||
while (strips)
|
while (strips)
|
||||||
{
|
{
|
||||||
|
@ -886,16 +694,16 @@ int FaceCount=FaceList.size();
|
||||||
if (strips)
|
if (strips)
|
||||||
{
|
{
|
||||||
if (f.pts.size() == 3)
|
if (f.pts.size() == 3)
|
||||||
TriList.push_back(f);
|
TriFaceList.push_back(f);
|
||||||
else
|
else
|
||||||
QuadList.push_back(f);
|
QuadFaceList.push_back(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// printf("Quaded %i extra\n",ThisTriList.size()-TriList.size());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // No quadding, copy direct
|
{ // No quadding, copy direct
|
||||||
for (int Loop=0;Loop<FaceCount;Loop++) TriList.push_back(FaceList[Loop]);
|
int FaceCount=FaceList.size();
|
||||||
|
for (int Loop=0;Loop<FaceCount;Loop++) TriFaceList.push_back(FaceList[Loop]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -23,16 +23,17 @@ struct sFaceTexList
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
/*
|
||||||
class CFace
|
class CFace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// int PntCount;
|
int PntCount;
|
||||||
int Mat;
|
int Mat;
|
||||||
Vector3 vtx[4];
|
Vector3 vtx[4];
|
||||||
int pts[4];
|
int pts[4];
|
||||||
int idx[4];
|
// int idx[4];
|
||||||
sUV uvs[4];
|
sUV uvs[4];
|
||||||
int vis[4];
|
// int vis[4];
|
||||||
Vector3 Normal;
|
Vector3 Normal;
|
||||||
bool Avail;
|
bool Avail;
|
||||||
// int ID;
|
// int ID;
|
||||||
|
@ -40,8 +41,8 @@ public:
|
||||||
int TPageFlag;
|
int TPageFlag;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
class CFace
|
class CFace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -49,25 +50,20 @@ public:
|
||||||
{
|
{
|
||||||
vtx.resize(3);
|
vtx.resize(3);
|
||||||
pts.resize(3);
|
pts.resize(3);
|
||||||
idx.resize(3);
|
|
||||||
uvs.resize(3);
|
uvs.resize(3);
|
||||||
vis.resize(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int PntCount;
|
|
||||||
int Mat;
|
int Mat;
|
||||||
vector<Vector3> vtx;
|
vector<Vector3> vtx;
|
||||||
vector<int> pts;
|
vector<int> pts;
|
||||||
vector<int> idx;
|
|
||||||
vector<sUV> uvs;
|
vector<sUV> uvs;
|
||||||
vector<int> vis;
|
|
||||||
Vector3 Normal;
|
Vector3 Normal;
|
||||||
bool Avail;
|
bool Avail;
|
||||||
int ID;
|
|
||||||
GString TexName;
|
GString TexName;
|
||||||
|
int TPageFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
*/
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
#ifndef sTriFace
|
#ifndef sTriFace
|
||||||
struct sTriFace
|
struct sTriFace
|
||||||
|
@ -85,8 +81,8 @@ class CFaceStore
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFaceStore() {MaxStrip = 3;TexGrab=&FaceStoreTexGrab;}
|
CFaceStore() {MaxStrip = 3;TexGrab=0;}
|
||||||
CFaceStore(int Max) {MaxStrip=Max;TexGrab=&FaceStoreTexGrab;}
|
CFaceStore(int Max) {MaxStrip=Max;TexGrab=0;}
|
||||||
~CFaceStore(){};
|
~CFaceStore(){};
|
||||||
|
|
||||||
void SetTPageFlag(CFace &F,int MatFlag);
|
void SetTPageFlag(CFace &F,int MatFlag);
|
||||||
|
@ -100,25 +96,7 @@ public:
|
||||||
void SetTexGrab(CTexGrab &NewGrab) {TexGrab=&NewGrab;}
|
void SetTexGrab(CTexGrab &NewGrab) {TexGrab=&NewGrab;}
|
||||||
int AddTex(GString const &TexName);
|
int AddTex(GString const &TexName);
|
||||||
|
|
||||||
void SetTexOut(GString &Name,int TPBase,int TPW,int TPH) {TexGrab->SetOutFile(Name); TexGrab->SetTPage(TPBase,TPW,TPH);}
|
void Process(vector<sTri> &OutTriList,vector<sQuad> &OutQuadList,vector<sVtx> &OutVtxList);
|
||||||
void SetTexInclude(GString &Name) {TexGrab->SetIncFile(Name);}
|
|
||||||
void SetTexDebug(bool f) {TexGrab->SetDebug(f);}
|
|
||||||
void SetTexDebugOut(GString &Name) {TexGrab->SetDebugOut(Name);}
|
|
||||||
void SetTexShrinkToFit(bool f) {TexGrab->ShrinkToFit(f);}
|
|
||||||
void SetTexNoSort() {TexGrab->NoSort();}
|
|
||||||
void SetTexAnimatedHeadersOnly(bool f) {TexGrab->AnimatedHeadersOnly(f);}
|
|
||||||
void SetTexDontOutputBoxes(bool f) {TexGrab->DontOutputBoxes(f);}
|
|
||||||
void SetTexAllowRotate(bool f) {TexGrab->AllowRotate(f);}
|
|
||||||
|
|
||||||
CTexGrab &GetTexGrab() {return(FaceStoreTexGrab);}
|
|
||||||
vector<sTexOutInfo> &GetTexInfo() {return(TexGrab->GetTexInfo());}
|
|
||||||
|
|
||||||
void ProcessTextures();
|
|
||||||
void Process();
|
|
||||||
|
|
||||||
int WriteTriList(FILE *File) {return(WriteTriList(File,OutTriList));}
|
|
||||||
int WriteQuadList(FILE *File) {return(WriteQuadList(File,OutQuadList));}
|
|
||||||
int WriteVtxList(FILE *File) {return(WriteVtxList(File,OutVtxList));}
|
|
||||||
|
|
||||||
int WriteTriList(FILE *File,vector<sTri> &List);
|
int WriteTriList(FILE *File,vector<sTri> &List);
|
||||||
int WriteQuadList(FILE *File,vector<sQuad> &List);
|
int WriteQuadList(FILE *File,vector<sQuad> &List);
|
||||||
|
@ -133,49 +111,43 @@ public:
|
||||||
|
|
||||||
vector<CFace> const &GetQuadFaceList() {return(QuadFaceList);}
|
vector<CFace> const &GetQuadFaceList() {return(QuadFaceList);}
|
||||||
int GetQuadFaceCount() {return(QuadFaceList.size());}
|
int GetQuadFaceCount() {return(QuadFaceList.size());}
|
||||||
|
static int AddVtx(vector<sVtx> &OutVtxList,Vector3 &Vtx);
|
||||||
vector<sVtx> const &GetVtxList() {return(OutVtxList);}
|
static int AddVtx(vector<sVtx> &OutVtxList,sVtx &ThisVtx);
|
||||||
int GetVtxCount() {return(OutVtxList.size());}
|
void ParseVtx4BBox(sVtx &Vtx);
|
||||||
int AddVtx(Vector3 &Vtx);
|
|
||||||
|
|
||||||
void setMaxStripLength(int v) {MaxStrip = v;}
|
void setMaxStripLength(int v) {MaxStrip = v;}
|
||||||
|
|
||||||
CFace& operator []( int nIndex ) {return(FaceList[nIndex]);}
|
CFace& operator []( int nIndex ) {return(FaceList[nIndex]);}
|
||||||
|
|
||||||
vector<sTri> GetOutTriList() {return(OutTriList);}
|
sBBox &GetBBox() {return(BBox);}
|
||||||
vector<sQuad> GetOutQuadList() {return(OutQuadList);}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Quad();
|
void Quad();
|
||||||
void SetupUV(CFace const &In, sTri &Out);
|
void SetupUV(CFace const &In, sTri &Out);
|
||||||
void SetupUV(CFace const &In, sQuad &Out);
|
void SetupUV(CFace const &In, sQuad &Out);
|
||||||
|
|
||||||
void BuildOutTriLists();
|
void BuildOutTriList(vector<sTri> &OutTriList,vector<sVtx> &OutVtxList);
|
||||||
void BuildOutQuadList();
|
void BuildOutQuadList(vector<sQuad> &OutQuadList,vector<sVtx> &OutVtxList);
|
||||||
|
|
||||||
// int QuadGetAttached(int FaceNo);
|
int QuadGetAttached(int FaceNo);
|
||||||
// void QuadGetPnts(CFace &F,int *Join0,int *Join1,int *Pnt);
|
void QuadGetPnts(CFace &F,int *Join0,int *Join1,int *Pnt);
|
||||||
// void QuadGetUVs(CFace &F,int *Join0,int *Join1,int *Pnt);
|
void QuadGetUVs(CFace &F,int *Join0,int *Join1,int *Pnt);
|
||||||
// void OrderPnts( CFace &F ,int unc);
|
void OrderPnts( CFace &F ,int unc);
|
||||||
|
|
||||||
// bool CanConnect( int f0, int f1 );
|
bool CanConnect( int f0, int f1 );
|
||||||
// int CountFacesAttached ( int f );
|
int CountFacesAttached ( int f );
|
||||||
// void FollowFace( int id, CFace &F );
|
void FollowFace( int id, CFace &F );
|
||||||
// int GetUnconnectedPoint( int f0, int f1, int &f0p0, int &f0p1 );
|
int GetUnconnectedPoint( int f0, int f1, int &f0p0, int &f0p1 );
|
||||||
// bool GetFace( CFace & F );
|
bool GetFace( CFace & F );
|
||||||
|
|
||||||
int MaxStrip;
|
int MaxStrip;
|
||||||
|
|
||||||
vector<CFace> FaceList;
|
vector<CFace> FaceList;
|
||||||
// vector<sFaceTexList> TexList;
|
CTexGrab *TexGrab;
|
||||||
CTexGrab FaceStoreTexGrab,*TexGrab;
|
|
||||||
|
|
||||||
vector<CFace> TriFaceList;
|
vector<CFace> TriFaceList;
|
||||||
vector<CFace> QuadFaceList;
|
vector<CFace> QuadFaceList;
|
||||||
|
vector<sVtx> VtxList;
|
||||||
vector<sTri> OutTriList;
|
sBBox BBox;
|
||||||
vector<sQuad> OutQuadList;
|
|
||||||
vector<sVtx> OutVtxList;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ CMkLevel Level;
|
||||||
int TPBase=-1,TPW=-1,TPH=-1;
|
int TPBase=-1,TPW=-1,TPH=-1;
|
||||||
GString IncDir;
|
GString IncDir;
|
||||||
int PakW=0,PakH=0;
|
int PakW=0,PakH=0;
|
||||||
|
bool LocalGeom=false;
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
char * CycleCommands(char *String,int Num)
|
char * CycleCommands(char *String,int Num)
|
||||||
|
@ -52,10 +53,10 @@ int Count;
|
||||||
TextPtr+=strlen(TextPtr)+1;
|
TextPtr+=strlen(TextPtr)+1;
|
||||||
TPH=atol(TextPtr);
|
TPH=atol(TextPtr);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
// case 'm':
|
||||||
TpStr= CheckFileString(String);
|
// TpStr= CheckFileString(String);
|
||||||
Level.AddModel(TpStr);
|
// Level.AddModel(TpStr);
|
||||||
break;
|
// break;
|
||||||
case 'i':
|
case 'i':
|
||||||
IncDir= CheckFileString(String);
|
IncDir= CheckFileString(String);
|
||||||
IncDir.Upper();
|
IncDir.Upper();
|
||||||
|
@ -64,6 +65,9 @@ int Count;
|
||||||
case 'q':
|
case 'q':
|
||||||
StripLength=4;
|
StripLength=4;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
LocalGeom=true;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
TpStr= CheckFileString(String);
|
TpStr= CheckFileString(String);
|
||||||
TextPtr=Text;
|
TextPtr=Text;
|
||||||
|
@ -100,9 +104,10 @@ void Usage(char *ErrStr)
|
||||||
printf(" -o:[FILE] Set output File (AND Dir)\n");
|
printf(" -o:[FILE] Set output File (AND Dir)\n");
|
||||||
printf(" -s:nn Set Scaling value\n");
|
printf(" -s:nn Set Scaling value\n");
|
||||||
printf(" -t:p,w,h Set TPage No,Width,Height\n");
|
printf(" -t:p,w,h Set TPage No,Width,Height\n");
|
||||||
printf(" -m: Add Model\n");
|
// printf(" -m: Add Model\n");
|
||||||
printf(" -d: Enable Debug output\n");
|
printf(" -d: Enable Debug output\n");
|
||||||
printf(" -q: Enable Quadding\n");
|
printf(" -q: Enable Quadding\n");
|
||||||
|
printf(" -l: Enable Local Geom\n");
|
||||||
GObject::Error(ERR_FATAL,ErrStr);
|
GObject::Error(ERR_FATAL,ErrStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +123,7 @@ std::vector<GString> const &Files = MyFiles.GetFileInfoVector();
|
||||||
if (Files.size()>1) Usage("Too many Levels specified\n");
|
if (Files.size()>1) Usage("Too many Levels specified\n");
|
||||||
|
|
||||||
Level.SetAppDir(argv[0]);
|
Level.SetAppDir(argv[0]);
|
||||||
Level.Init(Files[0],OutStr,IncDir,TPBase,TPW,TPH,PakW,PakH);
|
Level.Init(Files[0],OutStr,IncDir,TPBase,TPW,TPH,PakW,PakH,LocalGeom);
|
||||||
Level.Load();
|
Level.Load();
|
||||||
Level.Process();
|
Level.Process();
|
||||||
Level.Write();
|
Level.Write();
|
||||||
|
|
|
@ -58,6 +58,21 @@ sExpLayerTile BlankTile={0,0};
|
||||||
//sExpLayerTile BlankTile2d={-1,-1};
|
//sExpLayerTile BlankTile2d={-1,-1};
|
||||||
//sExpLayerTile BlankTile3d={0,0};
|
//sExpLayerTile BlankTile3d={0,0};
|
||||||
|
|
||||||
|
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(+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),
|
||||||
|
};
|
||||||
|
#define DefVtxTableSize sizeof(DefVtxTable)/sizeof(Vector3)
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
CMkLevel::CMkLevel()
|
CMkLevel::CMkLevel()
|
||||||
{
|
{
|
||||||
|
@ -66,6 +81,7 @@ CMkLevel::CMkLevel()
|
||||||
AddTile2d(BlankTile);
|
AddTile2d(BlankTile);
|
||||||
AddTile3d(BlankTile);
|
AddTile3d(BlankTile);
|
||||||
OutElem3d.resize(1);
|
OutElem3d.resize(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -88,7 +104,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)
|
void CMkLevel::Init(const char *Filename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH,int _PakW,int _PakH,bool _LocalGeom)
|
||||||
{
|
{
|
||||||
// Setup filenames and paths
|
// Setup filenames and paths
|
||||||
GFName Path;
|
GFName Path;
|
||||||
|
@ -142,130 +158,55 @@ GFName Path;
|
||||||
FlatFace[1].uv[1][0]=1; FlatFace[1].uv[1][1]=1;
|
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].uv[2][0]=0; FlatFace[1].uv[2][1]=1;
|
||||||
FlatFace[1].Flags=0;
|
FlatFace[1].Flags=0;
|
||||||
// Setup Pak Info
|
|
||||||
|
// Setup Extra Info
|
||||||
PakW=_PakW;
|
PakW=_PakW;
|
||||||
PakH=_PakH;
|
PakH=_PakH;
|
||||||
}
|
LocalGeom=_LocalGeom;
|
||||||
|
AddDefVtx(OutVtxList);
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
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);
|
|
||||||
*/
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::BuildModel(CScene &Scene,GString &RootPath,int Node)
|
void CMkLevel::AddDefVtx(vector<sVtx> &VtxList)
|
||||||
{
|
{
|
||||||
CNode &ThisNode=Scene.GetNode(Node);
|
CFaceStore F;
|
||||||
vector<sGinTri> const &NodeTriList = ThisNode.GetTris();
|
for (int i=0; i<DefVtxTableSize; i++)
|
||||||
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();
|
|
||||||
vector<Material> const &SceneMaterials=Scene.GetMaterials();
|
|
||||||
|
|
||||||
int TriCount=NodeTriList.size();
|
|
||||||
|
|
||||||
for (int T=0; T<TriCount; T++)
|
|
||||||
{
|
{
|
||||||
int Mat=SceneUsedMatList[NodeMatList[T]];
|
F.AddVtx(VtxList,DefVtxTable[i]);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChildCount=ThisNode.GetPruneChildCount();
|
|
||||||
for (int Loop=0;Loop<ChildCount ; Loop++) BuildModel(Scene,RootPath,ThisNode.PruneChildList[Loop]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
int CMkLevel::AddModel(const char *Name,int TriStart,int TriCount)
|
int CMkLevel::AddModel(const char *Name,int TriStart,int TriCount)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
sMkLevelModel ThisModel;
|
sMkLevelModel ThisModel;
|
||||||
int Idx;
|
int ModelID;
|
||||||
|
|
||||||
ThisModel.Name=Name;
|
ThisModel.Name=Name;
|
||||||
Idx=ModelList.Find(ThisModel);
|
ThisModel.TriStart=TriStart;
|
||||||
if (Idx!=-1)
|
|
||||||
{
|
|
||||||
return(Idx);
|
|
||||||
}
|
|
||||||
Idx=ModelList.size();
|
|
||||||
ThisModel.TriStart=ModelFaceList.GetFaceCount();
|
|
||||||
ThisModel.TriCount=TriCount;
|
ThisModel.TriCount=TriCount;
|
||||||
|
|
||||||
|
ModelID=ModelList.Add(ThisModel);
|
||||||
|
return(ModelID);
|
||||||
|
}
|
||||||
|
|
||||||
// Add tri data
|
//***************************************************************************
|
||||||
for (int i=0;i<TriCount; i++)
|
void CMkLevel::PreProcessModels()
|
||||||
|
{
|
||||||
|
int i,ListSize=ModelList.size();
|
||||||
|
|
||||||
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sExpTri &ThisTri=InTriList[TriStart+i];
|
sMkLevelModel &ThisModel=ModelList[i];
|
||||||
CFace F;
|
ThisModel.ElemID=Create3dElem(ThisModel.TriCount,ThisModel.TriStart,false); // always all models as global for the moment
|
||||||
|
|
||||||
ExpTri2Face(ThisTri,F);
|
|
||||||
ModelFaceList.SetTPageFlag(F,ThisTri.Flags);
|
|
||||||
ModelFaceList.AddFace(F,false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelList.Add(ThisModel);
|
|
||||||
return(Idx);
|
|
||||||
*/
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::ProcessModels()
|
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;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -307,11 +248,7 @@ GString FilePath;
|
||||||
{
|
{
|
||||||
GString InName=InPath;
|
GString InName=InPath;
|
||||||
InName+=TexPtr;
|
InName+=TexPtr;
|
||||||
// sprintf(FullName,"%s",InName);
|
|
||||||
_fullpath( FullName, InName, 1024);
|
_fullpath( FullName, InName, 1024);
|
||||||
// GFName::makeabsolute(InPath,InName,FullName);
|
|
||||||
// InName=FullName;
|
|
||||||
// _fullpath( FullName, FullName, 1024);
|
|
||||||
List.push_back(GString(FullName));
|
List.push_back(GString(FullName));
|
||||||
TexPtr+=strlen(TexPtr)+1;
|
TexPtr+=strlen(TexPtr)+1;
|
||||||
}
|
}
|
||||||
|
@ -433,12 +370,20 @@ void CMkLevel::Process()
|
||||||
{
|
{
|
||||||
printf("PreProcess Layers\n");
|
printf("PreProcess Layers\n");
|
||||||
PreProcessLayers();
|
PreProcessLayers();
|
||||||
printf("Process Models\n");
|
printf("PreProcess ElemBanks\n");
|
||||||
ProcessModels();
|
PreProcessElemBank2d();
|
||||||
|
PreProcessElemBank3d();
|
||||||
|
printf("PreProcess Models\n");
|
||||||
|
PreProcessModels();
|
||||||
|
printf("Process Textures\n");
|
||||||
|
TexGrab.Process();
|
||||||
printf("Process ElemBanks\n");
|
printf("Process ElemBanks\n");
|
||||||
ProcessElemBanks();
|
ProcessElemBank2d();
|
||||||
|
ProcessElemBank3d();
|
||||||
printf("Process Layers\n");
|
printf("Process Layers\n");
|
||||||
ProcessLayers();
|
ProcessLayers();
|
||||||
|
printf("Process Models\n");
|
||||||
|
ProcessModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -486,22 +431,11 @@ int TileIdx=(TileID<<2) | (InTile.Flags & PC_TILE_FLAG_MIRROR_XY);
|
||||||
return(TileIdx);
|
return(TileIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
void CMkLevel::ProcessElemBanks()
|
|
||||||
{
|
|
||||||
PreProcessElemBank2d();
|
|
||||||
PreProcessElemBank3d();
|
|
||||||
TexGrab.Process();
|
|
||||||
ProcessElemBank2d();
|
|
||||||
ProcessElemBank3d();
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkLevel::PreProcessElemBank2d()
|
void CMkLevel::PreProcessElemBank2d()
|
||||||
{
|
{
|
||||||
int i,ListSize=UsedTile2dList.size();
|
int i,ListSize=UsedTile2dList.size();
|
||||||
|
|
||||||
// UsedTile2dList[0].Tile=-1;
|
|
||||||
// Extract Tex data from list
|
// Extract Tex data from list
|
||||||
for (i=1; i<ListSize; i++)
|
for (i=1; i<ListSize; i++)
|
||||||
{ // Skip blank
|
{ // Skip blank
|
||||||
|
@ -540,35 +474,47 @@ int i,ListSize=UsedTile3dList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
int MaxElemTri=0,MaxElemQuad=0;
|
||||||
void CMkLevel::ProcessElemBank3d()
|
void CMkLevel::ProcessElemBank3d()
|
||||||
{
|
{
|
||||||
int i,ListSize=UsedTile3dList.size();
|
//int i,ListSize=UsedTile3dList.size(); <--- UsedTile3dList is tiles only!!
|
||||||
int MaxElemTri=0,MaxElemQuad=0;
|
int i,ListSize=OutElem3d.size();
|
||||||
|
|
||||||
for (i=0; i<ListSize; i++)
|
for (i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sOutElem3d &ThisElem=OutElem3d[i];
|
ProcessElem3d(OutElem3d[i]);
|
||||||
CFaceStore &ThisList=ThisElem.FaceStore;
|
}
|
||||||
|
printf("Max Elem Tri =%i\tMax Elem Quad =%i\n",MaxElemTri,MaxElemQuad);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkLevel::ProcessElem3d(sOutElem3d &ThisElem)
|
||||||
|
{
|
||||||
|
CFaceStore &ThisList=ThisElem.FaceStore;
|
||||||
|
|
||||||
ThisList.setMaxStripLength(StripLength);
|
ThisList.setMaxStripLength(StripLength);
|
||||||
ThisElem.Elem3d.TriStart=OutTriList.size();
|
ThisElem.Elem3d.TriStart=OutTriList.size();
|
||||||
ThisElem.Elem3d.QuadStart=OutQuadList.size();
|
ThisElem.Elem3d.QuadStart=OutQuadList.size();
|
||||||
|
if (!ThisElem.LocalGeom)
|
||||||
|
{ // Global Geom
|
||||||
ThisList.Process(OutTriList,OutQuadList,OutVtxList);
|
ThisList.Process(OutTriList,OutQuadList,OutVtxList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Local Geom
|
||||||
|
AddDefVtx(ThisElem.LocalVtxList);
|
||||||
|
ThisList.Process(OutTriList,OutQuadList,ThisElem.LocalVtxList);
|
||||||
|
int v,VtxListSize=ThisElem.LocalVtxList.size();
|
||||||
|
for (v=0; v<VtxListSize; v++)
|
||||||
|
{
|
||||||
|
u16 Idx=CFaceStore::AddVtx(OutVtxList,ThisElem.LocalVtxList[v]);
|
||||||
|
ThisElem.LocalVtxIdxList.push_back(Idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ThisElem.Elem3d.TriCount=ThisList.GetTriFaceCount();
|
ThisElem.Elem3d.TriCount=ThisList.GetTriFaceCount();
|
||||||
ThisElem.Elem3d.QuadCount=ThisList.GetQuadFaceCount();
|
ThisElem.Elem3d.QuadCount=ThisList.GetQuadFaceCount();
|
||||||
if (MaxElemTri<ThisElem.Elem3d.TriCount) MaxElemTri=ThisElem.Elem3d.TriCount;
|
if (MaxElemTri<ThisElem.Elem3d.TriCount) MaxElemTri=ThisElem.Elem3d.TriCount;
|
||||||
if (MaxElemQuad<ThisElem.Elem3d.QuadCount) MaxElemQuad=ThisElem.Elem3d.QuadCount;
|
if (MaxElemQuad<ThisElem.Elem3d.QuadCount) MaxElemQuad=ThisElem.Elem3d.QuadCount;
|
||||||
}
|
|
||||||
printf("Max Tile Tri =%i\tMax Tile Quad =%i\n",MaxElemTri,MaxElemQuad);
|
|
||||||
for (i=0; i<ListSize; i++)
|
|
||||||
{
|
|
||||||
sOutElem3d &ThisElem=OutElem3d[i];
|
|
||||||
CFaceStore &ThisList=ThisElem.FaceStore;
|
|
||||||
for (int c=i; c<ListSize; c++)
|
|
||||||
{
|
|
||||||
sOutElem3d &CheckElem=OutElem3d[c];
|
|
||||||
CFaceStore &CheckList=CheckElem.FaceStore;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -637,18 +583,38 @@ int ListSize=LayerList.size();
|
||||||
int CMkLevel::Create3dTile(int Tile,int Flags)
|
int CMkLevel::Create3dTile(int Tile,int Flags)
|
||||||
{
|
{
|
||||||
sExpTile &SrcTile=InTileList[Tile];
|
sExpTile &SrcTile=InTileList[Tile];
|
||||||
CFace F;
|
int ElemID;
|
||||||
int i,ListSize,p;
|
|
||||||
CList<sExpTri> SortList;
|
|
||||||
CList<float> ZPosList;
|
|
||||||
int TileID=OutElem3d.size();
|
|
||||||
|
|
||||||
if (SrcTile.TriCount)
|
if (SrcTile.TriCount)
|
||||||
{
|
{
|
||||||
for (i=0; i<SrcTile.TriCount; i++)
|
ElemID=Create3dElem(SrcTile.TriCount,SrcTile.TriStart,LocalGeom);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ElemID=Create2dElem(Tile,LocalGeom);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(ElemID);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
int CMkLevel::Create3dElem(int TriCount,int TriStart,bool Local)
|
||||||
|
{
|
||||||
|
CFace F;
|
||||||
|
int i,ListSize;
|
||||||
|
CList<sExpTri> SortList;
|
||||||
|
CList<float> ZPosList;
|
||||||
|
int ElemID=OutElem3d.size();
|
||||||
|
OutElem3d.resize(ElemID+1);
|
||||||
|
|
||||||
|
sOutElem3d &ThisElem=OutElem3d[ElemID];
|
||||||
|
CFaceStore &FaceList=ThisElem.FaceStore;
|
||||||
|
FaceList.SetTexGrab(TexGrab);
|
||||||
|
ThisElem.LocalGeom=Local;
|
||||||
|
|
||||||
|
for (i=0; i<TriCount; i++)
|
||||||
{
|
{
|
||||||
int ListPos;
|
int ListPos;
|
||||||
sExpTri &ThisTri=InTriList[SrcTile.TriStart+i];
|
sExpTri &ThisTri=InTriList[TriStart+i];
|
||||||
float ThisZPos;
|
float ThisZPos;
|
||||||
|
|
||||||
ThisZPos=ThisTri.vtx[0].z;
|
ThisZPos=ThisTri.vtx[0].z;
|
||||||
|
@ -663,53 +629,60 @@ int TileID=OutElem3d.size();
|
||||||
SortList.insert(ListPos,ThisTri);
|
SortList.insert(ListPos,ThisTri);
|
||||||
ZPosList.insert(ListPos,ThisZPos);
|
ZPosList.insert(ListPos,ThisZPos);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int TexID=Create2dTile(Tile,0);
|
|
||||||
|
|
||||||
for (i=0; i<2; i++)
|
|
||||||
{
|
|
||||||
FlatFace[i].Flags=0;
|
|
||||||
FlatFace[i].TexID=TexID;
|
|
||||||
SortList.push_back(FlatFace[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add sorted list to main list
|
// Add sorted list to main list
|
||||||
OutElem3d.resize(TileID+1);
|
|
||||||
CFaceStore &FaceList=OutElem3d[TileID].FaceStore;
|
|
||||||
FaceList.SetTexGrab(TexGrab);
|
|
||||||
|
|
||||||
ListSize=SortList.size();
|
for (i=0; i<TriCount; i++)
|
||||||
for (i=0; i<ListSize; i++)
|
|
||||||
{
|
{
|
||||||
sExpTri &ThisTri=SortList[i];
|
sExpTri &ThisTri=SortList[i];
|
||||||
CFace F;
|
CFace F;
|
||||||
bool SwapPnt=false;
|
|
||||||
|
|
||||||
if (SrcTile.TriCount)
|
|
||||||
{
|
|
||||||
F.TexName=InTexNameList[ThisTri.TexID];
|
F.TexName=InTexNameList[ThisTri.TexID];
|
||||||
F.Mat=-1;
|
F.Mat=-1;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
F.Mat=ThisTri.TexID;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (p=0; p<3; p++)
|
for (int p=0; p<3; p++)
|
||||||
{
|
{
|
||||||
F.vtx[p]=ThisTri.vtx[p];
|
F.vtx[p]=ThisTri.vtx[p];
|
||||||
F.vtx[p].y=F.vtx[p].y;
|
|
||||||
F.uvs[p].u=ThisTri.uv[p][0];
|
F.uvs[p].u=ThisTri.uv[p][0];
|
||||||
F.uvs[p].v=ThisTri.uv[p][1];
|
F.uvs[p].v=ThisTri.uv[p][1];
|
||||||
}
|
}
|
||||||
FaceList.SetTPageFlag(F,ThisTri.Flags);
|
FaceList.SetTPageFlag(F,ThisTri.Flags);
|
||||||
FaceList.AddFace(F,true);
|
FaceList.AddFace(F,true);
|
||||||
}
|
}
|
||||||
|
return(ElemID);
|
||||||
|
}
|
||||||
|
|
||||||
return(TileID);
|
//***************************************************************************
|
||||||
|
int CMkLevel::Create2dElem(int Tile,bool Local)
|
||||||
|
{
|
||||||
|
CFace F;
|
||||||
|
int i;
|
||||||
|
int TexID=Create2dTile(Tile,0);
|
||||||
|
int ElemID=OutElem3d.size();
|
||||||
|
OutElem3d.resize(ElemID+1);
|
||||||
|
|
||||||
|
sOutElem3d &ThisElem=OutElem3d[ElemID];
|
||||||
|
CFaceStore &FaceList=ThisElem.FaceStore;
|
||||||
|
FaceList.SetTexGrab(TexGrab);
|
||||||
|
ThisElem.LocalGeom=Local;
|
||||||
|
|
||||||
|
for (i=0; i<2; i++)
|
||||||
|
{
|
||||||
|
sExpTri &ThisTri=FlatFace[i];
|
||||||
|
CFace F;
|
||||||
|
|
||||||
|
F.Mat=TexID;
|
||||||
|
|
||||||
|
for (int p=0; p<3; p++)
|
||||||
|
{
|
||||||
|
F.vtx[p]=ThisTri.vtx[p];
|
||||||
|
F.uvs[p].u=ThisTri.uv[p][0];
|
||||||
|
F.uvs[p].v=ThisTri.uv[p][1];
|
||||||
|
}
|
||||||
|
FaceList.SetTPageFlag(F,0);
|
||||||
|
FaceList.AddFace(F,true);
|
||||||
|
}
|
||||||
|
return(ElemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -976,6 +949,7 @@ int i,ListSize;
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
int ZMin=9999,ZMax=0;
|
int ZMin=9999,ZMax=0;
|
||||||
|
int SnapCount[8]={0,0,0,0,0,0,0,0};
|
||||||
int CMkLevel::WriteTriList()
|
int CMkLevel::WriteTriList()
|
||||||
{
|
{
|
||||||
int ThisPos=ftell(File);
|
int ThisPos=ftell(File);
|
||||||
|
@ -993,6 +967,9 @@ int ZOfs=+4*Scale;
|
||||||
Z[1]=OutVtxList[T.P1].vz+ZOfs;
|
Z[1]=OutVtxList[T.P1].vz+ZOfs;
|
||||||
Z[2]=OutVtxList[T.P2].vz+ZOfs;
|
Z[2]=OutVtxList[T.P2].vz+ZOfs;
|
||||||
|
|
||||||
|
if (T.P0<8) SnapCount[T.P0]++;
|
||||||
|
if (T.P1<8) SnapCount[T.P1]++;
|
||||||
|
if (T.P2<8) SnapCount[T.P2]++;
|
||||||
for (int p=0; p<3; p++)
|
for (int p=0; p<3; p++)
|
||||||
{
|
{
|
||||||
if (ZMin>Z[p]) ZMin=Z[p];
|
if (ZMin>Z[p]) ZMin=Z[p];
|
||||||
|
@ -1012,6 +989,7 @@ int ZOfs=+4*Scale;
|
||||||
fwrite(&T,1,sizeof(sTri),File);
|
fwrite(&T,1,sizeof(sTri),File);
|
||||||
}
|
}
|
||||||
printf("%i Tris\t(%i Bytes)\n",ListSize,ListSize*sizeof(sTri));
|
printf("%i Tris\t(%i Bytes)\n",ListSize,ListSize*sizeof(sTri));
|
||||||
|
// printf("\n"); for (i=0; i<8;i++) printf("Snapped Vtx %i=%i \n",i,SnapCount[i]); printf("\n");
|
||||||
return(ThisPos);
|
return(ThisPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,6 +1012,10 @@ int ZOfs=+4*Scale;
|
||||||
Z[2]=OutVtxList[Q.P2].vz+ZOfs;
|
Z[2]=OutVtxList[Q.P2].vz+ZOfs;
|
||||||
Z[3]=OutVtxList[Q.P3].vz+ZOfs;
|
Z[3]=OutVtxList[Q.P3].vz+ZOfs;
|
||||||
|
|
||||||
|
if (Q.P0<8) SnapCount[Q.P0]++;
|
||||||
|
if (Q.P1<8) SnapCount[Q.P1]++;
|
||||||
|
if (Q.P2<8) SnapCount[Q.P2]++;
|
||||||
|
if (Q.P3<8) SnapCount[Q.P3]++;
|
||||||
for (int p=0; p<4; p++)
|
for (int p=0; p<4; p++)
|
||||||
{
|
{
|
||||||
if (ZMin>Z[p]) ZMin=Z[p];
|
if (ZMin>Z[p]) ZMin=Z[p];
|
||||||
|
@ -1053,10 +1035,13 @@ int ZOfs=+4*Scale;
|
||||||
fwrite(&Q,1,sizeof(sQuad),File);
|
fwrite(&Q,1,sizeof(sQuad),File);
|
||||||
}
|
}
|
||||||
printf("%i Quads\t(%i Bytes)\n",ListSize,ListSize*sizeof(sQuad));
|
printf("%i Quads\t(%i Bytes)\n",ListSize,ListSize*sizeof(sQuad));
|
||||||
|
// printf("\n"); for (i=0; i<8;i++) printf("Snapped Vtx %i=%i \n",i,SnapCount[i]); printf("\n");
|
||||||
return(ThisPos);
|
return(ThisPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
sVtx Min={+100,+100,+100};
|
||||||
|
sVtx Max={-100,-100,-100};
|
||||||
int CMkLevel::WriteVtxList()
|
int CMkLevel::WriteVtxList()
|
||||||
{
|
{
|
||||||
int i,ListSize=OutVtxList.size();
|
int i,ListSize=OutVtxList.size();
|
||||||
|
@ -1070,10 +1055,20 @@ int Pos=ftell(File);
|
||||||
Out.vx=+In.vx;
|
Out.vx=+In.vx;
|
||||||
Out.vy=-In.vy+(Scale/2); // Offset it so the origin is centre centre
|
Out.vy=-In.vy+(Scale/2); // Offset it so the origin is centre centre
|
||||||
Out.vz=+In.vz;
|
Out.vz=+In.vz;
|
||||||
|
Min.vx=__min(Min.vx,Out.vx);
|
||||||
|
Min.vy=__min(Min.vy,Out.vy);
|
||||||
|
Min.vz=__min(Min.vz,Out.vz);
|
||||||
|
Max.vx=__max(Max.vx,Out.vx);
|
||||||
|
Max.vy=__max(Max.vy,Out.vy);
|
||||||
|
Max.vz=__max(Max.vz,Out.vz);
|
||||||
fwrite(&Out,1,sizeof(sVtx),File);
|
fwrite(&Out,1,sizeof(sVtx),File);
|
||||||
|
// if (abs(Out.vz)==400) printf("%i %i %i\n",Out.vx,Out.vy,Out.vz);
|
||||||
}
|
}
|
||||||
printf("%i Vtx\t(%i Bytes)\n",ListSize,ListSize*sizeof(sVtx));
|
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);
|
||||||
|
|
||||||
return(Pos);
|
return(Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,7 +1101,7 @@ int ThingStart=ftell(File);
|
||||||
LevelHdr.TriggerList=WriteThings(LAYER_TYPE_TRIGGER);
|
LevelHdr.TriggerList=WriteThings(LAYER_TYPE_TRIGGER);
|
||||||
LevelHdr.FXList=WriteThings(LAYER_TYPE_FX);
|
LevelHdr.FXList=WriteThings(LAYER_TYPE_FX);
|
||||||
LevelHdr.HazardList=WriteThings(LAYER_TYPE_HAZARD);
|
LevelHdr.HazardList=WriteThings(LAYER_TYPE_HAZARD);
|
||||||
// LevelHdr.ModelList=(sModel*)WriteModelList();
|
LevelHdr.ModelList=(sModel*)WriteModelList();
|
||||||
printf("Things =\t(%i Bytes)\n",ftell(File)-ThingStart);
|
printf("Things =\t(%i Bytes)\n",ftell(File)-ThingStart);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1152,7 +1147,6 @@ char *LayerName=GetLayerName(Type,LAYER_SUBTYPE_NONE);
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
int CMkLevel::WriteModelList()
|
int CMkLevel::WriteModelList()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
int i,ListSize=ModelList.size();
|
int i,ListSize=ModelList.size();
|
||||||
int Ofs=ftell(File);
|
int Ofs=ftell(File);
|
||||||
|
|
||||||
|
@ -1160,50 +1154,18 @@ int Ofs=ftell(File);
|
||||||
{
|
{
|
||||||
sModel Out;
|
sModel Out;
|
||||||
sMkLevelModel &ThisModel=ModelList[i];
|
sMkLevelModel &ThisModel=ModelList[i];
|
||||||
|
sOutElem3d &ThisElem=OutElem3d[ThisModel.ElemID];
|
||||||
|
sBBox &ElemBBox=ThisElem.FaceStore.GetBBox();
|
||||||
|
Out.ElemID=ThisModel.ElemID;
|
||||||
|
Out.BBox=ElemBBox;
|
||||||
|
|
||||||
Out.TriCount=ThisModel.TriCount;
|
printf("Writing Model %s (%i) (%i %i) (BBox %i,%i->%i,%i)\n",ThisModel.Name,Out.ElemID,ThisElem.Elem3d.TriCount,ThisElem.Elem3d.QuadCount,Out.BBox.XMin,Out.BBox.YMin,Out.BBox.XMax,Out.BBox.YMax);
|
||||||
Out.TriStart=ThisModel.TriStart;
|
|
||||||
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);
|
fwrite(&Out,1,sizeof(sModel),File);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(Ofs);
|
return(Ofs);
|
||||||
*/
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
/*
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//*** Inf File **************************************************************
|
//*** Inf File **************************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
|
@ -26,16 +26,6 @@ struct sMkLevelTex
|
||||||
bool operator ==(sMkLevelTex const &v1) {return(Tile==v1.Tile && Flags==v1.Flags);}
|
bool operator ==(sMkLevelTex const &v1) {return(Tile==v1.Tile && Flags==v1.Flags);}
|
||||||
};
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
struct sMkLevelModel
|
|
||||||
{
|
|
||||||
GString Name;
|
|
||||||
int TriStart;
|
|
||||||
int TriCount;
|
|
||||||
|
|
||||||
bool operator ==(sMkLevelModel const &v1) {return(Name==v1.Name);}
|
|
||||||
};
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
struct sInfItem
|
struct sInfItem
|
||||||
{
|
{
|
||||||
|
@ -67,8 +57,21 @@ bool operator ==(sUsedTile3d const &v1) {return(Tile==v1.Tile);}
|
||||||
|
|
||||||
struct sOutElem3d
|
struct sOutElem3d
|
||||||
{
|
{
|
||||||
|
bool LocalGeom;
|
||||||
sElem3d Elem3d;
|
sElem3d Elem3d;
|
||||||
CFaceStore FaceStore;
|
CFaceStore FaceStore;
|
||||||
|
vector<sVtx> LocalVtxList;
|
||||||
|
CList<u16> LocalVtxIdxList;
|
||||||
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
struct sMkLevelModel
|
||||||
|
{
|
||||||
|
GString Name;
|
||||||
|
int TriStart,TriCount;
|
||||||
|
u16 ElemID;
|
||||||
|
|
||||||
|
bool operator ==(sMkLevelModel const &v1) {return(Name==v1.Name);}
|
||||||
};
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -81,10 +84,9 @@ public:
|
||||||
~CMkLevel();
|
~CMkLevel();
|
||||||
|
|
||||||
void SetAppDir(const char *Path);
|
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);
|
void Init(const char *InFilename,const char *OutFilename,const char *IncDir,int TPBase,int TPW,int TPH,int PakW,int PakH,bool LocalGeom);
|
||||||
|
|
||||||
void LoadModels();
|
void LoadModels();
|
||||||
int AddModel(GString &Filename);
|
|
||||||
int AddModel(const char *Name,int TriStart,int TriCount);
|
int AddModel(const char *Name,int TriStart,int TriCount);
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
|
@ -111,6 +113,10 @@ public:
|
||||||
void GetPakWH(int &W,int &H) {W=PakW; H=PakH;}
|
void GetPakWH(int &W,int &H) {W=PakW; H=PakH;}
|
||||||
protected:
|
protected:
|
||||||
void BuildModel(CScene &ThisScene,GString &RootPath,int Node);
|
void BuildModel(CScene &ThisScene,GString &RootPath,int Node);
|
||||||
|
|
||||||
|
int Create3dElem(int TriCount,int TriStart,bool Local);
|
||||||
|
int Create2dElem(int Tile,bool Local);
|
||||||
|
|
||||||
CMkLevelLayer *FindLayer(int Type,int SubType);
|
CMkLevelLayer *FindLayer(int Type,int SubType);
|
||||||
void LoadStrList(CList<GString> &List,char *TexPtr,int Count);
|
void LoadStrList(CList<GString> &List,char *TexPtr,int Count);
|
||||||
|
|
||||||
|
@ -118,15 +124,20 @@ protected:
|
||||||
void LoadLayers(sExpFileHdr *FileHdr);
|
void LoadLayers(sExpFileHdr *FileHdr);
|
||||||
void LoadLayer(sExpLayerHdr *LayerHdr);
|
void LoadLayer(sExpLayerHdr *LayerHdr);
|
||||||
|
|
||||||
|
void AddDefVtx(vector<sVtx> &VtxList);
|
||||||
|
|
||||||
void PreProcessLayers();
|
void PreProcessLayers();
|
||||||
void ProcessElemBanks();
|
void ProcessElemBanks();
|
||||||
void PreProcessElemBank2d();
|
void PreProcessElemBank2d();
|
||||||
void ProcessElemBank2d();
|
void ProcessElemBank2d();
|
||||||
void PreProcessElemBank3d();
|
void PreProcessElemBank3d();
|
||||||
void ProcessElemBank3d();
|
void ProcessElemBank3d();
|
||||||
|
void ProcessElem3d(sOutElem3d &ThisElem);
|
||||||
|
|
||||||
void ProcessLayers();
|
void ProcessLayers();
|
||||||
void SetUpTileUV(sElem2d &Out, sTexOutInfo &Info);
|
void SetUpTileUV(sElem2d &Out, sTexOutInfo &Info);
|
||||||
|
|
||||||
|
void PreProcessModels();
|
||||||
void ProcessModels();
|
void ProcessModels();
|
||||||
|
|
||||||
void WriteLevel();
|
void WriteLevel();
|
||||||
|
@ -138,7 +149,6 @@ protected:
|
||||||
int WriteQuadList();
|
int WriteQuadList();
|
||||||
int WriteVtxList();
|
int WriteVtxList();
|
||||||
void WriteElemBanks();
|
void WriteElemBanks();
|
||||||
void CalcModelBBox(sMkLevelModel &ThisModel,sBBox &BBox);
|
|
||||||
void BuildTiles();
|
void BuildTiles();
|
||||||
|
|
||||||
void WriteIncFile();
|
void WriteIncFile();
|
||||||
|
@ -161,8 +171,6 @@ protected:
|
||||||
CList<GString> InSetNameList;
|
CList<GString> InSetNameList;
|
||||||
CList<GString> InTexNameList;
|
CList<GString> InTexNameList;
|
||||||
|
|
||||||
|
|
||||||
// CFaceStore OutFaceList;
|
|
||||||
CList<sElem2d> OutElem2d;
|
CList<sElem2d> OutElem2d;
|
||||||
CList<sOutElem3d> OutElem3d;
|
CList<sOutElem3d> OutElem3d;
|
||||||
|
|
||||||
|
@ -184,6 +192,7 @@ protected:
|
||||||
CList<sInfItem> InfList;
|
CList<sInfItem> InfList;
|
||||||
|
|
||||||
int PakW,PakH;
|
int PakW,PakH;
|
||||||
|
bool LocalGeom;
|
||||||
|
|
||||||
vector<sTri> OutTriList;
|
vector<sTri> OutTriList;
|
||||||
vector<sQuad> OutQuadList;
|
vector<sQuad> OutQuadList;
|
||||||
|
|
|
@ -25,7 +25,7 @@ void CFXFallingTile::init(DVECTOR const &_Pos)
|
||||||
CFX::init();
|
CFX::init();
|
||||||
sLevelHdr *LevelHdr=CLevel::getLevelHdr();
|
sLevelHdr *LevelHdr=CLevel::getLevelHdr();
|
||||||
|
|
||||||
TileBank3d=LevelHdr->TileBank3d;
|
ElemBank3d=LevelHdr->ElemBank3d;
|
||||||
TriList=LevelHdr->TriList;
|
TriList=LevelHdr->TriList;
|
||||||
QuadList=LevelHdr->QuadList;
|
QuadList=LevelHdr->QuadList;
|
||||||
VtxList=LevelHdr->VtxList;
|
VtxList=LevelHdr->VtxList;
|
||||||
|
@ -77,7 +77,7 @@ VECTOR ThisRenderPos;
|
||||||
gte_SetRotMatrix(&Mtx);
|
gte_SetRotMatrix(&Mtx);
|
||||||
CMX_SetTransMtxXY(&ThisRenderPos);
|
CMX_SetTransMtxXY(&ThisRenderPos);
|
||||||
|
|
||||||
sTile3d *ThisTile=&TileBank3d[Tile];
|
sElem3d *ThisTile=&ElemBank3d[Tile];
|
||||||
int TriCount=ThisTile->TriCount;
|
int TriCount=ThisTile->TriCount;
|
||||||
sTri *TList=&TriList[ThisTile->TriStart];
|
sTri *TList=&TriList[ThisTile->TriStart];
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ protected:
|
||||||
u16 Tile;
|
u16 Tile;
|
||||||
DVECTOR Velocity;
|
DVECTOR Velocity;
|
||||||
|
|
||||||
sTile3d *TileBank3d;
|
sElem3d *ElemBank3d;
|
||||||
sTri *TriList;
|
sTri *TriList;
|
||||||
sQuad *QuadList;
|
sQuad *QuadList;
|
||||||
sVtx *VtxList;
|
sVtx *VtxList;
|
||||||
|
|
|
@ -773,18 +773,19 @@ u8 V=Node->V;
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
sModel *CModelGfx::ModelTable;
|
sModel *CModelGfx::ModelTable;
|
||||||
|
sElem3d *CModelGfx::ModelElemBank;
|
||||||
sTri *CModelGfx::ModelTriList;
|
sTri *CModelGfx::ModelTriList;
|
||||||
sQuad *CModelGfx::ModelQuadList;
|
sQuad *CModelGfx::ModelQuadList;
|
||||||
sVtx *CModelGfx::ModelVtxList;
|
sVtx *CModelGfx::ModelVtxList;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CModelGfx::SetData(sModel *Table,sTri *TList,sQuad *QList,sVtx *VList)
|
void CModelGfx::SetData(sLevelHdr *LevelHdr)
|
||||||
{
|
{
|
||||||
ModelTable=Table;
|
ModelTable=LevelHdr->ModelList;
|
||||||
ModelTriList=TList;
|
ModelElemBank=LevelHdr->ElemBank3d;
|
||||||
ModelQuadList=QList;
|
ModelTriList=LevelHdr->TriList;
|
||||||
ModelVtxList=VList;
|
ModelQuadList=LevelHdr->QuadList;
|
||||||
|
ModelVtxList=LevelHdr->VtxList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -794,19 +795,21 @@ void CModelGfx::SetModel(int Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
static const int MXO=0;
|
||||||
|
static const int MYO=-8;
|
||||||
void CModelGfx::Render(DVECTOR &Pos,SVECTOR *Angle,VECTOR *Scale)
|
void CModelGfx::Render(DVECTOR &Pos,SVECTOR *Angle,VECTOR *Scale)
|
||||||
{
|
{
|
||||||
#define BLOCK_MULT 16
|
#define BLOCK_MULT 16
|
||||||
|
sElem3d *Elem=&ModelElemBank[Model->ElemID];
|
||||||
u8 *PrimPtr=GetPrimPtr();
|
u8 *PrimPtr=GetPrimPtr();
|
||||||
POLY_FT3 *TPrimPtr=(POLY_FT3*)PrimPtr;
|
POLY_FT3 *TPrimPtr=(POLY_FT3*)PrimPtr;
|
||||||
sVtx *P0,*P1,*P2;
|
sVtx *P0,*P1,*P2;
|
||||||
u32 T0,T1,T2;
|
u32 T0,T1,T2;
|
||||||
s32 ClipZ;
|
s32 ClipZ;
|
||||||
sOT *ThisOT;
|
sOT *ThisOT;
|
||||||
DVECTOR MapXY;
|
|
||||||
VECTOR RenderPos;
|
VECTOR RenderPos;
|
||||||
int TriCount=Model->TriCount;
|
int TriCount=Elem->TriCount;
|
||||||
sTri *TList=&ModelTriList[Model->TriStart];
|
sTri *TList=&ModelTriList[Elem->TriStart];
|
||||||
MATRIX Mtx;
|
MATRIX Mtx;
|
||||||
|
|
||||||
// If has scale && angle then need to use PSX scale matrix, otherwise, force values
|
// If has scale && angle then need to use PSX scale matrix, otherwise, force values
|
||||||
|
@ -830,14 +833,8 @@ sTri *TList=&ModelTriList[Model->TriStart];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MapXY.vx=Pos.vx>>4;
|
RenderPos.vx=(INGAME_SCREENOFS_X+MXO)+Pos.vx;
|
||||||
MapXY.vy=Pos.vy>>4;
|
RenderPos.vy=(INGAME_SCREENOFS_Y+MYO)+Pos.vy;
|
||||||
|
|
||||||
int ShiftX=(Pos.vx & 15);
|
|
||||||
int ShiftY=(Pos.vy & 15);
|
|
||||||
|
|
||||||
RenderPos.vx=INGAME_SCREENOFS_X+((MapXY.vx*16)+ShiftX);
|
|
||||||
RenderPos.vy=INGAME_SCREENOFS_Y+((MapXY.vy*16)+ShiftY);
|
|
||||||
|
|
||||||
gte_SetRotMatrix(&Mtx);
|
gte_SetRotMatrix(&Mtx);
|
||||||
CMX_SetTransMtxXY(&RenderPos);
|
CMX_SetTransMtxXY(&RenderPos);
|
||||||
|
@ -857,35 +854,13 @@ int ShiftY=(Pos.vy & 15);
|
||||||
*(u32*)&TPrimPtr->u0=T0; // Set UV0
|
*(u32*)&TPrimPtr->u0=T0; // Set UV0
|
||||||
*(u32*)&TPrimPtr->u1=T1; // Set UV1
|
*(u32*)&TPrimPtr->u1=T1; // Set UV1
|
||||||
*(u16*)&TPrimPtr->u2=T2; // Set UV2
|
*(u16*)&TPrimPtr->u2=T2; // Set UV2
|
||||||
/*
|
|
||||||
if (TList->OTOfs>ActorOT)
|
|
||||||
{
|
|
||||||
ThisOT=OtPtr+(ActorOT+1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ThisOT=OtPtr+(ActorOT-1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
ThisOT=OtPtr+TList->OTOfs;
|
ThisOT=OtPtr+TList->OTOfs;
|
||||||
|
|
||||||
|
|
||||||
TList++;
|
TList++;
|
||||||
addPrim(ThisOT,TPrimPtr);
|
addPrim(ThisOT,TPrimPtr);
|
||||||
gte_stsxy3_ft3(TPrimPtr);
|
gte_stsxy3_ft3(TPrimPtr);
|
||||||
TPrimPtr++;
|
TPrimPtr++;
|
||||||
|
|
||||||
/* Models are not clipped
|
|
||||||
gte_nclip_b();
|
|
||||||
gte_stsxy3_ft3(TPrimPtr);
|
|
||||||
gte_stopz(&ClipZ);
|
|
||||||
if (ClipZ<=0)
|
|
||||||
{
|
|
||||||
addPrim(ThisOT,TPrimPtr);
|
|
||||||
TPrimPtr++;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPrimPtr((u8*)TPrimPtr);
|
SetPrimPtr((u8*)TPrimPtr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ public:
|
||||||
CModelGfx(){};
|
CModelGfx(){};
|
||||||
virtual ~CModelGfx(){};
|
virtual ~CModelGfx(){};
|
||||||
|
|
||||||
static void SetData(sModel *Table,sTri *TList,sQuad *QList,sVtx *VList);
|
static void SetData(sLevelHdr *LevelHdr);
|
||||||
void SetModel(int Type);
|
void SetModel(int Type);
|
||||||
|
|
||||||
void Render(DVECTOR &Pos,SVECTOR *Angle=0,VECTOR *Scale=0);
|
void Render(DVECTOR &Pos,SVECTOR *Angle=0,VECTOR *Scale=0);
|
||||||
|
@ -183,9 +183,11 @@ static void SetData(sModel *Table,sTri *TList,sQuad *QList,sVtx *VList);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static sModel *ModelTable;
|
static sModel *ModelTable;
|
||||||
|
static sElem3d *ModelElemBank;
|
||||||
static sTri *ModelTriList;
|
static sTri *ModelTriList;
|
||||||
static sQuad *ModelQuadList;
|
static sQuad *ModelQuadList;
|
||||||
static sVtx *ModelVtxList;
|
static sVtx *ModelVtxList;
|
||||||
|
|
||||||
sModel *Model;
|
sModel *Model;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ CLayerTile::CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr)
|
||||||
MapHeight=LayerHdr->Height;
|
MapHeight=LayerHdr->Height;
|
||||||
|
|
||||||
// printf("%i %i\n",MapWidth,MapHeight);
|
// printf("%i %i\n",MapWidth,MapHeight);
|
||||||
TileBank2d=LevelHdr->TileBank2d;
|
ElemBank2d=LevelHdr->ElemBank2d;
|
||||||
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ sOT *ThisOT=OtPtr+LayerOT;
|
||||||
MapRow++;
|
MapRow++;
|
||||||
if (ThisTile)
|
if (ThisTile)
|
||||||
{
|
{
|
||||||
sTile2d *Tile=&TileBank2d[ThisTile];
|
sElem2d *Tile=&ElemBank2d[ThisTile];
|
||||||
POLY_FT4 *Ft4=(POLY_FT4*)PrimPtr;
|
POLY_FT4 *Ft4=(POLY_FT4*)PrimPtr;
|
||||||
setPolyFT4(Ft4);
|
setPolyFT4(Ft4);
|
||||||
setShadeTex(Ft4,1);
|
setShadeTex(Ft4,1);
|
||||||
|
@ -151,7 +151,7 @@ sOT *ThisOT=OtPtr+LayerOT;
|
||||||
int ThisTile=*MapRow++;
|
int ThisTile=*MapRow++;
|
||||||
if (ThisTile)
|
if (ThisTile)
|
||||||
{
|
{
|
||||||
/**/ sTile2d *Tile=&TileBank2d[ThisTile];
|
/**/ sElem2d *Tile=&ElemBank2d[ThisTile];
|
||||||
TSPRT_16 *SprPtr=(TSPRT_16*)PrimPtr;
|
TSPRT_16 *SprPtr=(TSPRT_16*)PrimPtr;
|
||||||
setTSprt16(SprPtr);
|
setTSprt16(SprPtr);
|
||||||
setTSetShadeTex(SprPtr,1);
|
setTSetShadeTex(SprPtr,1);
|
||||||
|
|
|
@ -49,7 +49,7 @@ virtual sTileMapElem *getMapPtr(int _x,int _y) {return(&Map[(_x>>4)+((_y>>4)*M
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
sLayerHdr *LayerHdr;
|
sLayerHdr *LayerHdr;
|
||||||
sTile2d *TileBank2d;
|
sElem2d *ElemBank2d;
|
||||||
|
|
||||||
int MapWidth,MapHeight,MapXYShift;
|
int MapWidth,MapHeight,MapXYShift;
|
||||||
int RenderW,RenderH;
|
int RenderW,RenderH;
|
||||||
|
|
|
@ -21,23 +21,22 @@ static FontBank *Font;
|
||||||
|
|
||||||
static const int BLOCK_SIZE =16;
|
static const int BLOCK_SIZE =16;
|
||||||
static const int SCREEN_TILE_ADJ_U =2;
|
static const int SCREEN_TILE_ADJ_U =2;
|
||||||
static const int SCREEN_TILE_ADJ_D =2;
|
static const int SCREEN_TILE_ADJ_D =1;
|
||||||
static const int SCREEN_TILE_ADJ_L =2;
|
static const int SCREEN_TILE_ADJ_L =2;
|
||||||
static const int SCREEN_TILE_ADJ_R =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;
|
static const int SCREEN_TILE3D_WIDTH =(INGAME_SCREENW/BLOCK_SIZE)+SCREEN_TILE_ADJ_L+SCREEN_TILE_ADJ_R;
|
||||||
static const int SCREEN_TILE3D_HEIGHT =(INGAME_SCREENH/BLOCK_SIZE)+SCREEN_TILE_ADJ_U+SCREEN_TILE_ADJ_D;
|
static const int SCREEN_TILE3D_HEIGHT =(INGAME_SCREENH/BLOCK_SIZE)+SCREEN_TILE_ADJ_U+SCREEN_TILE_ADJ_D;
|
||||||
static const int RENDER_X_PIX_OFS =8;
|
|
||||||
static const int RENDER_Y_PIX_OFS =16;
|
|
||||||
|
|
||||||
static const int RENDER_X_OFS =INGAME_SCREENOFS_X-(SCREEN_TILE_ADJ_L*BLOCK_SIZE)+RENDER_X_PIX_OFS;
|
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)+RENDER_Y_PIX_OFS;
|
static const int RENDER_Y_OFS =INGAME_SCREENOFS_Y-(SCREEN_TILE_ADJ_U*BLOCK_SIZE)+INGAME_RENDER_OFS_Y;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CLayerTile3d::CLayerTile3d(sLevelHdr *LevelHdr,sLayerHdr *Hdr) : CLayerTile(LevelHdr,Hdr)
|
CLayerTile3d::CLayerTile3d(sLevelHdr *LevelHdr,sLayerHdr *Hdr) : CLayerTile(LevelHdr,Hdr)
|
||||||
{
|
{
|
||||||
TileBank3d=LevelHdr->TileBank3d;
|
ElemBank3d=LevelHdr->ElemBank3d;
|
||||||
TriList=LevelHdr->TriList;
|
TriList=LevelHdr->TriList;
|
||||||
QuadList=LevelHdr->QuadList;
|
QuadList=LevelHdr->QuadList;
|
||||||
VtxList=LevelHdr->VtxList;
|
VtxList=LevelHdr->VtxList;
|
||||||
|
@ -112,6 +111,29 @@ void CLayerTile3d::think(DVECTOR &MapPos)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
#define CMX_SetRotMatrixXY( r0 ) __asm__ ( \
|
||||||
|
"lw $12, 0( %0 );" \
|
||||||
|
"lw $13, 4( %0 );" \
|
||||||
|
"ctc2 $12, $0;" \
|
||||||
|
"ctc2 $13, $2;" \
|
||||||
|
: \
|
||||||
|
: "r"( r0 ) \
|
||||||
|
: "$12", "$13")
|
||||||
|
|
||||||
|
struct sFlipTable
|
||||||
|
{
|
||||||
|
s16 Mtx[4];
|
||||||
|
s32 ClipCode;
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
void CLayerTile3d::render()
|
void CLayerTile3d::render()
|
||||||
{
|
{
|
||||||
sTileMapElem *MapPtr=GetMapPos();
|
sTileMapElem *MapPtr=GetMapPos();
|
||||||
|
@ -134,14 +156,19 @@ VECTOR BlkPos;
|
||||||
|
|
||||||
for (int X=0; X<RenderW; X++)
|
for (int X=0; X<RenderW; X++)
|
||||||
{
|
{
|
||||||
sTile3d *Tile=&TileBank3d[MapRow->Tile];
|
u16 Tile=MapRow->Tile;
|
||||||
int TriCount=Tile->TriCount;
|
u16 TileIdx=Tile>>2;
|
||||||
sTri *TList=&TriList[Tile->TriStart];
|
u16 Flip=Tile&3;
|
||||||
|
sFlipTable *FTab=&FlipTable[Flip];
|
||||||
|
sElem3d *Elem=&ElemBank3d[TileIdx];
|
||||||
|
int TriCount=Elem->TriCount;
|
||||||
|
sTri *TList=&TriList[Elem->TriStart];
|
||||||
|
|
||||||
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2];
|
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2];
|
||||||
while (TriCount--) // Blank tiles rejected here (as no tri-count)
|
while (TriCount--) // Blank tiles rejected here (as no tri-count)
|
||||||
{
|
{
|
||||||
CMX_SetTransMtxXY(&BlkPos);
|
CMX_SetTransMtxXY(&BlkPos);
|
||||||
|
CMX_SetRotMatrixXY(&FTab->Mtx);
|
||||||
gte_ldv3(P0,P1,P2);
|
gte_ldv3(P0,P1,P2);
|
||||||
setlen(TPrimPtr, GPU_PolyFT3Tag);
|
setlen(TPrimPtr, GPU_PolyFT3Tag);
|
||||||
TPrimPtr->code=TList->PolyCode;
|
TPrimPtr->code=TList->PolyCode;
|
||||||
|
@ -157,11 +184,12 @@ VECTOR BlkPos;
|
||||||
|
|
||||||
ThisOT=OtPtr+TList->OTOfs;
|
ThisOT=OtPtr+TList->OTOfs;
|
||||||
TList++;
|
TList++;
|
||||||
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2];
|
P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2]; // Pre-fetch next Tri
|
||||||
gte_nclip_b();
|
gte_nclip_b();
|
||||||
gte_stsxy3_ft3(TPrimPtr);
|
gte_stsxy3_ft3(TPrimPtr);
|
||||||
gte_stopz(&ClipZ);
|
gte_stopz(&ClipZ);
|
||||||
if (ClipZ<=0)
|
ClipZ^=FTab->ClipCode;
|
||||||
|
if (ClipZ<0)
|
||||||
{
|
{
|
||||||
addPrim(ThisOT,TPrimPtr);
|
addPrim(ThisOT,TPrimPtr);
|
||||||
TPrimPtr++;
|
TPrimPtr++;
|
||||||
|
|
|
@ -13,31 +13,14 @@ class CLayerTile3d : public CLayerTile
|
||||||
public:
|
public:
|
||||||
CLayerTile3d(sLevelHdr *LevelHdr,sLayerHdr *Hdr);
|
CLayerTile3d(sLevelHdr *LevelHdr,sLayerHdr *Hdr);
|
||||||
~CLayerTile3d();
|
~CLayerTile3d();
|
||||||
/*
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
TILE3D_WIDTH =16,
|
|
||||||
TILE3D_HEIGHT =16,
|
|
||||||
BLOCK_MULT =16,
|
|
||||||
SCREEN_TILE_ADJ_UP =1,
|
|
||||||
SCREEN_TILE_ADJ_LEFT =3,
|
|
||||||
SCREEN_TILE3D_WIDTH =40,
|
|
||||||
SCREEN_TILE3D_HEIGHT =18,
|
|
||||||
RENDER_X_PIX_OFS =-8,
|
|
||||||
RENDER_Y_PIX_OFS =0,
|
|
||||||
|
|
||||||
RENDER_X_OFS =-(BLOCK_MULT*15)-(SCREEN_TILE_ADJ_LEFT*BLOCK_MULT)+RENDER_X_PIX_OFS,
|
|
||||||
RENDER_Y_OFS =-(BLOCK_MULT*7)-(SCREEN_TILE_ADJ_UP*BLOCK_MULT)+RENDER_Y_PIX_OFS,
|
|
||||||
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
void init(DVECTOR &MapPos,int Shift);
|
void init(DVECTOR &MapPos,int Shift);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void think(DVECTOR &MapPos);
|
void think(DVECTOR &MapPos);
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
sTile3d *TileBank3d;
|
sElem3d *ElemBank3d;
|
||||||
sTri *TriList;
|
sTri *TriList;
|
||||||
sQuad *QuadList;
|
sQuad *QuadList;
|
||||||
sVtx *VtxList;
|
sVtx *VtxList;
|
||||||
|
|
|
@ -203,14 +203,14 @@ sLvlTab *lvlTab=&LvlTable[LevelNo];
|
||||||
DisplayLoadingScreen(lvlTab);
|
DisplayLoadingScreen(lvlTab);
|
||||||
|
|
||||||
LevelHdr=(sLevelHdr*)CFileIO::loadFile(lvlTab->LevelFilename,"Level");
|
LevelHdr=(sLevelHdr*)CFileIO::loadFile(lvlTab->LevelFilename,"Level");
|
||||||
LevelHdr->TileBank2d=(sTile2d*) MakePtr(LevelHdr,(int)LevelHdr->TileBank2d);
|
LevelHdr->ElemBank2d=(sElem2d*) MakePtr(LevelHdr,(int)LevelHdr->ElemBank2d);
|
||||||
LevelHdr->TileBank3d=(sTile3d*) MakePtr(LevelHdr,(int)LevelHdr->TileBank3d);
|
LevelHdr->ElemBank3d=(sElem3d*) MakePtr(LevelHdr,(int)LevelHdr->ElemBank3d);
|
||||||
LevelHdr->TriList=(sTri*) MakePtr(LevelHdr,(int)LevelHdr->TriList);
|
LevelHdr->TriList=(sTri*) MakePtr(LevelHdr,(int)LevelHdr->TriList);
|
||||||
LevelHdr->QuadList=(sQuad*) MakePtr(LevelHdr,(int)LevelHdr->QuadList);
|
LevelHdr->QuadList=(sQuad*) MakePtr(LevelHdr,(int)LevelHdr->QuadList);
|
||||||
LevelHdr->VtxList=(sVtx*) MakePtr(LevelHdr,(int)LevelHdr->VtxList);
|
LevelHdr->VtxList=(sVtx*) MakePtr(LevelHdr,(int)LevelHdr->VtxList);
|
||||||
LevelHdr->ModelList=(sModel*) MakePtr(LevelHdr,(int)LevelHdr->ModelList);
|
LevelHdr->ModelList=(sModel*) MakePtr(LevelHdr,(int)LevelHdr->ModelList);
|
||||||
|
|
||||||
CModelGfx::SetData(LevelHdr->ModelList,LevelHdr->TriList,LevelHdr->QuadList,LevelHdr->VtxList);
|
CModelGfx::SetData(LevelHdr);//LevelHdr->ModelList,LevelHdr->TriList,LevelHdr->QuadList,LevelHdr->VtxList);
|
||||||
m_levelTPage=TPLoadTex(lvlTab->TexFilename);
|
m_levelTPage=TPLoadTex(lvlTab->TexFilename);
|
||||||
|
|
||||||
s_playerSpawnPos.vx=LevelHdr->PlayerStartX*16;
|
s_playerSpawnPos.vx=LevelHdr->PlayerStartX*16;
|
||||||
|
|
|
@ -8,13 +8,15 @@
|
||||||
#include "system\global.h"
|
#include "system\global.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#define GEOM_SCREEN_H 350
|
#define GEOM_SCREEN_H (350)
|
||||||
|
|
||||||
#define INGAME_SCREENW 512
|
#define INGAME_SCREENW (512)
|
||||||
#define INGAME_SCREENH 256
|
#define INGAME_SCREENH (256)
|
||||||
|
|
||||||
#define INGAME_SCREENOFS_X -(INGAME_SCREENW/2)
|
#define INGAME_RENDER_OFS_X (8)
|
||||||
#define INGAME_SCREENOFS_Y -(INGAME_SCREENH/2)
|
#define INGAME_RENDER_OFS_Y (4)
|
||||||
|
#define INGAME_SCREENOFS_X (-INGAME_SCREENW/2)
|
||||||
|
#define INGAME_SCREENOFS_Y (-INGAME_SCREENH/2)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
typedef void (*VbFuncType)(void);
|
typedef void (*VbFuncType)(void);
|
||||||
|
|
Binary file not shown.
|
@ -132,24 +132,13 @@ struct sQuad
|
||||||
//*** Game Types and Headers ************************************************
|
//*** Game Types and Headers ************************************************
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Tiles
|
// Tiles
|
||||||
//typedef u16 sTileMapElem;
|
|
||||||
|
|
||||||
struct sTileMapElem
|
struct sTileMapElem
|
||||||
{
|
{
|
||||||
u16 Tile;
|
u16 Tile;
|
||||||
// u16 LightIdx;
|
// u16 LightIdx;
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
struct sTile
|
struct sElem2d
|
||||||
{
|
|
||||||
// 2d Tile
|
|
||||||
u8 u0,v0; // 2
|
|
||||||
u16 Clut; // 2
|
|
||||||
u16 TPage; // 2
|
|
||||||
u16 Pad; // :o( need this? // 2
|
|
||||||
}; // 8
|
|
||||||
*/
|
|
||||||
struct sTile2d
|
|
||||||
{
|
{
|
||||||
// 2d Tile
|
// 2d Tile
|
||||||
u8 u0,v0; // 2
|
u8 u0,v0; // 2
|
||||||
|
@ -158,14 +147,17 @@ struct sTile2d
|
||||||
u16 Pad; // :o( need this? // 2
|
u16 Pad; // :o( need this? // 2
|
||||||
}; // 8
|
}; // 8
|
||||||
|
|
||||||
struct sTile3d
|
struct sElem3d
|
||||||
{
|
{
|
||||||
// 3d Tile
|
// 3d Elem (tile/model)
|
||||||
u16 TriStart;
|
u16 TriStart;
|
||||||
u16 TriCount;
|
u16 TriCount;
|
||||||
u16 QuadStart;
|
u16 QuadStart;
|
||||||
u16 QuadCount;
|
u16 QuadCount;
|
||||||
}; // 8
|
u16 VtxStart;
|
||||||
|
u16 VtxCount;
|
||||||
|
}; // 12
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Layers
|
// Layers
|
||||||
struct sLayerHdr
|
struct sLayerHdr
|
||||||
|
@ -209,8 +201,8 @@ struct sLayerShadeHdr
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
struct sModel
|
struct sModel
|
||||||
{
|
{
|
||||||
u16 TriCount;
|
u16 ElemID;
|
||||||
u16 TriStart;
|
u16 Pad;
|
||||||
sBBox BBox;
|
sBBox BBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -232,8 +224,8 @@ struct sLevelHdr
|
||||||
|
|
||||||
u16 PlayerStartX,PlayerStartY;
|
u16 PlayerStartX,PlayerStartY;
|
||||||
|
|
||||||
sTile2d *TileBank2d;
|
sElem2d *ElemBank2d;
|
||||||
sTile3d *TileBank3d;
|
sElem3d *ElemBank3d;
|
||||||
sTri *TriList;
|
sTri *TriList;
|
||||||
sQuad *QuadList;
|
sQuad *QuadList;
|
||||||
sVtx *VtxList;
|
sVtx *VtxList;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue