00001 00002 #ifndef __JBXL_CPP_BVH_TOOL_H_ 00003 #define __JBXL_CPP_BVH_TOOL_H_ 00004 00005 00006 #include "tools++.h" 00007 #include "bvh_tool.h" 00008 #include "Vector.h" 00009 #include "Rotation.h" 00010 00011 00012 // 00013 #define BVH_ERR_FAIL_WRT_MOTION -1 // モーションデータの書き込み失敗 00014 #define BVH_ERR_FAIL_WRT_HIRCHY -2 // ジョイントデータの書き込み失敗 00015 #define BVH_ERR_FAIL_FOPEN -3 // ファイルのオープンに失敗 00016 #define BVH_ERR_INVLD_ARGS -4 // 不正な引数(入力値) 00017 #define BVH_ERR_FAIL_OP -5 // 処理失敗 00018 00019 00020 00021 namespace jbxl { 00022 00023 00024 class CBVHTool : public BVHData 00025 { 00026 public: 00027 CBVHTool(void) { init();} 00028 virtual ~CBVHTool(void); 00029 00030 public: 00031 // 00032 // int joint_num; // ジョイントの数 00033 // int frame_num; // フレームの数 00034 // double frame_time; // フレーム間の時間 sec 00035 // int framepsec; // FPS = (int)(1.0/frame_time) 00036 // int channels; // 総チャンネル数.チャンネル数の合計.モーションデータの数. 00037 // int state; // データの状態 00038 00039 // tTree* hierarchy; // ジョイント部のツリーデータへのポインタ.上記参照. 00040 // double* otion; // MOTION データへのポインタ joint_num*frame_num 00041 // vector* offset; // ジョイントのOFFSET 00042 00043 // Buffer* joint_name; // ジョイントの名前の配列 00044 00045 00046 public: 00047 // 00048 void init(void); 00049 void free_data (void); 00050 void clear_data(void); 00051 00052 void copy_bvh_data(BVHData* bvh); 00053 BVHData setback_bvh_data(void); 00054 00055 BOOL readFile (char* fname); 00056 BOOL writeFile(char* fname); 00057 BOOL writeMultiFile(char* fname, int sec, int space); 00058 00059 BOOL readBVH (FILE* fp); 00060 BOOL printBVH(FILE* fp); 00061 00062 void setHierarchy(tTree* hrchy); 00063 00064 00065 Vector<double>* getPosOffset(void); 00066 Vector<double>* getPosData(int frame); 00067 Quaternion<double>* getQuaternion(int frame); 00068 00069 // Matrix<double>* getRotMatrix(int frame); 00070 00071 // 00072 private: 00073 public: 00074 // 00075 Buffer* joint_name; // ジョイントの名前の配列 00076 int* channel_num; // 各ジョイントのチャンネル数 00077 int* channel_idx; // 各ジョイントのチャンネルの位置(累計) 00078 Buffer flex_joint; // 各ジョイントのチャンネル種別 ex) "PXPYPZRXRYRZRXRYRZ...." 00079 00080 00081 private: 00082 // 00083 void set_offset(void); 00084 void _set_offset(tTree* tree, int* jnum); 00085 00086 void get_bvh_params(void); 00087 void _get_bvh_params(tTree* tree, int** ch, Buffer** jn); 00088 }; 00089 00090 00091 00092 } // namespace 00093 00094 #endif