Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h @ 1997

Last change on this file since 1997 was 1963, checked in by rgrieder, 16 years ago

Added Bullet physics engine.

  • Property svn:eol-style set to native
File size: 3.9 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
16#ifndef STRIDING_MESHINTERFACE_H
17#define STRIDING_MESHINTERFACE_H
18
19#include "LinearMath/btVector3.h"
20#include "btTriangleCallback.h"
21
22/// PHY_ScalarType enumerates possible scalar types.
23/// See the btStridingMeshInterface for its use
24typedef enum PHY_ScalarType {
25        PHY_FLOAT,
26        PHY_DOUBLE,
27        PHY_INTEGER,
28        PHY_SHORT,
29        PHY_FIXEDPOINT88
30} PHY_ScalarType;
31
32///     The btStridingMeshInterface is the interface class for high performance generic access to triangle meshes, used in combination with btBvhTriangleMeshShape and some other collision shapes.
33/// Using index striding of 3*sizeof(integer) it can use triangle arrays, using index striding of 1*sizeof(integer) it can handle triangle strips.
34/// It allows for sharing graphics and collision meshes. Also it provides locking/unlocking of graphics meshes that are in gpu memory.
35class  btStridingMeshInterface
36{
37        protected:
38       
39                btVector3 m_scaling;
40
41        public:
42                btStridingMeshInterface() :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.))
43                {
44
45                }
46
47                virtual ~btStridingMeshInterface();
48
49
50
51                virtual void    InternalProcessAllTriangles(btInternalTriangleIndexCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
52
53                ///brute force method to calculate aabb
54                void    calculateAabbBruteForce(btVector3& aabbMin,btVector3& aabbMax);
55
56                /// get read and write access to a subpart of a triangle mesh
57                /// this subpart has a continuous array of vertices and indices
58                /// in this way the mesh can be handled as chunks of memory with striding
59                /// very similar to OpenGL vertexarray support
60                /// make a call to unLockVertexBase when the read and write access is finished 
61                virtual void    getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0)=0;
62               
63                virtual void    getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0) const=0;
64       
65                /// unLockVertexBase finishes the access to a subpart of the triangle mesh
66                /// make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished
67                virtual void    unLockVertexBase(int subpart)=0;
68
69                virtual void    unLockReadOnlyVertexBase(int subpart) const=0;
70
71
72                /// getNumSubParts returns the number of seperate subparts
73                /// each subpart has a continuous array of vertices and indices
74                virtual int             getNumSubParts() const=0;
75
76                virtual void    preallocateVertices(int numverts)=0;
77                virtual void    preallocateIndices(int numindices)=0;
78
79                virtual bool    hasPremadeAabb() const { return false; }
80                virtual void    setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const {}
81                virtual void    getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const {}
82
83                const btVector3&        getScaling() const {
84                        return m_scaling;
85                }
86                void    setScaling(const btVector3& scaling)
87                {
88                        m_scaling = scaling;
89                }
90
91       
92
93};
94
95#endif //STRIDING_MESHINTERFACE_H
Note: See TracBrowser for help on using the repository browser.