Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Demos / Raytracer / Raytracer.h
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose, 
8 including commercial applications, and to alter it and redistribute it freely, 
9 subject to the following restrictions:
10
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 #ifndef RAYTRACER_H
16 #define RAYTRACER_H
17
18 #include "GlutDemoApplication.h"
19
20 class btDefaultCollisionConfiguration;
21 class btCollisionDispatcher;
22 class btAxisSweep3;
23 class btCollisionWorld;
24
25 ///Raytracer shows the inner working of the ray casting, using ray tracing rendering into a texture.
26 class Raytracer : public GlutDemoApplication
27 {
28
29         btDefaultCollisionConfiguration*        m_collisionConfiguration;
30         btCollisionDispatcher*  m_dispatcher;
31         btAxisSweep3*   m_overlappingPairCache;
32         btCollisionWorld*       m_collisionWorld;
33         bool    m_initialized;
34         
35         public:
36
37         void    initPhysics();
38
39         virtual ~Raytracer();
40
41         virtual void clientMoveAndDisplay();
42
43         virtual void displayCallback();
44
45         ///worldRaytest performs a ray versus all objects in a collision world, returning true is a hit is found (filling in worldNormal and worldHitPoint)
46         bool    worldRaytest(const btVector3& rayFrom,const btVector3& rayTo,btVector3& worldNormal,btVector3& worldHitPoint);
47
48         ///singleObjectRaytest performs a ray versus one collision shape, returning true is a hit is found (filling in worldNormal and worldHitPoint)
49         bool    singleObjectRaytest(const btVector3& rayFrom,const btVector3& rayTo,btVector3& worldNormal,btVector3& worldHitPoint);
50         
51         ///lowlevelRaytest performs a ray versus convex shape, returning true is a hit is found (filling in worldNormal and worldHitPoint)
52         bool    lowlevelRaytest(const btVector3& rayFrom,const btVector3& rayTo,btVector3& worldNormal,btVector3& worldHitPoint);
53
54         static DemoApplication* Create()
55         {
56                 Raytracer* demo = new Raytracer();
57                 demo->myinit();
58                 demo->initPhysics();
59                 return demo;
60         }       
61 };
62
63 #endif //RAYTRACER_H
64
65