This commit is contained in:
parent
9638e0c561
commit
abc8365365
7 changed files with 406 additions and 102 deletions
|
@ -370,7 +370,7 @@ void VRAMImage::SaveAs16ColLbm(const char * Name)
|
||||||
ThisFr.SetFrame(lbmData,W,H,GazPalette);
|
ThisFr.SetFrame(lbmData,W,H,GazPalette);
|
||||||
ThisFr.SaveLbm(Name);
|
ThisFr.SaveLbm(Name);
|
||||||
|
|
||||||
cout<<"Written "<<Name<<endl;
|
// cout<<"Written "<<Name<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
|
|
@ -516,7 +516,7 @@ int FrameCount=AllSprFrames.size();
|
||||||
thisPos=Out.tellp();
|
thisPos=Out.tellp();
|
||||||
if (m_AnimatedHeadersOnly)
|
if (m_AnimatedHeadersOnly)
|
||||||
{
|
{
|
||||||
printf("Writing only animated headers (%i).\n",FrameCount);
|
// printf("Writing only animated headers (%i).\n",FrameCount);
|
||||||
for (f=0;f<AllSprFrames.size();f++) // Write Animated headers only
|
for (f=0;f<AllSprFrames.size();f++) // Write Animated headers only
|
||||||
{
|
{
|
||||||
if (AllSprFrames[f].IsAnimated()) AllSprFrames[f].WriteHeader(Out);
|
if (AllSprFrames[f].IsAnimated()) AllSprFrames[f].WriteHeader(Out);
|
||||||
|
@ -539,7 +539,7 @@ int FrameCount=AllSprFrames.size();
|
||||||
|
|
||||||
if (m_DontOutputBoxes)
|
if (m_DontOutputBoxes)
|
||||||
{
|
{
|
||||||
printf("Skipping spare boxes.\n");
|
// printf("Skipping spare boxes.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -555,7 +555,7 @@ int FrameCount=AllSprFrames.size();
|
||||||
|
|
||||||
if (m_AlignHeaders)
|
if (m_AlignHeaders)
|
||||||
{
|
{
|
||||||
printf("Aligning headers to 2k chunk.\n");
|
// printf("Aligning headers to 2k chunk.\n");
|
||||||
Out.Align(2048);
|
Out.Align(2048);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,16 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//graphics/Characters/SpongeBob/SpongeBob.Gin -o:out/USA/data/Actors -t:24,1,1 -s:256
|
|
||||||
// -a:SBEyesAngry.bmp,SBEyesBlink.bmp,SBEyesDown.bmp,SBEyesfiece.bmp,SBEyesLeft.bmp,SBEyesSheepish.bmp,SBEyesUp.bmp,SBEyesWorried.bmp,SBEyesRight.bmp, SBmouth01.bmp,SBMouthGasp.bmp,SBMouthSheepishSBMouthSmile.bmp,SBMouthTerror.bmp,SBMouthWhistle
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
int TPBase=-1,TPWidth=-1,TPHeight=-1;
|
CMkActor3d ThisActor;
|
||||||
std::vector<GString> ExtraTex;
|
//std::vector<GString> ExtraTex;
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
char * CycleCommands(char *String,int Num)
|
char * CycleCommands(char *String,int Num)
|
||||||
{
|
{
|
||||||
char Text[256],*TextPtr;
|
int TPBase=-1,TPWidth=-1,TPHeight=-1;
|
||||||
|
char Text[2048],*TextPtr;
|
||||||
int Count,i;
|
int Count,i;
|
||||||
|
|
||||||
if (String[0]=='-' || String[0]=='/')
|
if (String[0]=='-' || String[0]=='/')
|
||||||
|
@ -51,13 +50,24 @@ int Count,i;
|
||||||
TextPtr=Text;
|
TextPtr=Text;
|
||||||
strcpy(TextPtr,TpStr);
|
strcpy(TextPtr,TpStr);
|
||||||
Count=ZeroAndCountCommas(TextPtr);
|
Count=ZeroAndCountCommas(TextPtr);
|
||||||
if (Count!=2)
|
if (Count!=2) GObject::Error(ERR_FATAL,"Problem with option %s\n",String);
|
||||||
GObject::Error(ERR_FATAL,"Problem with option %s\n",String);
|
|
||||||
TPBase=atol(TextPtr);
|
TPBase=atol(TextPtr);
|
||||||
TextPtr+=strlen(TextPtr)+1;
|
TextPtr+=strlen(TextPtr)+1;
|
||||||
TPWidth=atol(TextPtr);
|
TPWidth=atol(TextPtr);
|
||||||
TextPtr+=strlen(TextPtr)+1;
|
TextPtr+=strlen(TextPtr)+1;
|
||||||
TPHeight=atol(TextPtr);
|
TPHeight=atol(TextPtr);
|
||||||
|
ThisActor.SetTPData(TPBase,TPWidth,TPHeight);
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
TpStr= CheckFileString(String);
|
||||||
|
TextPtr=Text;
|
||||||
|
strcpy(TextPtr,TpStr);
|
||||||
|
Count=ZeroAndCountCommas(TextPtr);
|
||||||
|
for (i=0; i<Count+1; i++)
|
||||||
|
{
|
||||||
|
ThisActor.AddTex(TextPtr);
|
||||||
|
TextPtr+=strlen(TextPtr)+1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
TpStr= CheckFileString(String);
|
TpStr= CheckFileString(String);
|
||||||
|
@ -66,11 +76,10 @@ int Count,i;
|
||||||
Count=ZeroAndCountCommas(TextPtr);
|
Count=ZeroAndCountCommas(TextPtr);
|
||||||
for (i=0; i<Count+1; i++)
|
for (i=0; i<Count+1; i++)
|
||||||
{
|
{
|
||||||
ExtraTex.push_back(TextPtr);
|
ThisActor.AddAnim(TextPtr);
|
||||||
TextPtr+=strlen(TextPtr)+1;
|
TextPtr+=strlen(TextPtr)+1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
StripLength=4;
|
StripLength=4;
|
||||||
break;
|
break;
|
||||||
|
@ -81,41 +90,105 @@ int Count,i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GString UpperName(String);
|
ThisActor.SetInName(String);
|
||||||
UpperName.Upper();
|
|
||||||
MyFiles.AddFile(UpperName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(String);
|
return(String);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
//***************************************************************************
|
|
||||||
//***************************************************************************
|
|
||||||
CMkActor3d::CMkActor3d(GString const &In,GString const &Out,int TPBase,int TPW,int TPH)
|
|
||||||
{
|
|
||||||
GFName File=In;
|
|
||||||
|
|
||||||
InFilename=In;
|
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(" -x: Add Texture\n");
|
||||||
|
printf(" -d: Add Anim\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");
|
||||||
|
|
||||||
|
ThisActor.ProcessActor();
|
||||||
|
ThisActor.ProcessAnim();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
//***************************************************************************
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::SetInName(GString const &String)
|
||||||
|
{
|
||||||
|
GString UpperName(String);
|
||||||
|
UpperName.Upper();
|
||||||
|
GFName File=UpperName;
|
||||||
|
|
||||||
|
InFilename=UpperName;
|
||||||
InPath=File.Drive();
|
InPath=File.Drive();
|
||||||
InPath+=File.Dir();
|
InPath+=File.Dir();
|
||||||
OutDir=Out;
|
|
||||||
OutDir.Append('\\');
|
|
||||||
|
|
||||||
Name=File.File();
|
Name=File.File();
|
||||||
// Create Out Filename from inFilename and outdir
|
|
||||||
OutFile=OutDir+File.File();
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::SetTPData(int TPBase,int TPW,int TPH)
|
||||||
|
{
|
||||||
TPageBase=TPBase;
|
TPageBase=TPBase;
|
||||||
TPageWidth=TPW ;
|
TPageWidth=TPW ;
|
||||||
TPageHeight=TPH;
|
TPageHeight=TPH;
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkActor3d::Load()
|
void CMkActor3d::AddAnim(const char *Name)
|
||||||
{
|
{
|
||||||
|
InAnimList.push_back(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::AddTex(const char *Name)
|
||||||
|
{
|
||||||
|
InTexList.push_back(Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::ProcessActor()
|
||||||
|
{
|
||||||
|
ThisActor.ActorLoad();
|
||||||
|
ThisActor.ActorProcess();
|
||||||
|
ThisActor.ActorWrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::ProcessAnim()
|
||||||
|
{
|
||||||
|
ThisActor.AnimLoad();
|
||||||
|
ThisActor.AnimWrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::ActorLoad()
|
||||||
|
{
|
||||||
|
OutStr.Upper();
|
||||||
|
OutStr.Append('\\');
|
||||||
|
OutFile=OutStr+Name;
|
||||||
|
IncludeFile.Upper();
|
||||||
|
IncludeFile.Append('\\');
|
||||||
|
IncFile=IncludeFile;
|
||||||
|
IncFile+="ACTOR_";
|
||||||
|
IncFile+=Name;
|
||||||
|
|
||||||
Scene.Load(InFilename);
|
Scene.Load(InFilename);
|
||||||
// Scene.PrintPruneTree();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -157,12 +230,11 @@ vector<Vector3> VtxList;
|
||||||
int WeightCount=ThisNode.Weights.size();
|
int WeightCount=ThisNode.Weights.size();
|
||||||
if (WeightCount)
|
if (WeightCount)
|
||||||
{
|
{
|
||||||
printf("%s %i\n",ThisNode.Name,WeightCount);
|
// printf("%s %i\n",ThisNode.Name,WeightCount);
|
||||||
for (int i=0; i<WeightCount; i++)
|
for (int i=0; i<WeightCount; i++)
|
||||||
{
|
{
|
||||||
sGinWeight &ThisWeight=ThisNode.Weights[i];
|
sGinWeight &ThisWeight=ThisNode.Weights[i];
|
||||||
// printf("%i %f %f %f\t\n",ThisWeight.VertNo,NodeVtxList[ThisWeight.VertNo].x,NodeVtxList[ThisWeight.VertNo].y,NodeVtxList[ThisWeight.VertNo].z);
|
// printf("%i %f %f %f\t\n",ThisWeight.VertNo,NodeVtxList[ThisWeight.VertNo].x,NodeVtxList[ThisWeight.VertNo].y,NodeVtxList[ThisWeight.VertNo].z);
|
||||||
// ThisBone.FaceList.AddVtx((Vector3) NodeVtxList[ThisWeight.VertNo]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Skel.push_back(ThisBone);
|
Skel.push_back(ThisBone);
|
||||||
|
@ -184,6 +256,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());
|
||||||
|
|
||||||
ParentBone.FaceList.AddFace( VtxList, NodeTriList[T], NodeUVList[T], SceneTexList[Mat]);
|
ParentBone.FaceList.AddFace( VtxList, NodeTriList[T], NodeUVList[T], SceneTexList[Mat]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +272,8 @@ void CMkActor3d::BuildSkelOut()
|
||||||
{
|
{
|
||||||
int ListSize=Skel.size();
|
int ListSize=Skel.size();
|
||||||
|
|
||||||
|
BoneCount=Skel.size();
|
||||||
|
|
||||||
for (int i=0; i<ListSize; i++)
|
for (int i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
sGinSkel &ThisBone=Skel[i];
|
sGinSkel &ThisBone=Skel[i];
|
||||||
|
@ -233,21 +309,23 @@ int ListSize=Skel.size();
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkActor3d::Process()
|
void CMkActor3d::ActorProcess()
|
||||||
{
|
{
|
||||||
|
GString IncName=IncFile+".h";
|
||||||
|
|
||||||
FaceList.SetTexBasePath(InPath);
|
FaceList.SetTexBasePath(InPath);
|
||||||
FaceList.SetTexOut(OutFile+".Tex",TPageBase,TPageWidth,TPageHeight);
|
FaceList.SetTexOut(OutFile+".Tex",TPageBase,TPageWidth,TPageHeight);
|
||||||
FaceList.SetTexDebugOut(OutFile+".Lbm");
|
FaceList.SetTexDebugOut(OutFile+".Lbm");
|
||||||
if (!IncludeFile.Empty()) FaceList.SetTexInclude(IncludeFile);
|
if (!IncludeFile.Empty()) FaceList.SetTexInclude(IncName);
|
||||||
|
|
||||||
ProcessSkel(1,-1);
|
ProcessSkel(1,-1);
|
||||||
BuildSkelOut();
|
BuildSkelOut();
|
||||||
printf("Skel has %i bones\n",Skel.size());
|
printf("%s has %i bones\n",Name,BoneCount);
|
||||||
|
|
||||||
int ListSize=ExtraTex.size();
|
int ListSize=InTexList.size();
|
||||||
for (int i=0; i<ListSize; i++)
|
for (int i=0; i<ListSize; i++)
|
||||||
{
|
{
|
||||||
FaceList.AddTex(ExtraTex[i]);
|
FaceList.AddTex(InTexList[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
FaceList.ProcessTextures();
|
FaceList.ProcessTextures();
|
||||||
|
@ -256,14 +334,14 @@ int ListSize=ExtraTex.size();
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
void CMkActor3d::Write()
|
void CMkActor3d::ActorWrite()
|
||||||
{
|
{
|
||||||
GString OutName=OutFile+".A3d";
|
GString OutName=OutFile+".A3d";
|
||||||
|
|
||||||
File=fopen(OutName,"wb");
|
File=fopen(OutName,"wb");
|
||||||
|
|
||||||
// Write Dummy Hdr
|
// Write Dummy Hdr
|
||||||
fwrite(&FileHdr,1,sizeof(sActor3dHdr),File);
|
fwrite(&FileHdr,1,sizeof(sActorHdr),File);
|
||||||
|
|
||||||
// Write Skeleton
|
// Write Skeleton
|
||||||
FileHdr.BoneCount=Skel.size();
|
FileHdr.BoneCount=Skel.size();
|
||||||
|
@ -290,7 +368,7 @@ GString OutName=OutFile+".A3d";
|
||||||
|
|
||||||
// Rewrite Header
|
// Rewrite Header
|
||||||
fseek(File, 0, SEEK_SET);
|
fseek(File, 0, SEEK_SET);
|
||||||
fwrite(&FileHdr,1,sizeof(sActor3dHdr),File);
|
fwrite(&FileHdr,1,sizeof(sActorHdr),File);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
@ -348,46 +426,234 @@ int Pos=ftell(File);
|
||||||
CalcTPXY(TexList[i],OutTex);
|
CalcTPXY(TexList[i],OutTex);
|
||||||
fwrite(&OutTex, sizeof(sTexInfo), 1, File);
|
fwrite(&OutTex, sizeof(sTexInfo), 1, File);
|
||||||
}
|
}
|
||||||
printf("%i Materials\n",ListSize);
|
// printf("%i Materials\n",ListSize);
|
||||||
|
|
||||||
return (Pos);
|
return (Pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************************************
|
|
||||||
//***************************************************************************
|
|
||||||
//***************************************************************************
|
|
||||||
|
|
||||||
void Usage(char *ErrStr)
|
//***************************************************************************
|
||||||
|
//*** Anim ******************************************************************
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::AnimLoad()
|
||||||
{
|
{
|
||||||
printf("\nMkActor3d: by Dave\n");
|
int ListSize=InAnimList.size();
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
//***************************************************************************
|
for (int i=0; i<ListSize; i++)
|
||||||
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);
|
CScene Scene;
|
||||||
|
int ThisBoneCount;
|
||||||
|
GFName Name=InAnimList[i];
|
||||||
|
|
||||||
ThisActor.Load();
|
printf("%s\t",Name.File());
|
||||||
ThisActor.Process();
|
Scene.Load(InAnimList[i]);
|
||||||
ThisActor.Write();
|
|
||||||
|
// Process Anim
|
||||||
|
sAnim ThisAnim;
|
||||||
|
ThisAnim.Name=Name.File();
|
||||||
|
ThisAnim.Name.Upper();
|
||||||
|
ThisAnim.FrameCount=AnimProcessSkelMove(Scene,ThisAnim,1);
|
||||||
|
AnimProcessSkelAnim(Scene,ThisAnim,1);
|
||||||
|
AnimList.push_back(ThisAnim);
|
||||||
|
|
||||||
|
ThisBoneCount=ThisAnim.BoneAnim.size();
|
||||||
|
printf("\t(%i Bones, %i Frames)\n",ThisBoneCount,ThisAnim.FrameCount);
|
||||||
|
|
||||||
|
// Check Skeleton
|
||||||
|
if (BoneCount!=ThisBoneCount)
|
||||||
|
{
|
||||||
|
GObject::Error(ERR_FATAL,"Invalid skeleton\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
int CMkActor3d::AnimProcessSkelMove(CScene &Scene,sAnim &ThisAnim,int Idx)
|
||||||
|
{
|
||||||
|
CNode &ThisNode=Scene.GetNode(Idx);
|
||||||
|
vector<sGinAnim> const &NodeAnim=ThisNode.GetAnim();
|
||||||
|
int FrameCount=NodeAnim.size();
|
||||||
|
vector<s32> &Move=ThisAnim.Move;
|
||||||
|
|
||||||
|
Move.resize(FrameCount);
|
||||||
|
for (int i=0; i<FrameCount; i++)
|
||||||
|
{
|
||||||
|
Move[i]=-round(NodeAnim[i].Pos.y*Scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(FrameCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::AnimProcessSkelAnim(CScene &Scene,sAnim &ThisAnim,int Idx)
|
||||||
|
{
|
||||||
|
CNode &ThisNode=Scene.GetNode(Idx);
|
||||||
|
vector<sGinAnim> const &NodeAnim=ThisNode.GetAnim();
|
||||||
|
int FrameCount=NodeAnim.size();
|
||||||
|
|
||||||
|
// if (!ThisNode.Pts.size()) // Dont export Skin as bone
|
||||||
|
if (!ThisNode.GetTris().size()) // Dont export Skin as bone
|
||||||
|
{
|
||||||
|
sBoneAnim FrameList;
|
||||||
|
FrameList.Idx.resize(FrameCount);
|
||||||
|
|
||||||
|
for (int i=0; i<FrameCount; i++)
|
||||||
|
{
|
||||||
|
sGinAnim const &InFrame=NodeAnim[i];
|
||||||
|
sQuat ThisFrame;
|
||||||
|
Quaternion const &ThisQuat=InFrame.Ang;
|
||||||
|
|
||||||
|
ThisFrame.vx=round(ThisQuat.x*4096);
|
||||||
|
ThisFrame.vy=round(ThisQuat.y*4096);
|
||||||
|
ThisFrame.vz=round(ThisQuat.z*4096);
|
||||||
|
ThisFrame.vw=round(ThisQuat.w*4096);
|
||||||
|
FrameList.Idx[i]=QuatList.Add(ThisFrame);
|
||||||
|
}
|
||||||
|
ThisAnim.BoneAnim.push_back(FrameList);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ChildCount=ThisNode.GetPruneChildCount();
|
||||||
|
|
||||||
|
for (int Loop=0;Loop<ChildCount;Loop++) AnimProcessSkelAnim(Scene,ThisAnim,ThisNode.PruneChildList[Loop]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::AnimWrite()
|
||||||
|
{
|
||||||
|
GString OutName=OutFile+".Abk";
|
||||||
|
int Anim,AnimCount=AnimList.size();
|
||||||
|
sAnimFileHdr FileHdr;
|
||||||
|
sAnimHdr Hdr;
|
||||||
|
|
||||||
|
File=fopen(OutName,"wb");
|
||||||
|
|
||||||
|
// Write Dummy FileHdr
|
||||||
|
FileHdr.AnimCount=AnimCount;
|
||||||
|
FileHdr.BoneCount=BoneCount;
|
||||||
|
fwrite(&FileHdr,1,sizeof(sAnimFileHdr),File);
|
||||||
|
|
||||||
|
// Write Dummy AnimHdrs
|
||||||
|
|
||||||
|
for (Anim=0; Anim<AnimCount; Anim++)
|
||||||
|
{
|
||||||
|
fwrite(&Hdr,1,sizeof(sAnimHdr),File);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write QuatTable
|
||||||
|
FileHdr.QuatTable=(sQuat*)AnimWriteQuatTable();
|
||||||
|
|
||||||
|
// Write Movements
|
||||||
|
for (Anim=0; Anim<AnimCount; Anim++)
|
||||||
|
{
|
||||||
|
AnimList[Anim].MoveOfs=AnimWriteMove(AnimList[Anim]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write Anims (u16 can cause address errors, so write last
|
||||||
|
for (Anim=0; Anim<AnimCount; Anim++)
|
||||||
|
{
|
||||||
|
AnimList[Anim].AnimOfs=AnimWriteAnim(AnimList[Anim]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReWrite FileHdr
|
||||||
|
fseek(File, 0, SEEK_SET);
|
||||||
|
fwrite(&FileHdr,1,sizeof(sAnimFileHdr),File);
|
||||||
|
|
||||||
|
// Rewrite Dummy AnimHdrs
|
||||||
|
|
||||||
|
for (Anim=0; Anim<AnimCount; Anim++)
|
||||||
|
{
|
||||||
|
Hdr.FrameCount=AnimList[Anim].FrameCount;
|
||||||
|
Hdr.Move=(s32*)AnimList[Anim].MoveOfs;
|
||||||
|
Hdr.Anim=(u16*)AnimList[Anim].AnimOfs;
|
||||||
|
fwrite(&Hdr,1,sizeof(sAnimHdr),File);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(File);
|
||||||
|
if (!IncludeFile.Empty()) AnimWriteInclude();
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
int CMkActor3d::AnimWriteMove(sAnim const &ThisAnim)
|
||||||
|
{
|
||||||
|
int Pos=ftell(File);
|
||||||
|
|
||||||
|
for (int Frame=0; Frame<ThisAnim.FrameCount; Frame++)
|
||||||
|
{
|
||||||
|
s32 ThisMove=ThisAnim.Move[Frame];
|
||||||
|
fwrite(&ThisMove,1,sizeof(s32),File);
|
||||||
|
// printf("%i %i %i\n",ThisMove.vx,ThisMove.vy,ThisMove.vz);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
int CMkActor3d::AnimWriteAnim(sAnim const &ThisAnim)
|
||||||
|
{
|
||||||
|
int Pos=ftell(File);
|
||||||
|
|
||||||
|
for (int Frame=0; Frame<ThisAnim.FrameCount; Frame++)
|
||||||
|
{
|
||||||
|
for (int Bone=0; Bone<BoneCount; Bone++)
|
||||||
|
{
|
||||||
|
u16 ThisIdx=ThisAnim.BoneAnim[Bone].Idx[Frame];
|
||||||
|
fwrite(&ThisIdx,1,sizeof(u16),File);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
int CMkActor3d::AnimWriteQuatTable()
|
||||||
|
{
|
||||||
|
int Pos=ftell(File);
|
||||||
|
int ListSize=QuatList.size();
|
||||||
|
|
||||||
|
for (int i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
sQuat &ThisQuat=QuatList[i];
|
||||||
|
fwrite(&ThisQuat,1,sizeof(sQuat),File);
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------
|
||||||
|
printf("%i Anims\n",AnimList.size());
|
||||||
|
return(Pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
void CMkActor3d::AnimWriteInclude()
|
||||||
|
{
|
||||||
|
GString Filename=IncFile+"_Anim.h";
|
||||||
|
|
||||||
|
File=fopen(Filename,"wt");
|
||||||
|
|
||||||
|
fprintf(File,"// %s Anim Header\n",Name);
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"#ifndef\t__ANIM_%s_HEADER__\n",Name);
|
||||||
|
fprintf(File,"#define\t__ANIM_%s_HEADER__\n",Name);
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"enum\tANIM_%s_LIST\n",Name);
|
||||||
|
fprintf(File,"{\n");
|
||||||
|
|
||||||
|
int ListSize=AnimList.size();
|
||||||
|
for (int i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
sAnim &ThisAnim=AnimList[i];
|
||||||
|
fprintf(File,"\tANIM_%s_%s",Name,ThisAnim.Name);
|
||||||
|
if (i==0)
|
||||||
|
{
|
||||||
|
fprintf(File,"=0");
|
||||||
|
}
|
||||||
|
fprintf(File,",\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(File,"\tNUM_ANIM_%s\n",Name);
|
||||||
|
fprintf(File,"};\n");
|
||||||
|
fprintf(File,"\n");
|
||||||
|
fprintf(File,"#endif\n");
|
||||||
|
|
||||||
|
fclose(File);
|
||||||
|
}
|
||||||
|
|
|
@ -8,23 +8,47 @@
|
||||||
|
|
||||||
#include "..\mapedit\ExportHdr.h"
|
#include "..\mapedit\ExportHdr.h"
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
struct sGinSkel
|
struct sGinSkel
|
||||||
{
|
{
|
||||||
sBone Bone;
|
sBone Bone;
|
||||||
CFaceStore FaceList;
|
CFaceStore FaceList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
struct sBoneAnim
|
||||||
|
{
|
||||||
|
vector<int> Idx;
|
||||||
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
struct sAnim
|
||||||
|
{
|
||||||
|
GString Name;
|
||||||
|
int FrameCount;
|
||||||
|
vector<sBoneAnim> BoneAnim;
|
||||||
|
vector<s32> Move;
|
||||||
|
int AnimOfs;
|
||||||
|
int MoveOfs;
|
||||||
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
class CMkActor3d
|
class CMkActor3d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMkActor3d(GString const &In,GString const &Out,int TPBase,int TPW,int TPH);
|
void SetInName(GString const &In);
|
||||||
|
void SetTPData(int TPBase,int TPW,int TPH);
|
||||||
|
|
||||||
void Load();
|
void AddAnim(const char *Name);
|
||||||
void Process();
|
void AddTex(const char *Name);
|
||||||
void Write();
|
|
||||||
|
|
||||||
|
void ProcessActor();
|
||||||
|
void ProcessAnim();
|
||||||
private:
|
private:
|
||||||
|
void ActorLoad();
|
||||||
|
void ActorProcess();
|
||||||
|
void ActorWrite();
|
||||||
|
|
||||||
void ProcessSkel(int Idx,int Parent);
|
void ProcessSkel(int Idx,int Parent);
|
||||||
void WriteSkel();
|
void WriteSkel();
|
||||||
|
|
||||||
|
@ -32,20 +56,37 @@ private:
|
||||||
void BuildBoneOut(sBone &OutBone,CNode const &InNode,int ParentBoneIdx);
|
void BuildBoneOut(sBone &OutBone,CNode const &InNode,int ParentBoneIdx);
|
||||||
int WriteTexInfoList();
|
int WriteTexInfoList();
|
||||||
|
|
||||||
GString InFilename,InPath,Name,OutFile,OutDir;
|
|
||||||
|
|
||||||
|
GString InFilename,InPath,Name,OutFile,IncFile;
|
||||||
CScene Scene;
|
CScene Scene;
|
||||||
|
|
||||||
vector<sGinSkel> Skel;
|
vector<sGinSkel> Skel;
|
||||||
|
|
||||||
CFaceStore FaceList;
|
CFaceStore FaceList;
|
||||||
|
|
||||||
sActor3dHdr FileHdr;
|
sActorHdr FileHdr;
|
||||||
FILE *File;
|
FILE *File;
|
||||||
|
|
||||||
|
std::vector<GString> InTexList;
|
||||||
|
std::vector<GString> InAnimList;
|
||||||
|
|
||||||
int TPageBase;
|
int TPageBase;
|
||||||
int TPageWidth,TPageHeight;
|
int TPageWidth,TPageHeight;
|
||||||
|
|
||||||
|
/*Anim*/
|
||||||
|
void AnimLoad();
|
||||||
|
void AnimWrite();
|
||||||
|
void AnimWriteInclude();
|
||||||
|
int AnimProcessSkelMove(CScene &Scene,sAnim &ThisAnim,int Idx);
|
||||||
|
void AnimProcessSkelAnim(CScene &Scene,sAnim &ThisAnim,int Idx);
|
||||||
|
int AnimWriteMove(sAnim const &ThisAnim);
|
||||||
|
int AnimWriteAnim(sAnim const &ThisAnim);
|
||||||
|
int AnimWriteQuatTable();
|
||||||
|
|
||||||
|
int BoneCount;
|
||||||
|
vector<sAnim> AnimList;
|
||||||
|
CList<sQuat> QuatList;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
|
@ -162,8 +162,8 @@ int ChildCount=ThisNode.GetPruneChildCount();
|
||||||
void CMkAnim3d::Write(GString &Filename)
|
void CMkAnim3d::Write(GString &Filename)
|
||||||
{
|
{
|
||||||
int Anim,AnimCount=AnimList.size();
|
int Anim,AnimCount=AnimList.size();
|
||||||
sAnim3dFileHdr FileHdr;
|
sAnimFileHdr FileHdr;
|
||||||
sAnim3dHdr Hdr;
|
sAnimHdr Hdr;
|
||||||
|
|
||||||
File=fopen(Filename,"wb");
|
File=fopen(Filename,"wb");
|
||||||
|
|
||||||
|
@ -171,13 +171,13 @@ sAnim3dHdr Hdr;
|
||||||
// Write Dummy FileHdr
|
// Write Dummy FileHdr
|
||||||
FileHdr.AnimCount=AnimCount;
|
FileHdr.AnimCount=AnimCount;
|
||||||
FileHdr.BoneCount=BoneCount;
|
FileHdr.BoneCount=BoneCount;
|
||||||
fwrite(&FileHdr,1,sizeof(sAnim3dFileHdr),File);
|
fwrite(&FileHdr,1,sizeof(sAnimFileHdr),File);
|
||||||
|
|
||||||
// Write Dummy AnimHdrs
|
// Write Dummy AnimHdrs
|
||||||
|
|
||||||
for (Anim=0; Anim<AnimCount; Anim++)
|
for (Anim=0; Anim<AnimCount; Anim++)
|
||||||
{
|
{
|
||||||
fwrite(&Hdr,1,sizeof(sAnim3dHdr),File);
|
fwrite(&Hdr,1,sizeof(sAnimHdr),File);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write QuatTable
|
// Write QuatTable
|
||||||
|
@ -197,7 +197,7 @@ sAnim3dHdr Hdr;
|
||||||
|
|
||||||
// ReWrite FileHdr
|
// ReWrite FileHdr
|
||||||
fseek(File, 0, SEEK_SET);
|
fseek(File, 0, SEEK_SET);
|
||||||
fwrite(&FileHdr,1,sizeof(sAnim3dFileHdr),File);
|
fwrite(&FileHdr,1,sizeof(sAnimFileHdr),File);
|
||||||
|
|
||||||
// Rewrite Dummy AnimHdrs
|
// Rewrite Dummy AnimHdrs
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ sAnim3dHdr Hdr;
|
||||||
Hdr.FrameCount=AnimList[Anim].FrameCount;
|
Hdr.FrameCount=AnimList[Anim].FrameCount;
|
||||||
Hdr.Move=(s32*)AnimList[Anim].MoveOfs;
|
Hdr.Move=(s32*)AnimList[Anim].MoveOfs;
|
||||||
Hdr.Anim=(u16*)AnimList[Anim].AnimOfs;
|
Hdr.Anim=(u16*)AnimList[Anim].AnimOfs;
|
||||||
fwrite(&Hdr,1,sizeof(sAnim3dHdr),File);
|
fwrite(&Hdr,1,sizeof(sAnimHdr),File);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(File);
|
fclose(File);
|
||||||
|
@ -222,9 +222,7 @@ int Pos=ftell(File);
|
||||||
{
|
{
|
||||||
s32 ThisMove=ThisAnim.Move[Frame];
|
s32 ThisMove=ThisAnim.Move[Frame];
|
||||||
fwrite(&ThisMove,1,sizeof(s32),File);
|
fwrite(&ThisMove,1,sizeof(s32),File);
|
||||||
|
|
||||||
// printf("%i %i %i\n",ThisMove.vx,ThisMove.vy,ThisMove.vz);
|
// printf("%i %i %i\n",ThisMove.vx,ThisMove.vy,ThisMove.vz);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(Pos);
|
return(Pos);
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
struct sBoneAnim
|
struct sBoneAnim
|
||||||
{
|
{
|
||||||
// vector<sQuat> Quat;
|
|
||||||
vector<int> Idx;
|
vector<int> Idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
struct sAnim
|
struct sAnim
|
||||||
{
|
{
|
||||||
GString Name;
|
GString Name;
|
||||||
|
@ -32,20 +32,20 @@ public:
|
||||||
BoneCount=-1;
|
BoneCount=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Add(GString const &Filename);
|
/*Anim*/void Add(GString const &Filename);
|
||||||
void Write(GString &Filename);
|
/*Anim*/void Write(GString &Filename);
|
||||||
void WriteInclude(GString const &IncludeFile);
|
/*Anim*/void WriteInclude(GString const &IncludeFile);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int ProcessSkelMove(CScene &Scene,sAnim &ThisAnim,int Idx);
|
/*Anim*/int ProcessSkelMove(CScene &Scene,sAnim &ThisAnim,int Idx);
|
||||||
void ProcessSkelAnim(CScene &Scene,sAnim &ThisAnim,int Idx);
|
/*Anim*/void ProcessSkelAnim(CScene &Scene,sAnim &ThisAnim,int Idx);
|
||||||
int WriteMove(sAnim const &ThisAnim);
|
/*Anim*/int WriteMove(sAnim const &ThisAnim);
|
||||||
int WriteAnim(sAnim const &ThisAnim);
|
/*Anim*/int WriteAnim(sAnim const &ThisAnim);
|
||||||
int WriteQuatTable();
|
/*Anim*/int WriteQuatTable();
|
||||||
|
|
||||||
int BoneCount;
|
/*Anim*/int BoneCount;
|
||||||
vector<sAnim> AnimList;
|
/*Anim*/vector<sAnim> AnimList;
|
||||||
CList<sQuat> QuatList;
|
/*Anim*/CList<sQuat> QuatList;
|
||||||
FILE *File;
|
FILE *File;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,6 @@ DATA_INC_DIR := $(DATA_TOOL_DIR)/include
|
||||||
|
|
||||||
MKLEVEL := $(DATA_BIN_DIR)/MkLevel
|
MKLEVEL := $(DATA_BIN_DIR)/MkLevel
|
||||||
MKACTOR3D := $(DATA_BIN_DIR)/MkActor3d
|
MKACTOR3D := $(DATA_BIN_DIR)/MkActor3d
|
||||||
MKANIM3D := $(DATA_BIN_DIR)/MkAnim3d
|
|
||||||
|
|
||||||
# Cygwin
|
# Cygwin
|
||||||
# ------
|
# ------
|
||||||
|
|
Loading…
Add table
Reference in a new issue