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 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 btConeShape (btScalar radius,btScalar height);
00036
00037 virtual btVector3 localGetSupportingVertex(const btVector3& vec) const;
00038 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const;
00039 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00040
00041 btScalar getRadius() const { return m_radius;}
00042 btScalar getHeight() const { return m_height;}
00043
00044
00045 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const
00046 {
00047 btTransform identity;
00048 identity.setIdentity();
00049 btVector3 aabbMin,aabbMax;
00050 getAabb(identity,aabbMin,aabbMax);
00051
00052 btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
00053
00054 btScalar margin = getMargin();
00055
00056 btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
00057 btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
00058 btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
00059 const btScalar x2 = lx*lx;
00060 const btScalar y2 = ly*ly;
00061 const btScalar z2 = lz*lz;
00062 const btScalar scaledmass = mass * btScalar(0.08333333);
00063
00064 inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
00065
00066
00067
00068
00069 }
00070
00071
00072 virtual const char* getName()const
00073 {
00074 return "Cone";
00075 }
00076
00078 void setConeUpIndex(int upIndex);
00079
00080 int getConeUpIndex() const
00081 {
00082 return m_coneIndices[1];
00083 }
00084
00085 virtual void setLocalScaling(const btVector3& scaling);
00086
00087 };
00088
00090 class btConeShapeX : public btConeShape
00091 {
00092 public:
00093 btConeShapeX(btScalar radius,btScalar height);
00094 };
00095
00097 class btConeShapeZ : public btConeShape
00098 {
00099 public:
00100 btConeShapeZ(btScalar radius,btScalar height);
00101 };
00102 #endif //BT_CONE_MINKOWSKI_H
00103