Panda3D

bulletCylinderShape.cxx

00001 // Filename: bulletCylinderShape.cxx
00002 // Created by:  enn0x (17Feb10)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "bulletCylinderShape.h"
00016 
00017 TypeHandle BulletCylinderShape::_type_handle;
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: BulletCylinderShape::Constructor
00021 //       Access: Published
00022 //  Description:
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 //     Function: BulletCylinderShape::Constructor
00049 //       Access: Published
00050 //  Description:
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 //     Function: BulletCylinderShape::ptr
00075 //       Access: Public
00076 //  Description:
00077 ////////////////////////////////////////////////////////////////////
00078 btCollisionShape *BulletCylinderShape::
00079 ptr() const {
00080 
00081   return _shape;
00082 }
00083 
 All Classes Functions Variables Enumerations