-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
brfBody.h
115 lines (77 loc) · 2.59 KB
/
brfBody.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
109
110
111
112
113
114
115
/* OpenBRF -- by marco tarini. Provided under GNU General Public License */
#ifndef BRFBODY_H
#define BRFBODY_H
// Body: collision objects...
#include "brfToken.h"
class BrfBodyPart{
public:
bool Load(FILE*f,char* firstWord=NULL, int verbose=0);
static bool Skip(FILE*f,char* firstWord=NULL);
void Save(FILE*f) const;
typedef enum {MANIFOLD, FACE, CAPSULE, SPHERE, N_TYPE } Type;
Type type;
static char* typeName[N_TYPE];
void Merge(const BrfBodyPart &brf);
// for manyfolds
std::vector<vcg::Point3f> pos;
std::vector< std::vector<int> > face;
int ori ; // +1 or -1
bool IsEmpty() const;
void SetEmpty();
// uses only the last byte of flags
unsigned char GetHitboxFlags() const;
void SetHitboxFlags(unsigned char flags);
void SetAsDefaultHitbox();
void SymmetrizeCapsule(); // makes this capsule simmetric to self(w.r.t. Z)
void SymmetrizeCapsule(const BrfBodyPart& p); // makes this capsule simmetric to p (w.r.t. Z)
// for capsule / spheres
Point3f center;
float radius;
Point3f dir; // for capsule
// for faces: four pos (implicit)
unsigned int flags; // for faces, capsules, spheres only
Box3f bbox;
// list of abstract attributes to be changed for CAPSULES...
typedef enum {RADIUS, LEN_TOP, LEN_BOT, POSX, POSY, POSZ, ROTX, ROTY} Attribute;
void ChangeAttribute(int which, float howMuch);
const char* name() const;
float* GetRotMatrix() const; // rotation matrix for capsules
bool ExportOBJ(FILE *f, int i, int &vc) const;
bool ImportOBJ(FILE *f);
void GuessFromManyfold(); // guess sphere, ect parameter from manufold data
void UpdateBBox();
void InferTypeFromString(char* str);
void Flip();
void Transform(float * m);
void MakeQuadDominant();
void Scale(float f);
private:
Point3f Baricenter() const;
};
class BrfBody
{
public:
BrfBody();
static int tokenIndex(){return BODY;}
char name[255];
bool Load(FILE*f, int verbose=0);
bool Skip(FILE*f);
void Save(FILE*f) const;
void Flip();
void Transform(float * m);
bool Merge(const BrfBody &brf);
std::vector<BrfBodyPart> part;
bool IsAnimable() const{return false;}
Box3f bbox;
bool ExportOBJ(const char *fn) const;
bool ImportOBJ(const char *fn);
void MakeQuadDominant();
void UpdateBBox();
void Scale(float f);
// for hitbox support: set and restore the skeleton name
char* GetOriginalSkeletonName() const;
void SetOriginalSkeletonName(const char*);
const char* GetLikelyMeshName() const;
private:
};
#endif // BRFBODY_H