This commit is contained in:
Daveo 2001-03-01 17:03:15 +00:00
parent 6c4b207a57
commit 2e31ef0e34
5 changed files with 71 additions and 15 deletions

View File

@ -14,6 +14,7 @@
#include <gfname.hpp> #include <gfname.hpp>
#include "psxtypes.h" #include "psxtypes.h"
#include "FaceStore.h" #include "FaceStore.h"
#include <io.h>
#include "..\..\..\tools\data\include\dStructs.h" #include "..\..\..\tools\data\include\dStructs.h"
@ -100,3 +101,50 @@ int NumOfCommas=0;
return(NumOfCommas); return(NumOfCommas);
} }
//***************************************************************************
char *FindFile(const char *Name)
{
int Handle;
GFName DirName(Name);
GString Filename,Path;
_finddata_t FindBlock;
int Status;
// Does this file exist
FILE *File=fopen(Name,"rb");
if (File)
{
fclose(File);
return((char*)Name);
}
// Recurse dirs to find file
Filename=DirName.File();
Filename+=".";
Filename+=DirName.Ext();
DirName.File("*");
DirName.Ext("*");
Path=DirName.FullName();
Name=0;
Status=Handle= _findfirst(Path,&FindBlock);
while (Status!=-1 && !Name)
{
if (FindBlock.attrib&_A_SUBDIR)
{
if (strcmp(FindBlock.name,".") && strcmp(FindBlock.name,".."))
{
GString NewName;
NewName=DirName.Drive();
NewName+=DirName.Dir();
NewName+=FindBlock.name;
NewName+="/";
NewName+=Filename;
Name=FindFile(NewName);
}
}
if (!Name) Status=_findnext(Handle,&FindBlock);
}
return((char*)Name);
}

View File

@ -65,5 +65,7 @@ int round(float f);
void alignFile( FILE *f, int align ); void alignFile( FILE *f, int align );
char *FindFile(const char *Name);
//*************************************************************************** //***************************************************************************
#endif #endif

View File

@ -190,21 +190,27 @@ CFace &F = FaceList[ListSize];
int CFaceStore::AddTex(GString const &TexName) int CFaceStore::AddTex(GString const &TexName)
{ {
int ListSize=TexList.size(); int ListSize=TexList.size();
GString UpperName=TexBasePath+TexName; GString Filename=TexName;
UpperName.Upper(); Filename.Upper();
for (int i=0; i<ListSize; i++) for (int i=0; i<ListSize; i++)
{ {
if (TexList[i].Name==UpperName) return(TexList[i].TexGrabId); if (TexList[i].Name==Filename) return(TexList[i].TexGrabId);
} }
// Does file exist
if (!FindFile(TexName))
GObject::Error(ERR_FATAL,"Texture not found %s!!\n",TexName);
TexList.resize(ListSize+1); TexList.resize(ListSize+1);
sFaceTexList &New=TexList[ListSize]; sFaceTexList &New=TexList[ListSize];
New.Name=UpperName; New.Name=Filename;
// printf("Add Tex %s\n",TexName); // printf("Add Tex %s\n",TexName);
New.TexGrabId=TexGrab->AddFile(UpperName); New.TexGrabId=TexGrab->AddFile(Filename);
return(New.TexGrabId); return(New.TexGrabId);
} }

View File

@ -75,7 +75,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 SetTexBasePath(GString &Path) {TexBasePath=Path;}
void SetTexOut(GString &Name,int TPBase,int TPW,int TPH) {TexGrab->SetOutFile(Name); TexGrab->SetTPage(TPBase,TPW,TPH);} void SetTexOut(GString &Name,int TPBase,int TPW,int TPH) {TexGrab->SetOutFile(Name); TexGrab->SetTPage(TPBase,TPW,TPH);}
void SetTexInclude(GString &Name) {TexGrab->SetIncFile(Name);} void SetTexInclude(GString &Name) {TexGrab->SetIncFile(Name);}
void SetTexDebug(bool f) {TexGrab->SetDebug(f);} void SetTexDebug(bool f) {TexGrab->SetDebug(f);}
@ -137,7 +137,6 @@ private:
vector<CFace> FaceList; vector<CFace> FaceList;
vector<sFaceTexList> TexList; vector<sFaceTexList> TexList;
CTexGrab FaceStoreTexGrab,*TexGrab; CTexGrab FaceStoreTexGrab,*TexGrab;
GString TexBasePath;
vector<CFace> TriFaceList; vector<CFace> TriFaceList;
vector<CFace> QuadFaceList; vector<CFace> QuadFaceList;

