Robotics Library  0.7.0
Scene.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_SG_BULLET_SCENE_H
28 #define RL_SG_BULLET_SCENE_H
29 
30 #include <btBulletCollisionCommon.h>
31 
32 #include "../DepthScene.h"
33 #include "../DistanceScene.h"
34 #include "../RaycastScene.h"
35 #include "../SimpleScene.h"
36 
37 namespace rl
38 {
39  namespace sg
40  {
46  namespace bullet
47  {
49  {
50  public:
51  Scene();
52 
53  virtual ~Scene();
54 
55  bool areColliding(::rl::sg::Body* first, ::rl::sg::Body* second);
56 
57  bool areColliding(::rl::sg::Shape* first, ::rl::sg::Shape* second);
58 
60 
61  ::rl::math::Real depth(::rl::sg::Body* first, ::rl::sg::Body* second, ::rl::math::Vector3& point1, ::rl::math::Vector3& point2);
62 
63  ::rl::math::Real depth(::rl::sg::Shape* first, ::rl::sg::Shape* second, ::rl::math::Vector3& point1, ::rl::math::Vector3& point2);
64 
66 
68 
70 
71  bool isColliding();
72 
74 
76 
78 
79  ::btDbvtBroadphase broadphase;
80 
81  ::btDefaultCollisionConfiguration configuration;
82 
83  ::btCollisionDispatcher dispatcher;
84 
85  ::btCollisionWorld world;
86 
87  protected:
88 
89  private:
90  struct ContactResultCallback : public ::btCollisionWorld::ContactResultCallback
91  {
93 
94 #if (BT_BULLET_VERSION < 281)
95  btScalar addSingleResult(::btManifoldPoint& cp, const ::btCollisionObject* colObj0, int partId0, int index0, const ::btCollisionObject* colObj1, int partId1, int index1);
96 #else
97  btScalar addSingleResult(::btManifoldPoint& cp, const ::btCollisionObjectWrapper* colObj0, int partId0, int index0, const ::btCollisionObjectWrapper* colObj1, int partId1, int index1);
98 #endif
99 
100  bool collision;
101 
102  ::btScalar distance;
103 
104  ::btVector3 positionWorldOnA;
105 
106  ::btVector3 positionWorldOnB;
107  };
108 
109  struct RayResultCallback : public ::btCollisionWorld::RayResultCallback
110  {
112 
113  ::btScalar addSingleResult(::btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace);
114 
115  const ::btCollisionShape* collisionShape;
116 
117  ::btVector3 hitPointWorld;
118  };
119  };
120  }
121  }
122 }
123 
124 #endif // RL_SG_BULLET_SCENE_H
rl::sg::bullet::Scene::create
::rl::sg::Model * create()
Definition: Scene.cpp:85
rl::sg::DistanceScene
Definition: DistanceScene.h:44
rl::sg::bullet::Scene::~Scene
virtual ~Scene()
Definition: Scene.cpp:58
rl::sg::bullet::Scene::setMargin
void setMargin(const ::rl::math::Real &margin)
rl::sg::bullet::Scene::RayResultCallback::addSingleResult
::btScalar addSingleResult(::btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
Definition: Scene.cpp:333
rl::sg::bullet::Scene::RayResultCallback::hitPointWorld
::btVector3 hitPointWorld
Definition: Scene.h:117
rl::sg::bullet::Scene::ContactResultCallback::collision
bool collision
Definition: Scene.h:100
rl::math::Vector3
::Eigen::Matrix< Real, 3, 1 > Vector3
Definition: Vector.h:46
rl::sg::RaycastScene
Definition: RaycastScene.h:41
rl::sg::bullet::Scene::ContactResultCallback::positionWorldOnB
::btVector3 positionWorldOnB
Definition: Scene.h:106
rl::sg::Body
Definition: Body.h:45
rl::sg::bullet::Scene
Definition: Scene.h:49
rl::sg::Model
Definition: Model.h:43
rl::sg::bullet::Scene::raycast
::rl::sg::Shape * raycast(const ::rl::math::Vector3 &source, const ::rl::math::Vector3 &target, ::rl::math::Real &distance)
Definition: Scene.cpp:217
rl::sg::bullet::Scene::RayResultCallback
Definition: Scene.h:110
rl::sg::bullet::Scene::RayResultCallback::RayResultCallback
RayResultCallback()
Definition: Scene.cpp:326
rl::sg::bullet::Scene::dispatcher
::btCollisionDispatcher dispatcher
Definition: Scene.h:83
rl::sg::bullet::Scene::broadphase
::btDbvtBroadphase broadphase
Definition: Scene.h:79
rl::sg::bullet::Scene::distance
::rl::math::Real distance(::rl::sg::Shape *first, ::rl::sg::Shape *second, ::rl::math::Vector3 &point1, ::rl::math::Vector3 &point2)
Definition: Scene.cpp:117
rl::sg::bullet::Scene::depth
::rl::math::Real depth(::rl::sg::Body *first, ::rl::sg::Body *second, ::rl::math::Vector3 &point1, ::rl::math::Vector3 &point2)
Definition: Scene.cpp:91
rl::sg::bullet::Scene::areColliding
bool areColliding(::rl::sg::Body *first, ::rl::sg::Body *second)
Definition: Scene.cpp:67
rl::sg::bullet::Scene::configuration
::btDefaultCollisionConfiguration configuration
Definition: Scene.h:81
rl::sg::bullet::Scene::ContactResultCallback::distance
::btScalar distance
Definition: Scene.h:102
rl::sg::bullet::Scene::ContactResultCallback::ContactResultCallback
ContactResultCallback()
Definition: Scene.cpp:299
rl::sg::bullet::Scene::RayResultCallback::collisionShape
const ::btCollisionShape * collisionShape
Definition: Scene.h:115
distance
Scalar distance(const Transform< Scalar, Dim, Mode, Options > &other, const Scalar &weight=1) const
Definition: TransformAddons.h:33
rl::sg::Shape
Definition: Shape.h:41
rl::sg::DepthScene
Definition: DepthScene.h:42
rl::math::Real
double Real
Definition: Real.h:42
rl::sg::bullet::Scene::ContactResultCallback::positionWorldOnA
::btVector3 positionWorldOnA
Definition: Scene.h:104
rl::sg::bullet::Scene::Scene
Scene()
Definition: Scene.cpp:45
rl::sg::bullet::Scene::isColliding
bool isColliding()
Definition: Scene.cpp:201
rl::sg::bullet::Scene::world
::btCollisionWorld world
Definition: Scene.h:85
rl::sg::bullet::Scene::ContactResultCallback
Definition: Scene.h:91
rl::sg::SimpleScene
Definition: SimpleScene.h:41
rl::sg::bullet::Scene::ContactResultCallback::addSingleResult
btScalar addSingleResult(::btManifoldPoint &cp, const ::btCollisionObject *colObj0, int partId0, int index0, const ::btCollisionObject *colObj1, int partId1, int index1)
Definition: Scene.cpp:309
rl
Robotics Library.
Definition: AnalogInput.cpp:30