CNiBVHTool Class Reference

#include <NiBVHTool.h>

Inheritance diagram for CNiBVHTool:
Inheritance graph
[legend]
Collaboration diagram for CNiBVHTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CNiBVHTool (void)
virtual ~CNiBVHTool (void)
void free_data (void)
void clear_data (void)
virtual NiJointDatagetJointsData (int frmnum, int fps)
virtual int getPlayBackFPS (void)
virtual BOOL readFile (FILE *fp)
virtual BOOL writeFile (FILE *fp)

Private Member Functions

void init (void)

Private Attributes

CBVHTool * bvh_tool
tList * bvh_name_list

Detailed Description

Definition at line 25 of file NiBVHTool.h.


Constructor & Destructor Documentation

CNiBVHTool ( void   )  [inline]

Definition at line 28 of file NiBVHTool.h.

References CNiBVHTool::init().

00028 { init();}

Here is the call graph for this function:

~CNiBVHTool ( void   )  [virtual]

Definition at line 11 of file NiBVHTool.cpp.

References CNiBVHTool::free_data().

00012 {
00013     DEBUG_INFO("DESTRUCTOR: CNiBVHTool\n");
00014 
00015     free_data();
00016 }

Here is the call graph for this function:


Member Function Documentation

void clear_data ( void   ) 

Reimplemented from CBaseFrameTool.

Definition at line 45 of file NiBVHTool.cpp.

References CNiBVHTool::bvh_tool, and CNiBVHTool::free_data().

Referenced by CNiFileTool::clearFrameData(), CNiBVHTool::free_data(), and CNiBVHTool::readFile().

00046 {
00047     if (bvh_tool!=NULL) bvh_tool->free_data();
00048 
00049     CBaseFrameTool::free_data();
00050 }

Here is the call graph for this function:

Here is the caller graph for this function:

void free_data ( void   ) 

Reimplemented from CBaseFrameTool.

Definition at line 29 of file NiBVHTool.cpp.

References CNiBVHTool::bvh_name_list, CNiBVHTool::bvh_tool, and CNiBVHTool::clear_data().

Referenced by CNiBVHTool::clear_data(), and CNiBVHTool::~CNiBVHTool().

00030 {
00031     //
00032     if (bvh_tool!=NULL) delete(bvh_tool);
00033     bvh_tool = NULL;
00034 
00035     if (bvh_name_list!=NULL) {
00036         del_tList(&bvh_name_list);
00037         bvh_name_list = NULL;
00038     }
00039 
00040     clear_data();
00041 }

Here is the call graph for this function:

Here is the caller graph for this function:

NiJointData * getJointsData ( int  frmnum,
int  fps 
) [virtual]

Reimplemented from CBaseFrameTool.

Definition at line 159 of file NiBVHTool.cpp.

References CBaseFrameTool::clearJointsData(), CBaseFrameTool::exec_time, CBaseFrameTool::frames_num, CBaseFrameTool::framesData, NiJointData::index, NiFrameData::jdat, NiJointData::joint, CBaseFrameTool::joints_num, CBaseFrameTool::jointsData, NiJointData::quat, CBaseFrameTool::start_time, and NiJointData::vect.

00160 { 
00161     if (frmnum<0) return NULL;
00162     
00163     if (fps<=0) fps = 30;
00164     int msec = (int)(1000./fps*frmnum);
00165     if (msec>exec_time) return NULL;
00166 
00167     unsigned int f;
00168     double t = 0.0;
00169 
00170     for (f=1; f<frames_num; f++) {
00171         if (framesData[f].msec >= msec + start_time) {
00172             t = (float)(msec - framesData[f-1].msec)/(float)(framesData[f].msec - framesData[f-1].msec);
00173             break;
00174         }
00175     }
00176     if (f>=frames_num) return NULL;
00177 
00178     //
00179     clearJointsData(joints_num);
00180 
00181     NiJointData* jdat1 = framesData[f-1].jdat;
00182     NiJointData* jdat2 = framesData[f].jdat;
00183 
00184     for (int j=0; j<joints_num; j++) {
00185         jointsData[j].joint = jdat1[j].joint;
00186         jointsData[j].index = frmnum;
00187         jointsData[j].vect  = BSplineInterp4 (jdat1[j].vect, jdat2[j].vect, t);
00188         jointsData[j].quat  = SlerpQuaternion(jdat1[j].quat, jdat2[j].quat, t);
00189     }
00190 
00191     return jointsData;
00192 }

Here is the call graph for this function:

int getPlayBackFPS ( void   )  [virtual]

Reimplemented from CBaseFrameTool.

Definition at line 147 of file NiBVHTool.cpp.

References CNiBVHTool::bvh_tool.

Referenced by CNiFileTool::readBVHFile().

00148 {
00149     if (bvh_tool->framepsec<=0) {
00150         if (bvh_tool->frame_time!=0.0) bvh_tool->framepsec = (int)(1.0/bvh_tool->frame_time);
00151         else                           bvh_tool->framepsec = 30;
00152     }
00153 
00154     return bvh_tool->framepsec;
00155 }

Here is the caller graph for this function:

