Directors Cut Wiki : Animations

DirectorsCutModdingFoundry Categories PageIndex RecentChanges RecentlyCommented Login/Register
Trail: MeshFiles PageIndex WikkaDocumentation PageIndex TextSearchExpanded PageIndex MeshManip0Tutorial Animations

Most recent edit on 2007-12-11 12:30:59 by Gleem! [Added 010 Templates]

Additions:

Technical File Info

//--------------------------------------
//--- 010 Editor v2.1.3 Binary Template
//
// File: LionHead The Movies .ANM file structure
// Author: Glen Rickey; Updated by Reacher 7/22/2007
// Revision: 0.09
// Purpose: Parses TM Anm files	
//--------------------------------------
#include "VecMatrix.bt"
#include "CompressedU16.bt"


local quad align;
local uint16 v1;
local uint16 v2;
local uint16 v3;
local uint16 count;
local string comment;

typedef ushort CMP16 <read=CMP16Read>;
string CMP16Read( CMP16 f )
{
	string s; 
	local float g;
	g = (f/32767.0f - 1);  
	SPrintf( s, "Data: 0x%04x, %f ", f, g);
	return s;
}

typedef ushort MUL16 <read=MUL16Read>;
string MUL16Read( MUL16 f )
{
	string s;   
	SPrintf( s, "CountWord: 0x%04x ", f);
	return s;
}

struct AnimHeader
{
	enum
	{
	AH_CURRENT_VERSION = 12,
	};

	int	MagicNumber;
	ubyte	CountAnims;
	ubyte	CountStaticAnimation;
	uint16	FrameCount;
	
	Matrix34 OriginInWorld;

	struct 
	{
	ubyte	IsVariance		: 1;
	ubyte	Is30FPS			: 1;
	ubyte				: 0;
	} Flags1;
	
	ubyte	ALIGN;
	uint16	ALIGN2;

	if (CountAnims>1)
	{
	struct AnimOrigins
	{
	    //	int32	AnmIndex;
	    Matrix34	animOrigin;				
	} anmOrig[CountAnims-1];
	};
} head;

//Bone-Based Anims
if (head.CountAnims>0)
{
	struct CAnim
	{
	struct CAnimHeader
	{
	    int		FrameCount;
	    uint16	BoneCount;
	    ubyte	TypeForBesson;

	    struct 
	    {
		    ubyte	IsContainingScaleFactor	: 1;
		    ubyte	ContainsProbability	: 1;
		    ubyte	ContainAnimatedScale	: 1;
		    ubyte				: 0;
	    } Flags1;

	    struct
	    {
		float X;
		float Y;
		float Z;
		float Angle;
	    } Destination;
	    if (CAnimHead.Flags1.ContainsProbability)
	    {
		    float	Probability;
	    }

	} CAnimHead;

	if (CAnimHead.Flags1.IsContainingScaleFactor)
	{ 
	    float ScaleCompression;
	}

	struct BoneParentList
	{
	    local int i;
	    for (i=0; i<CAnimHead.BoneCount;i++)
	    {
		ubyte ParentID;
	    }
	} Bones;

	local quad align = FTell();
	if ((align%4)>0) { byte align_pad_bone[4 - (align % 4)]; }

	struct
	{
	    ubyte IsTransStatic;
	    ubyte pad[3];
	    // U16Compressor entities
	    struct cmp16dat
	    {
		uint16 mask;
		local int fc = CA.CAnimHead.FrameCount;
		local quad pos;
		local uint16 flag, dat;
		while (fc > 0)
		{
		    pos = FTell();
		    flag = ReadShort(pos);  // peek at it to figure out what type of data it is
		    count = 1; // default
		    if (flag & mask)
		    {
			v1 = flag & (mask - 1);
			v2 = flag - mask;
			v3 = ~(mask - 1);
			count = v1 | ((v2 & v3) >> 1);
			MUL16 cmpboneanm;
		    }
		    fc -= count;
		    count = 0;
		    CMP16 cmpboneanm;
		    if (fc < 0)
			Printf("Error: frame count below zero on decompress");
		}
	    } x;
	    struct cmp16dat y;
	    struct cmp16dat z;
	    align = FTell();
	    if ((align%4)>0) { byte align_pad_xyz[4 - (align % 4)]; }
	    if (IsTransStatic == 0)
	    {
		struct cmp16dat u;
		struct cmp16dat v;
		struct cmp16dat w;
	    }
	    else
	    {
		float u;
		float v;
		float w;
	    }
	    align = FTell();
	    if ((align%4)>0) { byte align_pad_trans[4 - (align % 4)]; }
	} BoneAnim[CA.CAnimHead.BoneCount] <optimize=false>;
	if (CA.CAnimHead.Flags1.ContainAnimatedScale)
	{
	    local int fc;
	    local int bc;
	    for (fc = 0; fc < CA.CAnimHead.FrameCount; fc++)
	    {
		struct
		{
		    struct
		    {
			for (bc = 0; fc < CA.CAnimHead.BoneCount; bc++)
			{
			    float x;
			    float y;
			    float z;
			}
		    } BoneScale;
		} FrameScale;
	    }

	}

	} CA[head.CountAnims] <optimize=false>;
};
align = FTell();
if ((align%4)>0) { byte align_pad_anim[4 - (align % 4)]; }
//Static Animations
if (head.CountStaticAnimation>0)
{
	struct StaticAnim
	{
	char 	Name[32];
	uint32	IsCarriable		: 1;
	uint32  ContainsScale		: 1;
	uint32	IndexLikeMe		: 4;
	uint32	IsMoreThanOneLikeMe	: 1;
	uint32	IndexSkeleton		: 8;

	if (ContainsScale)
		float	ScaleCompression;

	struct	StAFrame
	{
	    U16F	val[6];
	} saFrame[head.FrameCount];
	} StAnim[head.CountStaticAnimation] <optimize=false>;
}

