using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using Gibbed.IO;
namespace Metro_2033_SDK_Tools
{
public partial class ConvertAnimation : Form
{
protected const UInt32 MC_HeaderChunk = 0x00000000,
MC_InfoChunk = 0x00000001,
MC_DataChunk = 0x00000009;
public ConvertAnimation()
{
InitializeComponent();
}
private void convert_Click(object sender, EventArgs e)
{
mtnOpen.Title = "Метро 2033 анимации";
mtnOpen.Filter = "Анимации \"Метро 2033\"(*.motion)|*.motion|Все файлы(*.*)|*.*";
mtnOpen.DefaultExt = "*.motion";
mtnOpen.ShowDialog();
string path = mtnOpen.FileName;
convertPath.Text = path;
using (Stream input = File.OpenRead(path))
{
while (input.Position < (input.Length - 7))
{
UInt32 chunkId = input.ReadValueU32();
UInt32 chunkSize = input.ReadValueU32();
UInt64 ChunkEnd = (ulong)input.Position + chunkSize;
UInt32 mMotionsDataSize = 0;
switch (chunkId)
{
case MC_HeaderChunk:
UInt32 mVer = input.ReadValueU32();
UInt32 mBonesCRC = input.ReadValueU32();
UInt16 mNumBones = input.ReadValueU16();
UInt16 mNumLocators = input.ReadValueU16();
break;
case MC_InfoChunk:
UInt16 mFlags = input.ReadValueU16();
float mSpeed = input.ReadValueF32();
float mAccrue = input.ReadValueF32();
float mFalloff = input.ReadValueF32();
UInt32 mNumKeys = input.ReadValueU32();
UInt16 mJumpFrame = input.ReadValueU16();
UInt16 mLandFrame = input.ReadValueU16();
BitArray mAffectedBones = new BitArray(256);
mAffectedBones = input.ReadStructure<BitArray>();
mMotionsDataSize = input.ReadValueU32();
UInt32 mMotionsOffsetsSize = input.ReadValueU32();
BitArray mHighQualityBones = new BitArray(256);
mAffectedBones = input.ReadStructure<BitArray>();
MessageBox.Show(mMotionsDataSize.ToString());
break;
case MC_DataChunk:
bool mAssert = mMotionsDataSize == chunkSize;
MessageBox.Show(String.Format("{0} - assert; {1} - size", mAssert.ToString(), chunkSize.ToString()));
break;
}
}
}
}
}
}