00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "config_ode.h"
00016 #include "odeGeom.h"
00017
00018
00019
00020 TypeHandle OdeGeom::_type_handle;
00021
00022 OdeGeom::
00023 OdeGeom(dGeomID id) :
00024 _id(id) {
00025 odegeom_cat.debug() << get_type() << "(" << _id << ")\n";
00026 }
00027
00028 OdeGeom::
00029 ~OdeGeom() {
00030 odegeom_cat.debug() << "~" << get_type() << "(" << _id << ")\n";
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 void OdeGeom::
00085 destroy() {
00086 if (get_class() == OdeTriMeshGeom::get_geom_class()) {
00087 OdeTriMeshData::unlink_data(_id);
00088 }
00089 dGeomDestroy(_id);
00090 }
00091
00092 OdeSpace OdeGeom::
00093 get_space() const {
00094 return OdeSpace(dGeomGetSpace(_id));
00095 }
00096
00097
00098 void OdeGeom::
00099 write(ostream &out, unsigned int indent) const {
00100 out.width(indent);
00101 out << get_type() << "(id = " << _id << ")";
00102 }
00103
00104 OdeBoxGeom OdeGeom::
00105 convert_to_box() const {
00106 nassertr(_id != 0, OdeBoxGeom((dGeomID)0));
00107 nassertr(get_class() == GC_box, OdeBoxGeom((dGeomID)0));
00108 return OdeBoxGeom(_id);
00109 }
00110
00111 OdeCappedCylinderGeom OdeGeom::
00112 convert_to_capped_cylinder() const {
00113 nassertr(_id != 0, OdeCappedCylinderGeom((dGeomID)0));
00114 nassertr(get_class() == GC_capped_cylinder, OdeCappedCylinderGeom((dGeomID)0));
00115 return OdeCappedCylinderGeom(_id);
00116 }
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 OdeCylinderGeom OdeGeom::
00128 convert_to_cylinder() const {
00129 nassertr(_id != 0, OdeCylinderGeom((dGeomID)0));
00130 nassertr(get_class() == GC_cylinder, OdeCylinderGeom((dGeomID)0));
00131 return OdeCylinderGeom(_id);
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 OdePlaneGeom OdeGeom::
00144 convert_to_plane() const {
00145 nassertr(_id != 0, OdePlaneGeom((dGeomID)0));
00146 nassertr(get_class() == GC_plane, OdePlaneGeom((dGeomID)0));
00147 return OdePlaneGeom(_id);
00148 }
00149
00150 OdeRayGeom OdeGeom::
00151 convert_to_ray() const {
00152 nassertr(_id != 0, OdeRayGeom((dGeomID)0));
00153 nassertr(get_class() == GC_ray, OdeRayGeom((dGeomID)0));
00154 return OdeRayGeom(_id);
00155 }
00156
00157 OdeSphereGeom OdeGeom::
00158 convert_to_sphere() const {
00159 nassertr(_id != 0, OdeSphereGeom((dGeomID)0));
00160 nassertr(get_class() == GC_sphere, OdeSphereGeom((dGeomID)0));
00161 return OdeSphereGeom(_id);
00162 }
00163
00164 OdeTriMeshGeom OdeGeom::
00165 convert_to_tri_mesh() const {
00166 nassertr(_id != 0, OdeTriMeshGeom((dGeomID)0));
00167 nassertr(get_class() == GC_tri_mesh, OdeTriMeshGeom((dGeomID)0));
00168 return OdeTriMeshGeom(_id);
00169 }
00170
00171 OdeSimpleSpace OdeGeom::
00172 convert_to_simple_space() const {
00173 nassertr(_id != 0, OdeSimpleSpace((dSpaceID)0));
00174 nassertr(get_class() == GC_simple_space, OdeSimpleSpace((dSpaceID)0));
00175 return OdeSimpleSpace((dSpaceID)_id);
00176 }
00177
00178 OdeHashSpace OdeGeom::
00179 convert_to_hash_space() const {
00180 nassertr(_id != 0, OdeHashSpace((dSpaceID)0));
00181 nassertr(get_class() == GC_hash_space, OdeHashSpace((dSpaceID)0));
00182 return OdeHashSpace((dSpaceID)_id);
00183 }
00184
00185 OdeQuadTreeSpace OdeGeom::
00186 convert_to_quad_tree_space() const {
00187 nassertr(_id != 0, OdeQuadTreeSpace((dSpaceID)0));
00188 nassertr(get_class() == GC_quad_tree_space, OdeQuadTreeSpace((dSpaceID)0));
00189 return OdeQuadTreeSpace((dSpaceID)_id);
00190 }
00191
00192 OdeGeom::
00193 operator bool () const {
00194 return (_id != NULL);
00195 }
00196