00001 // Filename: physxCapsule.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 "physxCapsule.h" 00016 #include "physxManager.h" 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function: PhysxCapsule::get_radius 00020 // Access: Published 00021 // Description: Returns the capsule's radius. 00022 //////////////////////////////////////////////////////////////////// 00023 float PhysxCapsule:: 00024 get_radius() const { 00025 00026 return _capsule.radius; 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: PhysxCapsule::set_radius 00031 // Access: Published 00032 // Description: Sets the capsule's radius. 00033 //////////////////////////////////////////////////////////////////// 00034 void PhysxCapsule:: 00035 set_radius(float radius) { 00036 00037 _capsule.radius = radius; 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: PhysxCapsule::get_p0 00042 // Access: Published 00043 // Description: Returns the start point of the segment. 00044 //////////////////////////////////////////////////////////////////// 00045 LPoint3f PhysxCapsule:: 00046 get_p0() const { 00047 00048 return PhysxManager::nxVec3_to_vec3(_capsule.p0); 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: PhysxCapsule::set_p0 00053 // Access: Published 00054 // Description: Sets the start point of the segment. 00055 //////////////////////////////////////////////////////////////////// 00056 void PhysxCapsule:: 00057 set_p0(LPoint3f p) { 00058 00059 nassertv(!p.is_nan()); 00060 00061 _capsule.p0 = PhysxManager::vec3_to_nxVec3(p); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: PhysxCapsule::get_p1 00066 // Access: Published 00067 // Description: Returns the end point of the segment. 00068 //////////////////////////////////////////////////////////////////// 00069 LPoint3f PhysxCapsule:: 00070 get_p1() const { 00071 00072 return PhysxManager::nxVec3_to_vec3(_capsule.p1); 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function: PhysxCapsule::set_p1 00077 // Access: Published 00078 // Description: Sets the end point of the segment. 00079 //////////////////////////////////////////////////////////////////// 00080 void PhysxCapsule:: 00081 set_p1(LPoint3f p) { 00082 00083 nassertv(!p.is_nan()); 00084 00085 _capsule.p1 = PhysxManager::vec3_to_nxVec3(p); 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: PhysxCapsule::get_origin 00090 // Access: Published 00091 // Description: Returns the start point of the segment. 00092 //////////////////////////////////////////////////////////////////// 00093 LPoint3f PhysxCapsule:: 00094 get_origin() const { 00095 00096 return PhysxManager::nxVec3_to_point3(_capsule.getOrigin()); 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: PhysxCapsule::compute_direction 00101 // Access: Published 00102 // Description: Returns the direction vector from the segment's 00103 // start point to it's end point. 00104 //////////////////////////////////////////////////////////////////// 00105 void PhysxCapsule:: 00106 compute_direction(LPoint3f &dir) const { 00107 00108 nassertv(!dir.is_nan()); 00109 00110 NxVec3 nDir = PhysxManager::point3_to_nxVec3(dir); 00111 _capsule.computeDirection(nDir); 00112 PhysxManager::update_point3_from_nxVec3(dir, nDir); 00113 } 00114 00115 //////////////////////////////////////////////////////////////////// 00116 // Function: PhysxCapsule::compute_length 00117 // Access: Published 00118 // Description: Returns the distance from the segment's start point 00119 // to it's end point. 00120 //////////////////////////////////////////////////////////////////// 00121 float PhysxCapsule:: 00122 compute_length() const { 00123 00124 return _capsule.computeLength(); 00125 } 00126 00127 //////////////////////////////////////////////////////////////////// 00128 // Function: PhysxCapsule::compute_point 00129 // Access: Published 00130 // Description: Computes a point on the segment. 00131 //////////////////////////////////////////////////////////////////// 00132 void PhysxCapsule:: 00133 compute_point(LPoint3f &p, float t) const { 00134 00135 nassertv(!p.is_nan()); 00136 00137 NxVec3 nP = PhysxManager::point3_to_nxVec3(p); 00138 _capsule.computePoint(nP, t); 00139 PhysxManager::update_point3_from_nxVec3(p, nP); 00140 } 00141 00142 //////////////////////////////////////////////////////////////////// 00143 // Function: PhysxCapsule::compute_square_length 00144 // Access: Published 00145 // Description: Returns the square distance from the segment's 00146 // start point to it's end point. 00147 //////////////////////////////////////////////////////////////////// 00148 float PhysxCapsule:: 00149 compute_square_length() const { 00150 00151 return _capsule.computeSquareLength(); 00152 } 00153 00154 //////////////////////////////////////////////////////////////////// 00155 // Function: PhysxCapsule::set_origin_direction 00156 // Access: Published 00157 // Description: Setup this capsule from origin (start point) and 00158 // direction vector. 00159 //////////////////////////////////////////////////////////////////// 00160 void PhysxCapsule:: 00161 set_origin_direction(const LPoint3f &origin, const LVector3f &direction) { 00162 00163 nassertv(!origin.is_nan()); 00164 nassertv(!direction.is_nan()); 00165 00166 _capsule.setOriginDirection(PhysxManager::point3_to_nxVec3(origin), 00167 PhysxManager::vec3_to_nxVec3(direction)); 00168 } 00169