00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "bulletConvexHullShape.h"
00016
00017 #include "nodePathCollection.h"
00018 #include "geomNode.h"
00019 #include "geomVertexReader.h"
00020
00021 TypeHandle BulletConvexHullShape::_type_handle;
00022
00023
00024
00025
00026
00027
00028 BulletConvexHullShape::
00029 BulletConvexHullShape() {
00030
00031 _shape = new btConvexHullShape(NULL, 0);
00032 _shape->setUserPointer(this);
00033 }
00034
00035
00036
00037
00038
00039
00040 btCollisionShape *BulletConvexHullShape::
00041 ptr() const {
00042
00043 return _shape;
00044 }
00045
00046
00047
00048
00049
00050
00051 void BulletConvexHullShape::
00052 add_point(const LPoint3 &p) {
00053
00054 _shape->addPoint(LVecBase3_to_btVector3(p));
00055 }
00056
00057
00058
00059
00060
00061
00062 void BulletConvexHullShape::
00063 add_array(const PTA_LVecBase3 &points) {
00064
00065 _shape = new btConvexHullShape(NULL, 0);
00066 _shape->setUserPointer(this);
00067
00068 PTA_LVecBase3::const_iterator it;
00069 for (it=points.begin(); it!=points.end(); it++) {
00070 LVecBase3 v = *it;
00071 _shape->addPoint(LVecBase3_to_btVector3(v));
00072 }
00073 }
00074
00075
00076
00077
00078
00079
00080 void BulletConvexHullShape::
00081 add_geom(const Geom *geom) {
00082
00083
00084 pvector<LPoint3> points;
00085
00086 CPT(GeomVertexData) vdata = geom->get_vertex_data();
00087 GeomVertexReader reader = GeomVertexReader(vdata, InternalName::get_vertex());
00088
00089 while (!reader.is_at_end()) {
00090 points.push_back(reader.get_data3());
00091 }
00092
00093
00094 _shape = new btConvexHullShape(NULL, 0);
00095 _shape->setUserPointer(this);
00096
00097 pvector<LPoint3>::const_iterator it;
00098 for (it=points.begin(); it!=points.end(); it++) {
00099 _shape->addPoint(LVecBase3_to_btVector3(*it));
00100 }
00101 }
00102