JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
NiVMDTool.h
Go to the documentation of this file.
1#pragma once
2
3#include "common++.h"
4#include "tools++.h"
5
6#include "NiJointsTool.h"
7
8
9#define VMD_FILE_HD_ID2 "Vocaloid Motion Data 0002"
10
11#define VMD_JOINT_NUM 39
12#define VMD_GRID_UNIT 0.08 // m/grid
13
14#define VMD_FARME_RATE 30 // FPS
15
16
17//
18#define VMD_PARENT 0
19#define VMD_CENTER 1
20#define VMD_LOWER 2
21#define VMD_UPPER 3
22#define VMD_UPPER2 4
23#define VMD_NECK 5
24#define VMD_HEAD 6
25#define VMD_SKULL 7
26
27#define VMD_EYES 8
28#define VMD_L_EYE 9
29#define VMD_R_EYE 10
30#define VMD_L_BUST 11
31#define VMD_R_BUST 12
32
33#define VMD_L_SHLDR 13
34#define VMD_L_ARM 14
35#define VMD_L_ARM_TW 15
36#define VMD_L_ELBOW 16
37#define VMD_L_WRIST_TW 17
38#define VMD_L_WRIST 18
39#define VMD_L_HAND 19
40
41#define VMD_R_SHLDR 20
42#define VMD_R_ARM 21
43#define VMD_R_ARM_TW 22
44#define VMD_R_ELBOW 23
45#define VMD_R_WRIST_TW 24
46#define VMD_R_WRIST 25
47#define VMD_R_HAND 26
48
49#define VMD_L_HIP 27
50#define VMD_L_KNEE 28
51#define VMD_L_ANKLE_IK 29
52#define VMD_L_ANKLE 30
53#define VMD_L_TOE 31
54#define VMD_L_TOE_IK 32
55
56#define VMD_R_HIP 33
57#define VMD_R_KNEE 34
58#define VMD_R_ANKLE_IK 35
59#define VMD_R_ANKLE 36
60#define VMD_R_TOE 37
61#define VMD_R_TOE_IK 38
62
63
64
65namespace jbxwl {
66
67using namespace jbxl;
68
69
70typedef struct _vmd_file_header
71{
72 char header[30];
73 char name[20];
74 unsigned int data_num;
75 //
77
78
79//
80typedef struct _vmd_joint_data
81{
82 char name[15];
83 unsigned long frm_num;
84 double posx;
85 double posy;
86 double posz;
87 double qutx;
88 double quty;
89 double qutz;
90 double qutw;
91 char param[64]; // 補間係数
92 //
94
95
96
97/*
98// 未対応
99typedef struct _vmd_face_frame
100{
101 char name[15];
102 unsigned long num;
103 double value;
104 //
105} VMDFaceFrame;
106*/
107
108
109
111{
112public:
113 CNiVMDTool(void);
114 virtual ~CNiVMDTool(void);
115
116public:
117 void free_data(void);
118 void clear_data(void);
119
120public:
121 virtual unsigned int getFramesNumber(void) { return dmy_frmnum;}
122 virtual NiFrameData * getFramesData(void); // フレームの情報と全フレームへのポインタ
123 virtual NiJointData* getJointsData(int frmnum, int fps); // 動的にフレームデータ(補間)を計算.
124
125 virtual BOOL readFile(FILE* fp);
126
127//
128private:
129 Quaternion<double> A2TPose;
131
132 //
135 unsigned int vmd_datnum;
136
137 //
139 unsigned int dmy_frmnum;
140
141private:
143 VMDJointData readJointData (FILE* fp);
144 VMDJointData* readJointsData(FILE* fp, unsigned int& frmnum);
145
146 NiFrameData* convert2FrameData(VMDJointData* motion_data, unsigned int datnum, unsigned int& frmnum);
147 void calcJointRotation(void);
148 void calcJointIK(int fnum);
149
150 void calcLegIK_CCD(Vector<double>* vect, Vector<double> ik, Quaternion<double>* quat, int rpmax);
151};
152
153
154
155
157//
158
159std::string VMDJointName(int n);
160int VMDJointNum(char* name);
161
162int VMD2NiJointNum(int joint);
163
164
165}
166
167
VMDJointData readJointData(FILE *fp)
Quaternion< double > A2TPose
Definition NiVMDTool.h:129
unsigned int vmd_datnum
Definition NiVMDTool.h:135
VMDFileHeader readFileHeader(FILE *fp)
void calcJointIK(int fnum)
virtual unsigned int getFramesNumber(void)
Definition NiVMDTool.h:121
virtual BOOL readFile(FILE *fp)
virtual NiJointData * getJointsData(int frmnum, int fps)
NiFrameData * dmy_frames
Definition NiVMDTool.h:138
void calcLegIK_CCD(Vector< double > *vect, Vector< double > ik, Quaternion< double > *quat, int rpmax)
VMDFileHeader vmd_header
Definition NiVMDTool.h:133
unsigned int dmy_frmnum
Definition NiVMDTool.h:139
void clear_data(void)
NiFrameData * convert2FrameData(VMDJointData *motion_data, unsigned int datnum, unsigned int &frmnum)
void calcJointRotation(void)
void free_data(void)
virtual ~CNiVMDTool(void)
VMDJointData * readJointsData(FILE *fp, unsigned int &frmnum)
virtual NiFrameData * getFramesData(void)
VMDJointData * vmd_frames
Definition NiVMDTool.h:134
std::string VMDJointName(int n)
Definition NiVMDTool.cpp:46
int VMD2NiJointNum(int joint)
int VMDJointNum(char *name)
Definition NiVMDTool.cpp:64
unsigned int data_num
Definition NiVMDTool.h:74
double qutz
Definition NiVMDTool.h:89
unsigned long frm_num
Definition NiVMDTool.h:83
double posx
Definition NiVMDTool.h:84
double posz
Definition NiVMDTool.h:86
double posy
Definition NiVMDTool.h:85
double quty
Definition NiVMDTool.h:88
double qutx
Definition NiVMDTool.h:87
double qutw
Definition NiVMDTool.h:90