This commit is contained in:
parent
2ce3536060
commit
3d74ef38c3
3 changed files with 96 additions and 32 deletions
|
@ -105,7 +105,7 @@ void CMkActor3d::Process()
|
|||
{
|
||||
BuildSkin();
|
||||
FaceList.SetTexBasePath(InPath);
|
||||
FaceList.SetTexOut(OutFile+".Tex",1,1,1);
|
||||
FaceList.SetTexOut(OutFile+".Tex",TPageBase,TPageWidth,TPageHeight);
|
||||
FaceList.SetTexDebugOut(OutFile+".Lbm");
|
||||
|
||||
FaceList.Process();
|
||||
|
@ -148,20 +148,21 @@ GString OutName=OutFile+".A3d";
|
|||
fwrite(&FileHdr,1,sizeof(sActor3dHdr),File);
|
||||
|
||||
// Write Skeleton
|
||||
FileHdr.NodeData=ftell(File);
|
||||
FileHdr.BoneCount=Scene.GetPruneTreeSize()-1-1; // Skip Scene & skin
|
||||
FileHdr.BoneList=(sBone*)ftell(File);
|
||||
WriteBone(1);
|
||||
|
||||
// Write Tris
|
||||
FileHdr.TriCount=FaceList.GetTriFaceCount();
|
||||
FileHdr.TriData=FaceList.WriteTriList(File);
|
||||
FileHdr.TriList=(sTri*)FaceList.WriteTriList(File);
|
||||
printf("%i Tris\n",FileHdr.TriCount);
|
||||
// Write Quads
|
||||
FileHdr.QuadCount=FaceList.GetQuadFaceCount();
|
||||
FileHdr.QuadData=FaceList.WriteQuadList(File);
|
||||
FileHdr.QuadList=(sQuad*)FaceList.WriteQuadList(File);
|
||||
printf("%i Quads\n",FileHdr.QuadCount);
|
||||
// Write WeightList
|
||||
FileHdr.WeightCount=WeightList.size();
|
||||
FileHdr.WeightData=WriteWeightList();
|
||||
FileHdr.WeightList=(sWeight*)WriteWeightList();
|
||||
printf("%i Weight\n",FileHdr.WeightCount);
|
||||
|
||||
printf("Size=%i\n",ftell(File));
|
||||
|
@ -198,11 +199,14 @@ int ChildCount=ThisNode.GetPruneChildCount();
|
|||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
void CMkActor3d::BuildBoneOut(sBone &OutBone,CNode const &InNode)
|
||||
{
|
||||
OutBone.BoneSize.vx =round(InNode.Pos.x*Scale);
|
||||
OutBone.BoneSize.vy =round(InNode.Pos.y*Scale);
|
||||
OutBone.BoneSize.vz =round(InNode.Pos.z*Scale);
|
||||
Vector3 const &Vtx=InNode.Pos;
|
||||
|
||||
OutBone.BoneSize.vx =round(Vtx.x*Scale);
|
||||
OutBone.BoneSize.vy =round(Vtx.y*Scale);
|
||||
OutBone.BoneSize.vz =round(Vtx.z*Scale);
|
||||
OutBone.Idx=InNode.PruneIdx-1;
|
||||
OutBone.Parent=InNode.PruneParentIdx-1;
|
||||
OutBone.WeightCount=InNode.Weights.size();
|
||||
|
@ -217,7 +221,6 @@ void CMkActor3d::BuildWeightOut(sWeight &OutWeight,sGinWeight const &InWeight
|
|||
OutWeight.VtxNo=InWeight.VertNo;
|
||||
}
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
int CMkActor3d::WriteWeightList()
|
||||
{
|
||||
|
@ -227,6 +230,7 @@ int Pos=ftell(File);
|
|||
for (int i=0; i<ListSize; i++)
|
||||
{
|
||||
sWeight &OutWeight=WeightList[i];
|
||||
|
||||
fwrite(&OutWeight, sizeof(sWeight), 1, File);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@ char * CycleCommands(char *String,int Num)
|
|||
case 'd':
|
||||
DebugOn =true;
|
||||
break;
|
||||
case 's':
|
||||
TpStr= CheckFileString(String);
|
||||
Scale=atof(TpStr);
|
||||
break;
|
||||
default:
|
||||
GObject::Error(ERR_FATAL,"Unknown switch %s",String);
|
||||
break;
|
||||
|
@ -78,13 +82,32 @@ int ThisBoneCount;
|
|||
// Process Anim
|
||||
sAnim ThisAnim;
|
||||
|
||||
ThisAnim.FrameCount=ProcessSkel(Scene,ThisAnim,1);
|
||||
ThisAnim.FrameCount=ProcessSkelMove(Scene,ThisAnim,1);
|
||||
ProcessSkelAnim(Scene,ThisAnim,1);
|
||||
AnimList.push_back(ThisAnim);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int CMkAnim3d::ProcessSkelMove(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;
|
||||
|
||||
int CMkAnim3d::ProcessSkel(CScene &Scene,sAnim &ThisAnim,int Idx)
|
||||
Move.resize(FrameCount);
|
||||
for (int i=0; i<FrameCount; i++)
|
||||
{
|
||||
// Move[i].vx=round(NodeAnim[i].Pos.x*Scale);
|
||||
Move[i]=-round(NodeAnim[i].Pos.y*Scale);
|
||||
// Move[i].vz=round(NodeAnim[i].Pos.z*Scale);
|
||||
}
|
||||
|
||||
return(FrameCount);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void CMkAnim3d::ProcessSkelAnim(CScene &Scene,sAnim &ThisAnim,int Idx)
|
||||
{
|
||||
CNode &ThisNode=Scene.GetNode(Idx);
|
||||
vector<sGinAnim> const &NodeAnim=ThisNode.GetAnim();
|
||||
|
@ -99,10 +122,23 @@ int FrameCount=NodeAnim.size();
|
|||
{
|
||||
sGinAnim const &InFrame=NodeAnim[i];
|
||||
sQuat ThisFrame;
|
||||
ThisFrame.vx=round(InFrame.Ang.x*4096);
|
||||
ThisFrame.vy=round(InFrame.Ang.y*4096);
|
||||
ThisFrame.vz=round(InFrame.Ang.z*4096);
|
||||
ThisFrame.vw=round(InFrame.Ang.w*4096);
|
||||
Quaternion ThisQuat=InFrame.Ang;
|
||||
|
||||
/* if (Idx==1)
|
||||
{
|
||||
Matrix4x4 Mtx;
|
||||
ThisQuat.ToMatrix(Mtx);
|
||||
Mtx.m_M[0][1]=-Mtx.m_M[0][1];
|
||||
Mtx.m_M[1][1]=-Mtx.m_M[1][1];
|
||||
Mtx.m_M[2][1]=-Mtx.m_M[2][1];
|
||||
Mtx.m_M[3][1]=-Mtx.m_M[3][1];
|
||||
Mtx.ToQuaternion(ThisQuat);
|
||||
}
|
||||
*/
|
||||
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);
|
||||
QuatCount++;
|
||||
}
|
||||
|
@ -111,9 +147,7 @@ int FrameCount=NodeAnim.size();
|
|||
|
||||
int ChildCount=ThisNode.GetPruneChildCount();
|
||||
|
||||
for (int Loop=0;Loop<ChildCount;Loop++) ProcessSkel(Scene,ThisAnim,ThisNode.PruneChildList[Loop]);
|
||||
|
||||
return(FrameCount);
|
||||
for (int Loop=0;Loop<ChildCount;Loop++) ProcessSkelAnim(Scene,ThisAnim,ThisNode.PruneChildList[Loop]);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -137,15 +171,22 @@ sAnim3dHdr Hdr;
|
|||
{
|
||||
fwrite(&Hdr,1,sizeof(sAnim3dHdr),File);
|
||||
}
|
||||
// Write Anims
|
||||
for (Anim=0; Anim<AnimCount; Anim++)
|
||||
{
|
||||
AnimList[Anim].FileOfs=WriteAnim(AnimList[Anim]);
|
||||
}
|
||||
|
||||
// Write QuatTable
|
||||
FileHdr.QuatTable=(sQuat*)WriteQuatTable();
|
||||
|
||||
|
||||
// Write Movements
|
||||
for (Anim=0; Anim<AnimCount; Anim++)
|
||||
{
|
||||
AnimList[Anim].MoveOfs=WriteMove(AnimList[Anim]);
|
||||
}
|
||||
|
||||
// Write Anims (u16 can cause address errors, so write last
|
||||
for (Anim=0; Anim<AnimCount; Anim++)
|
||||
{
|
||||
AnimList[Anim].AnimOfs=WriteAnim(AnimList[Anim]);
|
||||
}
|
||||
|
||||
// ReWrite FileHdr
|
||||
fseek(File, 0, SEEK_SET);
|
||||
fwrite(&FileHdr,1,sizeof(sAnim3dFileHdr),File);
|
||||
|
@ -155,7 +196,8 @@ sAnim3dHdr Hdr;
|
|||
for (Anim=0; Anim<AnimCount; Anim++)
|
||||
{
|
||||
Hdr.FrameCount=AnimList[Anim].FrameCount;
|
||||
Hdr.Anim=(u16*)AnimList[Anim].FileOfs;
|
||||
Hdr.Move=(s32*)AnimList[Anim].MoveOfs;
|
||||
Hdr.Anim=(u16*)AnimList[Anim].AnimOfs;
|
||||
fwrite(&Hdr,1,sizeof(sAnim3dHdr),File);
|
||||
}
|
||||
|
||||
|
@ -163,6 +205,23 @@ sAnim3dHdr Hdr;
|
|||
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
int CMkAnim3d::WriteMove(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 CMkAnim3d::WriteAnim(sAnim const &ThisAnim)
|
||||
{
|
||||
|
@ -170,7 +229,6 @@ int Pos=ftell(File);
|
|||
|
||||
for (int Frame=0; Frame<ThisAnim.FrameCount; Frame++)
|
||||
{
|
||||
// printf("Frame %i/%i\r",Frame,ThisAnim.FrameCount);
|
||||
for (int Bone=0; Bone<BoneCount; Bone++)
|
||||
{
|
||||
u16 ThisIdx=ThisAnim.BoneAnim[Bone].Idx[Frame];
|
||||
|
@ -213,6 +271,7 @@ void Usage(char *ErrStr)
|
|||
printf("Switches:\n");
|
||||
printf(" -o:[FILE] Set output File\n");
|
||||
printf(" -d: Enable Debug output\n");
|
||||
printf(" -s: Set Scale\n");
|
||||
GObject::Error(ERR_FATAL,ErrStr);
|
||||
}
|
||||
|
||||
|
@ -235,6 +294,3 @@ vector<GString> const &Files = MyFiles.GetFileInfoVector();
|
|||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
c:\spongebob\graphics\characters\spongebob\sbanim\buttbounce.gin c:\spongebob\graphics\characters\spongebob\sbanim\deathelectric.gin c:\spongebob\graphics\characters\spongebob\sbanim\deathfall.gin c:\spongebob\graphics\characters\spongebob\sbanim\electricshock.gin c:\spongebob\graphics\characters\spongebob\sbanim\fall.gin c:\spongebob\graphics\characters\spongebob\sbanim\fireaim.gin c:\spongebob\graphics\characters\spongebob\sbanim\firerecoill.gin c:\spongebob\graphics\characters\spongebob\sbanim\float.gin c:\spongebob\graphics\characters\spongebob\sbanim\getup.gin c:\spongebob\graphics\characters\spongebob\sbanim\hitground01.gin c:\spongebob\graphics\characters\spongebob\sbanim\hover.gin c:\spongebob\graphics\characters\spongebob\sbanim\idleboots.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlecoral.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlecoral01.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlegeneric01.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlegeneric02.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlegeneric03.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlegeneric04.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlegeneric05.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlelauncher.gin c:\spongebob\graphics\characters\spongebob\sbanim\idlenet.gin -o:\temp\anim.bnk
|
||||
*/
|
|
@ -9,7 +9,7 @@
|
|||
//***************************************************************************
|
||||
struct sBoneAnim
|
||||
{
|
||||
vector<sQuat> Quat;
|
||||
// vector<sQuat> Quat;
|
||||
vector<int> Idx;
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,9 @@ struct sAnim
|
|||
{
|
||||
int FrameCount;
|
||||
vector<sBoneAnim> BoneAnim;
|
||||
int FileOfs;
|
||||
vector<s32> Move;
|
||||
int AnimOfs;
|
||||
int MoveOfs;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -33,7 +35,9 @@ public:
|
|||
void Write(GString &Filename);
|
||||
|
||||
private:
|
||||
int ProcessSkel(CScene &Scene,sAnim &ThisAnim,int Idx);
|
||||
int ProcessSkelMove(CScene &Scene,sAnim &ThisAnim,int Idx);
|
||||
void ProcessSkelAnim(CScene &Scene,sAnim &ThisAnim,int Idx);
|
||||
int WriteMove(sAnim const &ThisAnim);
|
||||
int WriteAnim(sAnim const &ThisAnim);
|
||||
int WriteQuatTable();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue