btHfFluidCollisionShape.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.com
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  Experimental Buoyancy fluid demo written by John McCutchan
00016  */
00017 #ifndef BT_HF_FLUID_COLLISION_SHAPE_H
00018 #define BT_HF_FLUID_COLLISION_SHAPE_H
00019 
00020 #include "btHfFluid.h"
00021 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
00022 #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
00023 #include "BulletCollision/CollisionShapes/btConvexInternalShape.h"
00024 #include "BulletCollision/CollisionShapes/btConcaveShape.h"
00025 
00026 #include <iostream>
00027 
00028 class btHfFluidCollisionShape : public btConcaveShape
00029 {
00030 public:
00031   btHfFluid* m_fluid;
00032 
00033   btHfFluidCollisionShape(btHfFluid* backptr) :
00034       btConcaveShape()
00035   {
00036     m_shapeType = HFFLUID_SHAPE_PROXYTYPE;
00037     m_fluid = backptr;
00038   }
00039 
00040   virtual ~btHfFluidCollisionShape()
00041   {
00042 
00043   }
00044 
00045   void processAllTriangles(btTriangleCallback* /*callback*/, const btVector3& /*aabbMin*/,
00046                            const btVector3& /*aabbMax*/) const
00047   {
00048     //not yet
00049     btAssert(0);
00050   }
00051 
00053   virtual void getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
00054   {
00055     /* t should be identity, but better be safe than...fast? */
00056     btVector3 mins;
00057     btVector3 maxs;
00058 
00059     m_fluid->getAabb(mins, maxs);
00060 
00061     const btVector3 crns[] = {t * btVector3(mins.x(), mins.y(), mins.z()), t * btVector3(maxs.x(), mins.y(), mins.z()),
00062                               t * btVector3(maxs.x(), maxs.y(), mins.z()), t * btVector3(mins.x(), maxs.y(), mins.z()),
00063                               t * btVector3(mins.x(), mins.y(), maxs.z()), t * btVector3(maxs.x(), mins.y(), maxs.z()),
00064                               t * btVector3(maxs.x(), maxs.y(), maxs.z()), t * btVector3(mins.x(), maxs.y(), maxs.z())};
00065     aabbMin = aabbMax = crns[0];
00066     for (int i = 1; i < 8; ++i)
00067     {
00068       aabbMin.setMin(crns[i]);
00069       aabbMax.setMax(crns[i]);
00070     }
00071   }
00072 
00073   virtual void setLocalScaling(const btVector3& /*scaling*/)
00074   {
00076     btAssert(0);
00077   }
00078   virtual const btVector3& getLocalScaling() const
00079   {
00080     static const btVector3 dummy(1, 1, 1);
00081     return dummy;
00082   }
00083   virtual void calculateLocalInertia(btScalar /*mass*/, btVector3& /*inertia*/) const
00084   {
00086     btAssert(0);
00087   }
00088   virtual const char* getName() const
00089   {
00090     return "HfFluid";
00091   }
00092 };
00093 
00094 #endif


uwsim
Author(s): Mario Prats
autogenerated on Mon Oct 6 2014 08:24:07