Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_CONE_MINKOWSKI_H
00017 #define BT_CONE_MINKOWSKI_H
00018
00019 #include "btConvexInternalShape.h"
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00021
00023 ATTRIBUTE_ALIGNED16(class) btConeShape : public btConvexInternalShape
00024
00025 {
00026
00027 btScalar m_sinAngle;
00028 btScalar m_radius;
00029 btScalar m_height;
00030 int m_coneIndices[3];
00031 btVector3 coneLocalSupport(const btVector3& v) const;
00032
00033
00034 public:
00035 BT_DECLARE_ALIGNED_ALLOCATOR();
00036
00037 btConeShape (btScalar radius,btScalar height);
00038
00039 virtual btVector3 localGetSupportingVertex(const btVector3& vec) const;
00040 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const;
00041 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00042
00043 btScalar getRadius() const { return m_radius;}
00044 btScalar getHeight() const { return m_height;}
00045
00046
00047 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const
00048 {
00049 btTransform identity;
00050 identity.setIdentity();
00051 btVector3 aabbMin,aabbMax;
00052 getAabb(identity,aabbMin,aabbMax);
00053
00054 btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
00055
00056 btScalar margin = getMargin();
00057
00058 btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
00059 btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
00060 btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
00061 const btScalar x2 = lx*lx;
00062 const btScalar y2 = ly*ly;
00063 const btScalar z2 = lz*lz;
00064 const btScalar scaledmass = mass * btScalar(0.08333333);
00065
00066 inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
00067
00068
00069
00070
00071 }
00072
00073
00074 virtual const char* getName()const
00075 {
00076 return "Cone";
00077 }
00078
00080 void setConeUpIndex(int upIndex);
00081
00082 int getConeUpIndex() const
00083 {
00084 return m_coneIndices[1];
00085 }
00086
00087 virtual btVector3 getAnisotropicRollingFrictionDirection() const
00088 {
00089 return btVector3 (0,1,0);
00090 }
00091
00092 virtual void setLocalScaling(const btVector3& scaling);
00093
00094 };
00095
00097 class btConeShapeX : public btConeShape
00098 {
00099 public:
00100 btConeShapeX(btScalar radius,btScalar height);
00101
00102 virtual btVector3 getAnisotropicRollingFrictionDirection() const
00103 {
00104 return btVector3 (1,0,0);
00105 }
00106
00107 };
00108
00110 class btConeShapeZ : public btConeShape
00111 {
00112 public:
00113 btConeShapeZ(btScalar radius,btScalar height);
00114
00115 virtual btVector3 getAnisotropicRollingFrictionDirection() const
00116 {
00117 return btVector3 (0,0,1);
00118 }
00119
00120 };
00121 #endif //BT_CONE_MINKOWSKI_H
00122