View File

@ -38,12 +38,12 @@ int Count;
case 'o': case 'o':
OutStr = CheckFileString(String); OutStr = CheckFileString(String);
OutStr.Upper(); OutStr.Upper();
OutStr.Append('\\'); OutStr.Append('/');
break; break;
case 'i': case 'i':
IncludeFile = CheckFileString(String); IncludeFile = CheckFileString(String);
IncludeFile.Upper(); IncludeFile.Upper();
IncludeFile.Append('\\'); IncludeFile.Append('/');
break; break;
case 'd': case 'd':
DebugOn =true; DebugOn =true;
@ -167,6 +167,7 @@ GString IncName;
TexGrab.AnimatedHeadersOnly(true); TexGrab.AnimatedHeadersOnly(true);
TexGrab.DontOutputBoxes(true); TexGrab.DontOutputBoxes(true);
TexGrab.AllowRotate(true); TexGrab.AllowRotate(true);
TexGrab.FileRecursion(true);
} }
//*************************************************************************** //***************************************************************************
@ -290,8 +291,8 @@ Matrix4x4 PMtx=ParentNode.Mtx;
int Mat=SceneUsedMatList[NodeMatList[T]]; int Mat=SceneUsedMatList[NodeMatList[T]];
if (Mat>SceneTexList.size()) GObject::Error(ERR_FATAL,"Crap Material ID, wanted %i, only have %i\n",Mat,SceneTexList.size()); if (Mat>SceneTexList.size()) GObject::Error(ERR_FATAL,"Crap Material ID, wanted %i, only have %i\n",Mat,SceneTexList.size());
GString TexName=InPath+SceneTexList[Mat];
ParentBone.FaceList.AddFace( VtxList, NodeTriList[T], NodeUVList[T], SceneTexList[Mat]); ParentBone.FaceList.AddFace( VtxList, NodeTriList[T], NodeUVList[T], TexName);
} }
} }
@ -345,7 +346,6 @@ int ListSize=Skel.size();
void CMkActor3d::ActorProcess() void CMkActor3d::ActorProcess()
{ {
FaceList.SetTexGrab(TexGrab); FaceList.SetTexGrab(TexGrab);
FaceList.SetTexBasePath(InPath);
ProcessSkel(1,-1); ProcessSkel(1,-1);
BuildSkelOut(); BuildSkelOut();
@ -354,9 +354,10 @@ void CMkActor3d::ActorProcess()
int ListSize=InTexList.size(); int ListSize=InTexList.size();
for (int i=0; i<ListSize; i++) for (int i=0; i<ListSize; i++)
{ {
GString Filename; GString Filename=InPath;
Filename="Textures/"; Filename+="Textures/";
Filename+=InTexList[i]+".Bmp"; Filename+=InTexList[i]+".Bmp";
Filename.Upper();
FaceList.AddTex(Filename); FaceList.AddTex(Filename);
} }
} }
@ -446,7 +447,6 @@ int PixPerWord;
//*************************************************************************** //***************************************************************************
int CMkActor3d::WriteTexInfoList() int CMkActor3d::WriteTexInfoList()
{ {
CTexGrab &TexGrab=FaceList.GetTexGrab();
std::vector<sTexOutInfo> &TexList=TexGrab.GetTexInfo(); std::vector<sTexOutInfo> &TexList=TexGrab.GetTexInfo();
int ListSize=TexList.size(); int ListSize=TexList.size();
int Pos=ftell(File); int Pos=ftell(File);
@ -456,6 +456,7 @@ int Pos=ftell(File);
sTexInfo OutTex; sTexInfo OutTex;
CalcTPXY(TexList[i],OutTex); CalcTPXY(TexList[i],OutTex);
// printf("%i %i %i %i\n",OutTex.x,OutTex.y,OutTex.w,OutTex.h);
fwrite(&OutTex, sizeof(sTexInfo), 1, File); fwrite(&OutTex, sizeof(sTexInfo), 1, File);
} }
// printf("%i Materials\n",ListSize); // printf("%i Materials\n",ListSize);