This commit is contained in:
parent
662a7aefe9
commit
1fdd0f1c9c
3 changed files with 333 additions and 0 deletions
183
Utils/MkActor3d/MkActor3d.cpp
Normal file
183
Utils/MkActor3d/MkActor3d.cpp
Normal file
|
@ -0,0 +1,183 @@
|
|||
/**********************************/
|
||||
/*** SpongeBob 3d Actor Creator ***/
|
||||
/**********************************/
|
||||
|
||||
#include "stdio.h"
|
||||
#include <misc.hpp>
|
||||
#include <conio.h>
|
||||
#include <iostream.h>
|
||||
#include <vector>
|
||||
#include <PsxLib.h>
|
||||
#include <FaceStore.h>
|
||||
|
||||
#include "MkActor3d.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//***************************************************************************
|
||||
int TPBase=-1,TPWidth=-1,TPHeight=-1;
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
char * CycleCommands(char *String,int Num)
|
||||
{
|
||||
char Text[256],*TextPtr;
|
||||
int Count;
|
||||
|
||||
if (String[0]=='-' || String[0]=='/')
|
||||
{
|
||||
GString TpStr;
|
||||
switch (String[1])
|
||||
{
|
||||
// Switches
|
||||
case 'o':
|
||||
OutStr = CheckFileString(String);
|
||||
break;
|
||||
case 'd':
|
||||
DebugOn =true;
|
||||
break;
|
||||
case 's':
|
||||
TpStr= CheckFileString(String);
|
||||
Scale=atof(TpStr);
|
||||
break;
|
||||
case 't':
|
||||
TpStr= CheckFileString(String);
|
||||
TextPtr=Text;
|
||||
strcpy(TextPtr,TpStr);
|
||||
Count=ZeroAndCountCommas(TextPtr);
|
||||
if (Count!=2)
|
||||
GObject::Error(ERR_FATAL,"Problem with option %s\n",String);
|
||||
TPBase=atol(TextPtr);
|
||||
TextPtr+=strlen(TextPtr)+1;
|
||||
TPWidth=atol(TextPtr);
|
||||
TextPtr+=strlen(TextPtr)+1;
|
||||
TPHeight=atol(TextPtr);
|
||||
case 'q':
|
||||
StripLength=4;
|
||||
break;
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"Unknown switch %s",String);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GString UpperName(String);
|
||||
UpperName.Upper();
|
||||
MyFiles.AddFile(UpperName);
|
||||
}
|
||||
|
||||
return(String);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
CMkActor3d::CMkActor3d(GString const &In,GString const &Out,int TPBase,int TPW,int TPH)
|
||||
{
|
||||
GFName File=In;
|
||||
InFilename=In;
|
||||
InPath=File.Drive();
|
||||
InPath+=File.Dir();
|
||||
OutDir=Out;
|
||||
|
||||
Name=File.File();
|
||||
// Create Out Filename from inFilename and outdir
|
||||
OutFile=OutDir;
|
||||
OutFile.Append('\\');
|
||||
OutFile+=File.File();
|
||||
|
||||
TPageBase=TPBase;
|
||||
TPageWidth=TPW ;
|
||||
TPageHeight=TPH;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor3d::Load()
|
||||
{
|
||||
Scene.Load(InFilename);
|
||||
// Scene.PrintPruneTree();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor3d::Process()
|
||||
{
|
||||
|
||||
BuildSkin();
|
||||
FaceList.SetTexBasePath(InPath);
|
||||
FaceList.SetTexOut(GString("\\temp\\Test.tex"),1,1,1);
|
||||
FaceList.SetTexDebugOut(GString("\\temp\\Test.Lbm"));
|
||||
|
||||
FaceList.Process();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkActor3d::BuildSkin(int Idx)
|
||||
{
|
||||
CNode &ThisNode=Scene.GetNode(Idx);
|
||||
vector<sGinTri> const &NodeTriList = ThisNode.GetTris();
|
||||
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<Material> const &SceneMatList= Scene.GetMaterials();
|
||||
|
||||
int TriCount=NodeTriList.size();
|
||||
|
||||
for (int T=0; T<TriCount; T++)
|
||||
{
|
||||
int Mat=NodeMatList[T];
|
||||
Mat=SceneMatList[Mat].TexId;
|
||||
if (Mat<0) Mat=0;
|
||||
CFace &ThisFace=FaceList.AddFace( NodeVtxList, NodeTriList[T], NodeUVList[T], SceneTexList[Mat]);
|
||||
}
|
||||
|
||||
int ChildCount=ThisNode.GetPruneChildCount();
|
||||
for (int Loop=0;Loop<ChildCount ;Loop++) BuildSkin(ThisNode.PruneChildList[Loop]);
|
||||
|
||||
}
|
||||
//***************************************************************************
|
||||
void CMkActor3d::Write()
|
||||
{
|
||||
printf("%i Tris\n",FaceList.GetFaceCount());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
//***************************************************************************
|
||||
|
||||
void Usage(char *ErrStr)
|
||||
{
|
||||
printf("\nMkActor3d: by Dave\n");
|
||||
printf("Usage: MkActor3d <file> [ <file>.. ] [ switches.. ]\n");
|
||||
printf("Switches:\n");
|
||||
printf(" -o:[FILE] Set output Dir\n");
|
||||
printf(" -s:nn Set Scaling value\n");
|
||||
printf(" -t:p,w,h Set TPage No,Width,Height\n");
|
||||
printf(" -d: Enable Debug output\n");
|
||||
printf(" -q: Enable Quadding\n");
|
||||
GObject::Error(ERR_FATAL,ErrStr);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
CommandLine(argc,argv,CycleCommands);
|
||||
if (OutStr.Empty()) Usage("No Output File Set\n");
|
||||
|
||||
if (TPBase==-1) Usage("No TPage Set\n");
|
||||
|
||||
vector<GString> const &Files = MyFiles.GetFileInfoVector();
|
||||
|
||||
for (int Loop=0; Loop<Files.size(); Loop++)
|
||||
{
|
||||
CMkActor3d ThisActor(Files[Loop],OutStr,TPBase,TPWidth,TPHeight);
|
||||
|
||||
ThisActor.Load();
|
||||
ThisActor.Process();
|
||||
ThisActor.Write();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
93
Utils/MkActor3d/MkActor3d.dsp
Normal file
93
Utils/MkActor3d/MkActor3d.dsp
Normal file
|
@ -0,0 +1,93 @@
|
|||
# Microsoft Developer Studio Project File - Name="MkActor3d" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=MkActor3d - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MkActor3d.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "MkActor3d.mak" CFG="MkActor3d - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "MkActor3d - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "MkActor3d - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "MkActor3d - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "MkActor3d - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\libs\glib" /I "..\libs\maths" /I "..\libs\davelib" /I "..\libs\ginlib" /I "..\libs\psxlib" /I "..\libs\texgrab" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glib.lib ginlib.lib psxlib.lib davelib.lib texgrab.lib maths.lib psxlib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\libs\psxlib\debug" /libpath:"..\libs\ginlib\debug" /libpath:"..\libs\glib\debug" /libpath:"..\libs\davelib\debug" /libpath:"..\libs\texgrab\debug" /libpath:"..\libs\maths\debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "MkActor3d - Win32 Release"
|
||||
# Name "MkActor3d - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkActor3d.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MkActor3d.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
57
Utils/MkActor3d/MkActor3d.h
Normal file
57
Utils/MkActor3d/MkActor3d.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**********************************/
|
||||
/*** SpongeBob 3d Actor Creator ***/
|
||||
/**********************************/
|
||||
|
||||
|
||||
#include <Vector3.h>
|
||||
//#include "Layer.h"
|
||||
//#include "LayerTile.h"
|
||||
#include <List.h>
|
||||
#include <FaceStore.h>
|
||||
|
||||
#include "..\mapedit\ExportPSXHdr.h"
|
||||
/*
|
||||
struct sTex
|
||||
{
|
||||
int TexId;
|
||||
int XOfs,YOfs;
|
||||
int Flags;
|
||||
|
||||
bool operator==(sTex const &v1)
|
||||
{
|
||||
if (TexId!=v1.TexId) return(FALSE);
|
||||
if (XOfs!=v1.XOfs) return(FALSE);
|
||||
if (YOfs!=v1.YOfs) return(FALSE);
|
||||
if (Flags!=v1.Flags) return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
//***************************************************************************
|
||||
class CMkActor3d
|
||||
{
|
||||
public:
|
||||
CMkActor3d(GString const &In,GString const &Out,int TPBase,int TPW,int TPH);
|
||||
|
||||
void Load();
|
||||
void Process();
|
||||
void Write();
|
||||
|
||||
private:
|
||||
void BuildSkin(int Idx=0);
|
||||
|
||||
GString InFilename,InPath,Name,OutFile,OutDir;
|
||||
|
||||
CScene Scene;
|
||||
|
||||
CFaceStore FaceList;
|
||||
CList<sTri> OutTriList;
|
||||
CList<sVtx> OutVtxList;
|
||||
|
||||
int TPageBase;
|
||||
int TPageWidth,TPageHeight;
|
||||
|
||||
};
|
||||
|
||||
//***************************************************************************
|
Loading…
Add table
Reference in a new issue