btConeShape.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 
00016 #ifndef BT_CONE_MINKOWSKI_H
00017 #define BT_CONE_MINKOWSKI_H
00018 
00019 #include "btConvexInternalShape.h"
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
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 //              inertia.x() = scaledmass * (y2+z2);
00067 //              inertia.y() = scaledmass * (x2+z2);
00068 //              inertia.z() = scaledmass * (x2+y2);
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 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


bullet
Author(s): Erwin Coumans, ROS package maintained by Tully Foote
autogenerated on Wed Oct 31 2012 07:54:31