/*
//custom function Converts U16 to Float
float ConvertU16 ( uint16 v)
{ 
	return (((v-0.5f)/32768)-1); // PI
};

//Converts U8 to Float
float ConvertU8 (ubyte v)
{
	return (((v-0.5f)/128.0f)-1);// PI;
};
*/


VecMatrix.bt
//--------------------------------------
//--- 010 Editor v2.1.3 Binary Template
//
// File: VecMatrix.bt
// Author: Glen Rickey	
// Revision: 0.01
// Purpose: Holds vector and matrix definitions
//--------------------------------------

struct V3
	{
		float	x;
		float	y;
		float	z;
	};

struct V2
	{
		float	x;
		float	y;
	};

struct Matrix34
	{
		V3	m[4];
	};

struct Pos2D 
	{
		V3	Trans;
		float	Zangle;
	};


CompressedU16.bt
//--------------------------------------
//--- 010 Editor v2.1.3 Binary Template
//
// File: U16, U8 Float
// Author: Glen Rickey	
// Revision: 0.01
// Purpose: displays float values of Compressed U16s, U8s
//--------------------------------------

typedef uint16 U16F <read=U16FRead>;

	string U16FRead( U16F f )
	{
	    string s;   
	    SPrintf( s, "%f", ConvertU16(f) );
	    return s;
	}
typedef ubyte U8F <read=U8FRead>;

	string U8FRead( U8F f )
	{
	    string s;   
	    SPrintf( s, "%f", ConvertU8(f) );
	    return s;
	}

//custom function Converts U16 to Float
float ConvertU16 ( uint16 v)
{ 
	return (v/32767.0f)-1;
	//return (((v-0.5f)/32768)-1)* PI
};

//Converts U8 to Float
float ConvertU8 (ubyte v)
{
	return (((v-0.5f)/128.0f)-1);// PI;
};




Oldest known version of this page was edited on 2007-05-18 14:32:08 by XImplosionX []
Page view:
Welcome to the .ANM file format Documentation page. In the next few weeks, I will begin to post my findings on the editing of this file format.
Valid XHTML 1.0 Transitional Valid CSS Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0298 seconds