33 #ifndef DART_COLLISION_FCL_MESH_COLLISIONSHAPES_HPP_
34 #define DART_COLLISION_FCL_MESH_COLLISIONSHAPES_HPP_
37 #include <assimp/scene.h>
45 ::fcl::BVHModel<BV>*
createMesh(
float _scaleX,
float _scaleY,
float _scaleZ,
49 ::fcl::BVHModel<BV>* model = new ::fcl::BVHModel<BV>;
52 for (
unsigned int i = 0; i < _mesh->mNumMeshes; i++) {
53 for (
unsigned int j = 0; j < _mesh->mMeshes[i]->mNumFaces; j++) {
55 for (
unsigned int k = 0; k < 3; k++) {
56 const aiVector3D& vertex
57 = _mesh->mMeshes[i]->mVertices[
58 _mesh->mMeshes[i]->mFaces[j].mIndices[k]];
64 model->addTriangle(vertices[0], vertices[1], vertices[2]);
77 {0.135299, -0.461940, -0.135299},
78 {0.000000, -0.461940, -0.191342},
79 {-0.135299, -0.461940, -0.135299},
80 {-0.191342, -0.461940, 0.000000},
81 {-0.135299, -0.461940, 0.135299},
82 {0.000000, -0.461940, 0.191342},
83 {0.135299, -0.461940, 0.135299},
84 {0.191342, -0.461940, 0.000000},
85 {0.250000, -0.353553, -0.250000},
86 {0.000000, -0.353553, -0.353553},
87 {-0.250000, -0.353553, -0.250000},
88 {-0.353553, -0.353553, 0.000000},
89 {-0.250000, -0.353553, 0.250000},
90 {0.000000, -0.353553, 0.353553},
91 {0.250000, -0.353553, 0.250000},
92 {0.353553, -0.353553, 0.000000},
93 {0.326641, -0.191342, -0.326641},
94 {0.000000, -0.191342, -0.461940},
95 {-0.326641, -0.191342, -0.326641},
96 {-0.461940, -0.191342, 0.000000},
97 {-0.326641, -0.191342, 0.326641},
98 {0.000000, -0.191342, 0.461940},
99 {0.326641, -0.191342, 0.326641},
100 {0.461940, -0.191342, 0.000000},
101 {0.353553, 0.000000, -0.353553},
102 {0.000000, 0.000000, -0.500000},
103 {-0.353553, 0.000000, -0.353553},
104 {-0.500000, 0.000000, 0.000000},
105 {-0.353553, 0.000000, 0.353553},
106 {0.000000, 0.000000, 0.500000},
107 {0.353553, 0.000000, 0.353553},
108 {0.500000, 0.000000, 0.000000},
109 {0.326641, 0.191342, -0.326641},
110 {0.000000, 0.191342, -0.461940},
111 {-0.326641, 0.191342, -0.326641},
112 {-0.461940, 0.191342, 0.000000},
113 {-0.326641, 0.191342, 0.326641},
114 {0.000000, 0.191342, 0.461940},
115 {0.326641, 0.191342, 0.326641},
116 {0.461940, 0.191342, 0.000000},
117 {0.250000, 0.353553, -0.250000},
118 {0.000000, 0.353553, -0.353553},
119 {-0.250000, 0.353553, -0.250000},
120 {-0.353553, 0.353553, 0.000000},
121 {-0.250000, 0.353553, 0.250000},
122 {0.000000, 0.353553, 0.353553},
123 {0.250000, 0.353553, 0.250000},
124 {0.353553, 0.353553, 0.000000},
125 {0.135299, 0.461940, -0.135299},
126 {0.000000, 0.461940, -0.191342},
127 {-0.135299, 0.461940, -0.135299},
128 {-0.191342, 0.461940, 0.000000},
129 {-0.135299, 0.461940, 0.135299},
130 {0.000000, 0.461940, 0.191342},
131 {0.135299, 0.461940, 0.135299},
132 {0.191342, 0.461940, 0.000000},
133 {0.000000, -0.500000, 0.000000},
134 {0.000000, 0.500000, 0.000000}
251 ::fcl::BVHModel<BV>* model = new ::fcl::BVHModel<BV>;
255 for (
int i = 0; i < 112; i++) {
257 v[f[i][0]][1] * _sizeY,
258 v[f[i][0]][2] * _sizeZ);
260 v[f[i][1]][1] * _sizeY,
261 v[f[i][1]][2] * _sizeZ);
263 v[f[i][2]][1] * _sizeY,
264 v[f[i][2]][2] * _sizeZ);
268 model->addTriangle(p1, p2, p3);
276 ::fcl::BVHModel<BV>*
createCube(
float _sizeX,
float _sizeY,
float _sizeZ,
296 v[0][0] = v[1][0] = v[2][0] = v[3][0] = -_sizeX / 2;
297 v[4][0] = v[5][0] = v[6][0] = v[7][0] = _sizeX / 2;
298 v[0][1] = v[1][1] = v[4][1] = v[5][1] = -_sizeY / 2;
299 v[2][1] = v[3][1] = v[6][1] = v[7][1] = _sizeY / 2;
300 v[0][2] = v[3][2] = v[4][2] = v[7][2] = -_sizeZ / 2;
301 v[1][2] = v[2][2] = v[5][2] = v[6][2] = _sizeZ / 2;
303 ::fcl::BVHModel<BV>* model = new ::fcl::BVHModel<BV>;
307 for (
int i = 0; i < 6; i++) {
314 model->addTriangle(p1, p2, p3);
321 model->addTriangle(p1, p2, p3);
329 double _height,
int _slices,
int _stacks,
331 const int CACHE_SIZE = 240;
334 float sinCache[CACHE_SIZE];
335 float cosCache[CACHE_SIZE];
339 float sintemp, costemp;
341 float radiusLow, radiusHigh;
343 if (_slices >= CACHE_SIZE) _slices = CACHE_SIZE-1;
345 if (_slices < 2 || _stacks < 1 || _baseRadius < 0.0 || _topRadius < 0.0 ||
354 deltaRadius = _baseRadius - _topRadius;
357 for (i = 0; i < _slices; i++) {
358 angle = 2 * M_PI * i / _slices;
359 sinCache[i] = sin(angle);
360 cosCache[i] = cos(angle);
363 sinCache[_slices] = sinCache[0];
364 cosCache[_slices] = cosCache[0];
366 ::fcl::BVHModel<BV>* model = new ::fcl::BVHModel<BV>;
372 sintemp = sinCache[0];
373 costemp = cosCache[0];
374 radiusLow = _baseRadius;
378 for (i = 1; i < _slices; i++) {
383 model->addTriangle(p1, p2, p3);
385 Eigen::Vector3d v(radiusLow * sinCache[i], radiusLow * cosCache[i], zLow);
389 for (i = 0; i < _slices; i++) {
390 for (j = 0; j < _stacks; j++) {
391 zLow = j * _height / _stacks + zBase;
392 zHigh = (j + 1) * _height / _stacks + zBase;
393 radiusLow = _baseRadius
394 - deltaRadius * (
static_cast<float>(j) / _stacks);
395 radiusHigh = _baseRadius
396 - deltaRadius * (
static_cast<float>(j + 1) / _stacks);
411 model->addTriangle(p1, p2, p3);
412 model->addTriangle(p2, p3, p4);
417 sintemp = sinCache[0];
418 costemp = cosCache[0];
419 radiusLow = _topRadius;
420 zLow = zBase + _height;
423 for (i = 1; i < _slices; i++) {
428 model->addTriangle(p1, p2, p3);
::fcl::Vec3f Vector3
Definition: BackwardCompatibility.hpp:140
dart::collision::fcl::Vector3 transform(const dart::collision::fcl::Transform3 &t, const dart::collision::fcl::Vector3 &v)
Transforms a 3-dim vector by a transform and returns the result.
Definition: BackwardCompatibility.cpp:131
::fcl::Transform3f Transform3
Definition: BackwardCompatibility.hpp:142
::fcl::BVHModel< BV > * createMesh(float _scaleX, float _scaleY, float _scaleZ, const aiScene *_mesh, const dart::collision::fcl::Transform3 &_transform)
Definition: CollisionShapes.hpp:45
::fcl::BVHModel< BV > * createCylinder(double _baseRadius, double _topRadius, double _height, int _slices, int _stacks, const dart::collision::fcl::Transform3 &_transform)
Definition: CollisionShapes.hpp:328
::fcl::BVHModel< BV > * createCube(float _sizeX, float _sizeY, float _sizeZ, const dart::collision::fcl::Transform3 &_transform)
Definition: CollisionShapes.hpp:276
::fcl::BVHModel< BV > * createEllipsoid(float _sizeX, float _sizeY, float _sizeZ, const dart::collision::fcl::Transform3 &_transform)
Definition: CollisionShapes.hpp:73
Definition: BulletCollisionDetector.cpp:63