btMultimaterialTriangleMeshShape.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
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 
00017 
00018 #ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
00019 #define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
00020 
00021 #include "btBvhTriangleMeshShape.h"
00022 #include "btMaterial.h"
00023 
00025 class btMultimaterialTriangleMeshShape : public btBvhTriangleMeshShape
00026 {
00027     btAlignedObjectArray <btMaterial*> m_materialList;
00028     int ** m_triangleMaterials;
00029 
00030 public:
00031 
00032         BT_DECLARE_ALIGNED_ALLOCATOR();
00033 
00034     btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
00035     btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
00036         btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
00037         {
00038             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
00039 
00040             const unsigned char *vertexbase;
00041             int numverts;
00042             PHY_ScalarType type;
00043             int stride;
00044             const unsigned char *indexbase;
00045             int indexstride;
00046             int numfaces;
00047             PHY_ScalarType indicestype;
00048 
00049             //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
00050 
00051             for(int i = 0; i < meshInterface->getNumSubParts(); i++)
00052             {
00053                 m_meshInterface->getLockedReadOnlyVertexIndexBase(
00054                     &vertexbase,
00055                     numverts,
00056                     type,
00057                     stride,
00058                     &indexbase,
00059                     indexstride,
00060                     numfaces,
00061                     indicestype,
00062                     i);
00063                 //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces, 16));
00064             }
00065         }
00066 
00068         btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true):
00069         btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
00070         {
00071             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
00072 
00073             const unsigned char *vertexbase;
00074             int numverts;
00075             PHY_ScalarType type;
00076             int stride;
00077             const unsigned char *indexbase;
00078             int indexstride;
00079             int numfaces;
00080             PHY_ScalarType indicestype;
00081 
00082             //m_materialLookup = (int**)(btAlignedAlloc(sizeof(int*) * meshInterface->getNumSubParts(), 16));
00083 
00084             for(int i = 0; i < meshInterface->getNumSubParts(); i++)
00085             {
00086                 m_meshInterface->getLockedReadOnlyVertexIndexBase(
00087                     &vertexbase,
00088                     numverts,
00089                     type,
00090                     stride,
00091                     &indexbase,
00092                     indexstride,
00093                     numfaces,
00094                     indicestype,
00095                     i);
00096                 //m_materialLookup[i] = (int*)(btAlignedAlloc(sizeof(int) * numfaces * 2, 16));
00097             }
00098         }
00099         
00100     virtual ~btMultimaterialTriangleMeshShape()
00101     {
00102 /*
00103         for(int i = 0; i < m_meshInterface->getNumSubParts(); i++)
00104         {
00105             btAlignedFree(m_materialValues[i]);
00106             m_materialLookup[i] = NULL;
00107         }
00108         btAlignedFree(m_materialValues);
00109         m_materialLookup = NULL;
00110 */
00111     }
00112         //debugging
00113         virtual const char*     getName()const {return "MULTIMATERIALTRIANGLEMESH";}
00114 
00116     const btMaterial * getMaterialProperties(int partID, int triIndex);
00117 
00118 }
00119 ;
00120 
00121 #endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H

Generated on Mon Feb 15 22:17:05 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1