void init ( void   )  [private]

Definition at line 20 of file NiBVHTool.cpp.

References CNiBVHTool::bvh_name_list, CNiBVHTool::bvh_tool, and jbxwl::setBVHJointName().

Referenced by CNiBVHTool::CNiBVHTool().

00021 {
00022     bvh_tool = new CBVHTool();
00023 
00024     bvh_name_list = setBVHJointName();
00025 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL readFile ( FILE *  fp  )  [virtual]

Reimplemented from CBaseFrameTool.

Definition at line 58 of file NiBVHTool.cpp.

References jbxwl::addBVHJointName(), BVH_ADD_JOINTNAME_TXT, CNiBVHTool::bvh_name_list, CNiBVHTool::bvh_tool, jbxwl::BVHJoint2NiJointNum(), CNiBVHTool::clear_data(), CBaseFrameTool::clearJointsData(), CBaseFrameTool::exec_time, CBaseFrameTool::frames_num, CBaseFrameTool::framesData, NiFrameData::frmn, NiJointData::index, NiFrameData::jdat, NiFrameData::jnum, NiJointData::joint, CBaseFrameTool::joints_num, CBaseFrameTool::jointsData, jbxwl::makeFramesData(), NiFrameData::msec, CBaseFrameTool::posVect, NiJointData::quat, CBaseFrameTool::rotQuat, CBaseFrameTool::start_time, CBaseFrameTool::stop_time, and NiJointData::vect.

Referenced by CNiFileTool::readBVHFile().

00059 {
00060     if (fp==NULL || bvh_tool==NULL) return FALSE;
00061 
00062     clear_data();
00063 
00064     bvh_tool->readBVH(fp);
00065     if (bvh_tool->state!=0) return FALSE;
00066 
00067     //
00068     joints_num = bvh_tool->joint_num;
00069     if (jointsData!=NULL) ::free(jointsData);
00070     jointsData = (NiJointData*)malloc(sizeof(NiJointData)*joints_num);
00071     if (jointsData==NULL) {
00072         clear_data();
00073         return FALSE;
00074     }
00075     clearJointsData(joints_num);
00076     
00077     frames_num = bvh_tool->frame_num;
00078     framesData = makeFramesData(frames_num, joints_num, NULL);
00079     if (framesData==NULL) {
00080         clear_data();
00081         return FALSE;
00082     }
00083 
00084     //
00085     tList* namelist = addBVHJointName(BVH_ADD_JOINTNAME_TXT, bvh_name_list);
00086     
00087     //
00088     for (unsigned int i=0; i<frames_num; i++) {
00089         framesData[i].frmn = (int)i;                                // フレーム番号
00090         framesData[i].msec = (int)(bvh_tool->frame_time*i*1000);    // フレーム時間 ms
00091         framesData[i].jnum = joints_num;                            // Joint の数
00092 
00093         posVect = bvh_tool->getPosData(i);
00094         rotQuat = bvh_tool->getQuaternion(i);
00095 
00096         NiJointData* jdata = framesData[i].jdat;
00097         for (int j=0; j<bvh_tool->joint_num; j++) {
00098             jdata[j].joint  = BVHJoint2NiJointNum(namelist, bvh_tool->joint_name[j]);
00099             jdata[j].index  = i;
00100             jdata[j].vect.x = posVect[j].z;
00101             jdata[j].vect.y = posVect[j].x;
00102             jdata[j].vect.z = posVect[j].y;
00103             jdata[j].vect.c = 1.0;
00104             jdata[j].quat   = rotQuat[j];
00105             jdata[j].quat.c = 1.0;
00106         }
00107 
00108         //
00109         free(posVect);
00110         free(rotQuat);
00111         posVect = NULL;
00112         rotQuat = NULL;
00113     }
00114 
00115     /*
00116     tList* pp = namelist;
00117     while(pp!=NULL) {
00118         DEBUG_INFO("%d => %s\n", pp->ldat.id, pp->ldat.key.buf);
00119         pp = pp->next;
00120     }*/
00121 
00122     //
00123     start_time = framesData[0].msec;
00124     stop_time  = framesData[frames_num-1].msec;
00125     exec_time  = stop_time - start_time;
00126 
00127     del_tList(&namelist);
00128 
00129     return TRUE;
00130 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL writeFile ( FILE *  fp  )  [virtual]

Reimplemented from CBaseFrameTool.

Definition at line 134 of file NiBVHTool.cpp.

References CNiBVHTool::bvh_tool.

00135 {
00136     BOOL ret = FALSE;
00137 
00138     if (bvh_tool!=NULL) {
00139         ret = bvh_tool->printBVH(fp);
00140     }
00141 
00142     return ret;
00143 }


Member Data Documentation

tList* bvh_name_list [private]

Definition at line 46 of file NiBVHTool.h.

Referenced by CNiBVHTool::free_data(), CNiBVHTool::init(), and CNiBVHTool::readFile().

CBVHTool* bvh_tool [private]

The documentation for this class was generated from the following files:

Generated on 15 Nov 2023 for JunkBox_Win_Lib by  doxygen 1.6.1