00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "bulletCylinderShape.h"
00016
00017 TypeHandle BulletCylinderShape::_type_handle;
00018
00019
00020
00021
00022
00023
00024 BulletCylinderShape::
00025 BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) {
00026
00027 btVector3 btHalfExtents = LVecBase3_to_btVector3(half_extents);
00028
00029 switch (up) {
00030 case X_up:
00031 _shape = new btCylinderShapeX(btHalfExtents);
00032 break;
00033 case Y_up:
00034 _shape = new btCylinderShape(btHalfExtents);
00035 break;
00036 case Z_up:
00037 _shape = new btCylinderShapeZ(btHalfExtents);
00038 break;
00039 default:
00040 bullet_cat.error() << "invalid up-axis:" << up << endl;
00041 break;
00042 }
00043
00044 _shape->setUserPointer(this);
00045 }
00046
00047
00048
00049
00050
00051
00052 BulletCylinderShape::
00053 BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) {
00054
00055 switch (up) {
00056 case X_up:
00057 _shape = new btCylinderShapeX(btVector3(0.5 * height, radius, radius));
00058 break;
00059 case Y_up:
00060 _shape = new btCylinderShape(btVector3(radius, 0.5 * height, radius));
00061 break;
00062 case Z_up:
00063 _shape = new btCylinderShapeZ(btVector3(radius, radius, 0.5 * height));
00064 break;
00065 default:
00066 bullet_cat.error() << "invalid up-axis:" << up << endl;
00067 break;
00068 }
00069
00070 _shape->setUserPointer(this);
00071 }
00072
00073
00074
00075
00076
00077
00078 btCollisionShape *BulletCylinderShape::
00079 ptr() const {
00080
00081 return _shape;
00082 }
00083