Panda3D
 All Classes Functions Variables Enumerations
physxSphere.cxx
00001 // Filename: physxSphere.cxx
00002 // Created by:  enn0x (31Oct09)
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 "physxSphere.h"
00016 #include "physxManager.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: PhysxSphere::is_valid
00020 //       Access: Published
00021 //  Description: Returns TRUE if this sphere is valid.
00022 ////////////////////////////////////////////////////////////////////
00023 bool PhysxSphere::
00024 is_valid() const {
00025 
00026   return _sphere.IsValid();
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: PhysxSphere::contains
00031 //       Access: Published
00032 //  Description: Tests if a point is contained within the sphere.
00033 ////////////////////////////////////////////////////////////////////
00034 bool PhysxSphere::
00035 contains(const LPoint3f &p) const {
00036 
00037   nassertr(!p.is_nan(), false);
00038 
00039   return _sphere.Contains(PhysxManager::vec3_to_nxVec3(p));
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: PhysxSphere::contains
00044 //       Access: Published
00045 //  Description: Tests if a sphere is contained within the sphere.
00046 ////////////////////////////////////////////////////////////////////
00047 bool PhysxSphere::
00048 contains(const PhysxSphere &sphere) const {
00049 
00050   return _sphere.Contains(sphere._sphere);
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: PhysxSphere::contains
00055 //       Access: Published
00056 //  Description: Tests if an axis aligned box is contained within
00057 //               the sphere. The axis aligned box is defined by the
00058 //               minimum corner and the maximum corner.
00059 ////////////////////////////////////////////////////////////////////
00060 bool PhysxSphere::
00061 contains(const LPoint3f &min, const LPoint3f &max) const {
00062 
00063   nassertr(!min.is_nan(), false);
00064   nassertr(!max.is_nan(), false);
00065 
00066   return _sphere.Contains(PhysxManager::vec3_to_nxVec3(min), 
00067                           PhysxManager::vec3_to_nxVec3(max));
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: PhysxSphere::intersect
00072 //       Access: Published
00073 //  Description: Tests if the sphere intersects another sphere.
00074 //               Returns TRUE if the spheres overlap.
00075 ////////////////////////////////////////////////////////////////////
00076 bool PhysxSphere::
00077 intersect(const PhysxSphere &sphere) const {
00078 
00079   return _sphere.Intersect(sphere._sphere);
00080 }
00081 
00082 ////////////////////////////////////////////////////////////////////
00083 //     Function: PhysxSphere::get_center
00084 //       Access: Published
00085 //  Description: Returns the center of the sphere.
00086 ////////////////////////////////////////////////////////////////////
00087 LPoint3f PhysxSphere::
00088 get_center() const {
00089 
00090   return PhysxManager::nxVec3_to_vec3(_sphere.center);
00091 }
00092 
00093 ////////////////////////////////////////////////////////////////////
00094 //     Function: PhysxSphere::set_center
00095 //       Access: Published
00096 //  Description: Sets the center of the sphere.
00097 ////////////////////////////////////////////////////////////////////
00098 void PhysxSphere::
00099 set_center(LPoint3f center) {
00100 
00101   nassertv(!center.is_nan());
00102 
00103   _sphere.center = PhysxManager::vec3_to_nxVec3(center);
00104 }
00105 
00106 ////////////////////////////////////////////////////////////////////
00107 //     Function: PhysxSphere::get_radius
00108 //       Access: Published
00109 //  Description: Returns the sphere's radius.
00110 ////////////////////////////////////////////////////////////////////
00111 float PhysxSphere::
00112 get_radius() const {
00113 
00114   return _sphere.radius;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: PhysxSphere::set_radius
00119 //       Access: Published
00120 //  Description: Sets the sphere's radius.
00121 ////////////////////////////////////////////////////////////////////
00122 void PhysxSphere::
00123 set_radius(float radius) {
00124 
00125   _sphere.radius = radius;
00126 }
00127 
 All Classes Functions Variables Enumerations