forked from s-nakaoka/openhrp-plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathModelLoaderUtil.cpp
64 lines (50 loc) · 1.15 KB
/
ModelLoaderUtil.cpp
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
/**
\file
\author Shizuko Hattori
*/
#include "ModelLoaderUtil.h"
#include <iostream>
using namespace std;
using namespace cnoid;
namespace cnoid {
namespace openHRPModelloader {
void setVector3(const Vector3f& v, float* out){
*out = v(0);
*(out+1) = v(1);
*(out+2) = v(2);
}
void setAngleAxis(const AngleAxis& a, DblArray4& out){
const Vector3& v = a.axis();
out[0] = v(0);
out[1] = v(1);
out[2] = v(2);
out[3] = a.angle();
}
void setMatrix3(const Matrix3& m, DblArray4& out){
AngleAxis angleAxis(m);
setAngleAxis(angleAxis, out);
}
void setMatrix3(const Matrix3& m, DblArray9& out){
for(int k=0, i=0; i<3; i++){
for(int j=0; j<3; j++){
out[k++] = m(i,j);
}
}
}
void setTransformMatrix(const Matrix3& m, const Vector3& v, DblArray12& out){
for(int i=0, k=0; i<3; i++){
for (int j=0; j<3; j++){
out[k++] = m(i,j);
}
out[k++] = v(i);
}
}
void setTransformMatrix(const Position& m, DblArray12& out){
for(int p=0, row=0; row < 3; ++row){
for(int col=0; col < 4; ++col){
out[p++] = m(row, col);
}
}
}
}
}