-
Notifications
You must be signed in to change notification settings - Fork 1
/
BVH.h
108 lines (82 loc) · 2.9 KB
/
BVH.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef __BVH_H__
#define __BVH_H__
#include <memory.h>
#include <string>
#include <vector>
#include <cassert>
#include <fstream>
#include <iostream>
#include "BVHAxis.h"
#include <BVHJoint.h>
/** @addtogroup BVH
@{
*/
namespace chara {
class BVHJoint;
/** @brief Motion capture skeleton and animation
*/
class BVH
{
friend class chara::BVHJoint;
public:
//! Default constructor
BVH();
//! Destructor
BVH(const std::string& filename, bool enableEndSite=false) { init(filename,enableEndSite); }
~BVH() {}
//! init
void init(const std::string& filename, bool enableEndSite=true);
//! Return the number of frames
int getNumberOfFrame(void) const { return m_numFrames; }
//! Return the dt between 2 frames
float getFrameTime(void) const { return m_frameTime; }
//! Return the root joint
const chara::BVHJoint& getRoot(void) const;
//! Return the root joint Id
int getRootId(void) const { return m_rootId; }
//! Return the number of joint
int getNumberOfJoint(void) const { return (int)m_joints.size(); }
//! Return the i-th joint
chara::BVHJoint& getJoint(int i) { assert(i >= 0); assert(i < (int)m_joints.size()); return m_joints[i]; }
//! Return the i-th joint
const chara::BVHJoint& getJoint(int i) const { assert(i >= 0); assert(i < (int)m_joints.size()); return m_joints[i]; }
//! Return a joint Id fro mhis name, -& if the joint does not exist
int getJointId(const std::string& name) const;
//! Return the i-th joint
chara::BVHJoint& operator[](int i) { return getJoint(i); }
//! Return the i-th joint
const chara::BVHJoint& operator[](int i) const { return getJoint(i); }
//! create and add a joint, return the joint Id of the created joint
int addJoint(const std::string& name, int parentId);
//! Scaling the animation time
void scaleAnimation(float factor);
//! Scaling the skeleton
void scaleSkeleton(float factor);
//! Rotate the BVH
void rotate90(chara::AXIS axis, bool cw);
//! Edit the animation in a multi resolution way
void multiResEditAnimation(const std::vector<float>& coef);
//! dump
friend std::ostream& operator << (std::ostream& os, const BVH& bvh);
protected:
//! Number of frames
int m_numFrames;
//! Time between 2 frames
float m_frameTime;
//! Vector of joint
std::vector<chara::BVHJoint> m_joints;
//! Root Joint
//chara::BVHJoint* m_root;
long unsigned int m_rootId;
//! internal init: recursive on the children
void init(std::ifstream& stream, bool enableEndSite, int id);
//! Return the best end name from it parent e.g. RHand from RWrist
static std::string getEndSiteName(const std::string& parentName);
private:
//! Check if the next word in stream is word
static bool expect(const std::string& word, std::ifstream& stream);
};
} // namespace
/** @}
*/
#endif //__BVH_H__