00001 /* 00002 Bullet Continuous Collision Detection and Physics Library 00003 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ 00004 00005 This software is provided 'as-is', without any express or implied warranty. 00006 In no event will the authors be held liable for any damages arising from the use of this software. 00007 Permission is granted to anyone to use this software for any purpose, 00008 including commercial applications, and to alter it and redistribute it freely, 00009 subject to the following restrictions: 00010 00011 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. 00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 00013 3. This notice may not be removed or altered from any source distribution. 00014 */ 00015 00016 #ifndef BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H 00017 #define BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H 00018 00019 00020 class btVertexBufferDescriptor 00021 { 00022 public: 00023 enum BufferTypes 00024 { 00025 CPU_BUFFER, 00026 DX11_BUFFER, 00027 OPENGL_BUFFER 00028 }; 00029 00030 protected: 00031 00032 bool m_hasVertexPositions; 00033 bool m_hasNormals; 00034 00035 int m_vertexOffset; 00036 int m_vertexStride; 00037 00038 int m_normalOffset; 00039 int m_normalStride; 00040 00041 public: 00042 btVertexBufferDescriptor() 00043 { 00044 m_hasVertexPositions = false; 00045 m_hasNormals = false; 00046 m_vertexOffset = 0; 00047 m_vertexStride = 0; 00048 m_normalOffset = 0; 00049 m_normalStride = 0; 00050 } 00051 00052 virtual ~btVertexBufferDescriptor() 00053 { 00054 00055 } 00056 00057 virtual bool hasVertexPositions() const 00058 { 00059 return m_hasVertexPositions; 00060 } 00061 00062 virtual bool hasNormals() const 00063 { 00064 return m_hasNormals; 00065 } 00066 00070 virtual BufferTypes getBufferType() const = 0; 00071 00075 virtual int getVertexOffset() const 00076 { 00077 return m_vertexOffset; 00078 } 00079 00083 virtual int getVertexStride() const 00084 { 00085 return m_vertexStride; 00086 } 00087 00091 virtual int getNormalOffset() const 00092 { 00093 return m_normalOffset; 00094 } 00095 00099 virtual int getNormalStride() const 00100 { 00101 return m_normalStride; 00102 } 00103 }; 00104 00105 00106 class btCPUVertexBufferDescriptor : public btVertexBufferDescriptor 00107 { 00108 protected: 00109 float *m_basePointer; 00110 00111 public: 00117 btCPUVertexBufferDescriptor( float *basePointer, int vertexOffset, int vertexStride ) 00118 { 00119 m_basePointer = basePointer; 00120 m_vertexOffset = vertexOffset; 00121 m_vertexStride = vertexStride; 00122 m_hasVertexPositions = true; 00123 } 00124 00130 btCPUVertexBufferDescriptor( float *basePointer, int vertexOffset, int vertexStride, int normalOffset, int normalStride ) 00131 { 00132 m_basePointer = basePointer; 00133 00134 m_vertexOffset = vertexOffset; 00135 m_vertexStride = vertexStride; 00136 m_hasVertexPositions = true; 00137 00138 m_normalOffset = normalOffset; 00139 m_normalStride = normalStride; 00140 m_hasNormals = true; 00141 } 00142 00143 virtual ~btCPUVertexBufferDescriptor() 00144 { 00145 00146 } 00147 00151 virtual BufferTypes getBufferType() const 00152 { 00153 return CPU_BUFFER; 00154 } 00155 00159 virtual float *getBasePointer() const 00160 { 00161 return m_basePointer; 00162 } 00163 }; 00164 00165 #endif // #ifndef BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H