This commit is contained in:
parent
6c4b207a57
commit
2e31ef0e34
5 changed files with 71 additions and 15 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <gfname.hpp>
|
||||
#include "psxtypes.h"
|
||||
#include "FaceStore.h"
|
||||
#include <io.h>
|
||||
|
||||
#include "..\..\..\tools\data\include\dStructs.h"
|
||||
|
||||
|
@ -100,3 +101,50 @@ int NumOfCommas=0;
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -65,5 +65,7 @@ int round(float f);
|
|||
|
||||
void alignFile( FILE *f, int align );
|
||||
|
||||
char *FindFile(const char *Name);
|
||||
|
||||
//***************************************************************************
|
||||
#endif
|
|
@ -190,21 +190,27 @@ CFace &F = FaceList[ListSize];
|
|||
int CFaceStore::AddTex(GString const &TexName)
|
||||
{
|
||||
int ListSize=TexList.size();
|
||||
GString UpperName=TexBasePath+TexName;
|
||||
UpperName.Upper();
|
||||
GString Filename=TexName;
|
||||
Filename.Upper();
|
||||
|
||||
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);
|
||||
sFaceTexList &New=TexList[ListSize];
|
||||
|
||||
New.Name=UpperName;
|
||||
New.Name=Filename;
|
||||
|
||||
// printf("Add Tex %s\n",TexName);
|
||||
New.TexGrabId=TexGrab->AddFile(UpperName);
|
||||
New.TexGrabId=TexGrab->AddFile(Filename);
|
||||
|
||||
return(New.TexGrabId);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
void SetTexGrab(CTexGrab &NewGrab) {TexGrab=&NewGrab;}
|
||||
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 SetTexInclude(GString &Name) {TexGrab->SetIncFile(Name);}
|
||||
void SetTexDebug(bool f) {TexGrab->SetDebug(f);}
|
||||
|
@ -137,7 +137,6 @@ private:
|
|||
vector<CFace> FaceList;
|
||||
vector<sFaceTexList> TexList;
|
||||
CTexGrab FaceStoreTexGrab,*TexGrab;
|
||||
GString TexBasePath;
|
||||
|
||||
vector<CFace> TriFaceList;
|
||||
vector<CFace> QuadFaceList;
|
||||
|
|
|
@ -38,12 +38,12 @@ int Count;
|
|||
case 'o':
|
||||
OutStr = CheckFileString(String);
|
||||
OutStr.Upper();
|
||||
OutStr.Append('\\');
|
||||
OutStr.Append('/');
|
||||
break;
|
||||
case 'i':
|
||||
IncludeFile = CheckFileString(String);
|
||||
IncludeFile.Upper();
|
||||
IncludeFile.Append('\\');
|
||||
IncludeFile.Append('/');
|
||||
break;
|
||||
case 'd':
|
||||
DebugOn =true;
|
||||
|
@ -167,6 +167,7 @@ GString IncName;
|
|||
TexGrab.AnimatedHeadersOnly(true);
|
||||
TexGrab.DontOutputBoxes(true);
|
||||
TexGrab.AllowRotate(true);
|
||||
TexGrab.FileRecursion(true);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -290,8 +291,8 @@ Matrix4x4 PMtx=ParentNode.Mtx;
|
|||
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());
|
||||
|
||||
ParentBone.FaceList.AddFace( VtxList, NodeTriList[T], NodeUVList[T], SceneTexList[Mat]);
|
||||
GString TexName=InPath+SceneTexList[Mat];
|
||||
ParentBone.FaceList.AddFace( VtxList, NodeTriList[T], NodeUVList[T], TexName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,7 +346,6 @@ int ListSize=Skel.size();
|
|||
void CMkActor3d::ActorProcess()
|
||||
{
|
||||
FaceList.SetTexGrab(TexGrab);
|
||||
FaceList.SetTexBasePath(InPath);
|
||||
|
||||
ProcessSkel(1,-1);
|
||||
BuildSkelOut();
|
||||
|
@ -354,9 +354,10 @@ void CMkActor3d::ActorProcess()
|
|||
int ListSize=InTexList.size();
|
||||
for (int i=0; i<ListSize; i++)
|
||||
{
|
||||
GString Filename;
|
||||
Filename="Textures/";
|
||||
GString Filename=InPath;
|
||||
Filename+="Textures/";
|
||||
Filename+=InTexList[i]+".Bmp";
|
||||
Filename.Upper();
|
||||
FaceList.AddTex(Filename);
|
||||
}
|
||||
}
|
||||
|
@ -446,7 +447,6 @@ int PixPerWord;
|
|||
//***************************************************************************
|
||||
int CMkActor3d::WriteTexInfoList()
|
||||
{
|
||||
CTexGrab &TexGrab=FaceList.GetTexGrab();
|
||||
std::vector<sTexOutInfo> &TexList=TexGrab.GetTexInfo();
|
||||
int ListSize=TexList.size();
|
||||
int Pos=ftell(File);
|
||||
|
@ -456,6 +456,7 @@ int Pos=ftell(File);
|
|||
sTexInfo 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);
|
||||
}
|
||||
// printf("%i Materials\n",ListSize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue