00001 // 00002 // Copyright 2002 Sony Corporation 00003 // 00004 // Permission to use, copy, modify, and redistribute this software for 00005 // non-commercial use is hereby granted. 00006 // 00007 // This software is provided "as is" without warranty of any kind, 00008 // either expressed or implied, including but not limited to the 00009 // implied warranties of fitness for a particular purpose. 00010 // 00011 00012 #ifndef MTNFile_h_DEFINED 00013 #define MTNFile_h_DEFINED 00014 00015 #include <Types.h> 00016 00017 struct MTNString { 00018 byte length; 00019 char name[1]; 00020 }; 00021 00022 struct MTNKeyFrame { 00023 slongword roll; // 4 bytes 00024 slongword pitch; // 4 bytes 00025 slongword yaw; // 4 bytes 00026 slongword data[1]; // numJoints * 4 bytes 00027 }; 00028 00029 struct MTNSection0 { // 24 bytes (total) 00030 longword sectionNum; // 4 bytes 00031 longword sectionSize; // 4 bytes 00032 longword numSections; // 4 bytes 00033 word majorVersion; // 2 bytes 00034 word minorVersion; // 2 bytes 00035 word numKeyFrames; // 2 bytes 00036 word frameRate; // 2 bytes 00037 longword option; // 4 bytes 00038 }; 00039 00040 struct MTNSection1 { 00041 longword sectionNum; // 4 bytes 00042 longword sectionSize; // 4 bytes 00043 MTNString motion; 00044 // MTNString author; 00045 // MTNString robotDesign; 00046 }; 00047 00048 struct MTNSection2 { 00049 longword sectionNum; 00050 longword sectionSize; 00051 word numJoints; 00052 MTNString locator[1]; 00053 }; 00054 00055 struct MTNSection3 { 00056 longword sectionNum; 00057 longword sectionSize; 00058 longword dataType; 00059 byte keyFrame[1]; 00060 }; 00061 00062 struct MTNFile { 00063 char magic[4]; 00064 MTNSection0 section0; 00065 MTNSection1 section1; 00066 00067 word GetNumJoints(); 00068 word GetNumKeyFrames(); 00069 word GetFrameRate(); 00070 char* GetName(); 00071 char* GetAuthor(); 00072 char* GetRobotDesign(); 00073 char* GetLocator(int index); 00074 MTNString* GetLocator2(int index); 00075 longword GetDataType(); 00076 int GetEachKeyFrameSize(); 00077 int GetTotalKeyFrameSize(); 00078 MTNKeyFrame* GetKeyFrame(int index); 00079 int GetNumInterpolate(int index); 00080 int GetNumInterpolate8ms(int index); 00081 slongword GetJointValue(int index, int jointIndex); 00082 00083 MTNSection2* GetSection2(); 00084 MTNSection3* GetSection3(); 00085 00086 void Print(); 00087 void PrintKeyFrame(int index); 00088 00089 private: 00090 char* string_access(MTNString* mstr); 00091 }; 00092 00093 #endif // MTNFile_h_DEFINED