source: proiecte/SIMEO/Simeo/src/SimeoGui/GL_ShapeDrawer.h @ 167

Last change on this file since 167 was 167, checked in by (none), 14 years ago

Simeo: added final project and also older proof of concept code.

We used Git for version control, so look at the Git repo
in SIMEO/Simeo/ for more info.

File size: 2.6 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15#ifndef GL_SHAPE_DRAWER_H
16#define GL_SHAPE_DRAWER_H
17
18class btCollisionShape;
19class btShapeHull;
20#include "LinearMath/btAlignedObjectArray.h"
21#include "LinearMath/btVector3.h"
22
23#include "BulletCollision/CollisionShapes/btShapeHull.h"
24
25/// OpenGL shape drawing
26class GL_ShapeDrawer
27{
28protected:
29        struct ShapeCache
30        {
31        struct Edge { btVector3 n[2];int v[2]; };
32        ShapeCache(btConvexShape* s) : m_shapehull(s) {}
33        btShapeHull                                     m_shapehull;
34        btAlignedObjectArray<Edge>      m_edges;
35        };
36        //clean-up memory of dynamically created shape hulls
37        btAlignedObjectArray<ShapeCache*>       m_shapecaches;
38        unsigned int                                            m_texturehandle;
39        bool                                                            m_textureenabled;
40        bool                                                            m_textureinitialized;
41       
42
43        ShapeCache*                                                     cache(btConvexShape*);
44
45public:
46                GL_ShapeDrawer();
47
48                virtual ~GL_ShapeDrawer();
49
50                ///drawOpenGL might allocate temporary memoty, stores pointer in shape userpointer
51                virtual void            drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int       debugMode,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax);
52                virtual void            drawShadow(btScalar* m, const btVector3& extrusion,const btCollisionShape* shape,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax);
53               
54                bool            enableTexture(bool enable) { bool p=m_textureenabled;m_textureenabled=enable;return(p); }
55                bool            hasTextureEnabled() const
56                {
57                        return m_textureenabled;
58                }
59               
60                static void             drawCylinder(float radius,float halfHeight, int upAxis);
61                void                    drawSphere(btScalar r, int lats, int longs);
62                static void             drawCoordSystem();
63               
64};
65
66void OGL_displaylist_register_shape(btCollisionShape * shape);
67void OGL_displaylist_clean();
68
69#endif //GL_SHAPE_DRAWER_H
70
Note: See TracBrowser for help on using the repository browser.