Panda3D
 All Classes Functions Variables Enumerations
physxPlane.cxx
00001 // Filename: physxPlane.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 "physxPlane.h"
00016 #include "physxManager.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: PhysxPlane::distance
00020 //       Access: Published
00021 //  Description:
00022 ////////////////////////////////////////////////////////////////////
00023 float PhysxPlane::
00024 distance(const LPoint3f &p) const {
00025 
00026   nassertr(!p.is_nan(), 0.0f);
00027 
00028   return _plane.distance(PhysxManager::point3_to_nxVec3(p));
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: PhysxPlane::belongs
00033 //       Access: Published
00034 //  Description:
00035 ////////////////////////////////////////////////////////////////////
00036 bool PhysxPlane::
00037 belongs(const LPoint3f &p) const {
00038 
00039   nassertr(!p.is_nan(), false);
00040 
00041   return _plane.belongs(PhysxManager::point3_to_nxVec3(p));
00042 }
00043 
00044 ////////////////////////////////////////////////////////////////////
00045 //     Function: PhysxPlane::point_in_plane
00046 //       Access: Published
00047 //  Description:
00048 ////////////////////////////////////////////////////////////////////
00049 LPoint3f PhysxPlane::
00050 point_in_plane() const {
00051 
00052   return PhysxManager::nxVec3_to_point3(_plane.pointInPlane());
00053 }
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //     Function: PhysxPlane::project
00057 //       Access: Published
00058 //  Description:
00059 ////////////////////////////////////////////////////////////////////
00060 LPoint3f PhysxPlane::
00061 project(const LPoint3f &p) const {
00062 
00063   nassertr(!p.is_nan(), LPoint3f::zero());
00064 
00065   return PhysxManager::nxVec3_to_point3(_plane.project(PhysxManager::point3_to_nxVec3(p)));
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: PhysxPlane::inverse_transform
00070 //       Access: Published
00071 //  Description:
00072 ////////////////////////////////////////////////////////////////////
00073 void PhysxPlane::
00074 inverse_transform(const LMatrix4f &transform, PhysxPlane &transformed) const {
00075 
00076   nassertv(!transform.is_nan());
00077 
00078   _plane.inverseTransform(PhysxManager::mat4_to_nxMat34(transform), transformed._plane);
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: PhysxPlane::normalize
00083 //       Access: Published
00084 //  Description:
00085 ////////////////////////////////////////////////////////////////////
00086 void PhysxPlane::
00087 normalize() {
00088 
00089   _plane.normalize();
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: PhysxPlane::transform
00094 //       Access: Published
00095 //  Description:
00096 ////////////////////////////////////////////////////////////////////
00097 void PhysxPlane::
00098 transform(const LMatrix4f &transform, PhysxPlane &transformed) const {
00099 
00100   nassertv(!transform.is_nan());
00101 
00102   _plane.transform(PhysxManager::mat4_to_nxMat34(transform), transformed._plane);
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: PhysxPlane::get_d
00107 //       Access: Published
00108 //  Description:
00109 ////////////////////////////////////////////////////////////////////
00110 float PhysxPlane::
00111 get_d() const {
00112 
00113   return _plane.d;
00114 }
00115 
00116 ////////////////////////////////////////////////////////////////////
00117 //     Function: PhysxPlane::set_d
00118 //       Access: Published
00119 //  Description:
00120 ////////////////////////////////////////////////////////////////////
00121 void PhysxPlane::
00122 set_d(float value) {
00123 
00124   _plane.d = value;
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: PhysxPlane::get_normal
00129 //       Access: Published
00130 //  Description:
00131 ////////////////////////////////////////////////////////////////////
00132 LVector3f PhysxPlane::
00133 get_normal() const {
00134 
00135   return PhysxManager::nxVec3_to_vec3(_plane.normal);
00136 }
00137 
00138 ////////////////////////////////////////////////////////////////////
00139 //     Function: PhysxPlane::set_normal
00140 //       Access: Published
00141 //  Description:
00142 ////////////////////////////////////////////////////////////////////
00143 void PhysxPlane::
00144 set_normal(LVector3f normal) {
00145 
00146   nassertv(!normal.is_nan());
00147 
00148   _plane.normal = PhysxManager::vec3_to_nxVec3(normal);
00149 }
00150 
00151 ////////////////////////////////////////////////////////////////////
00152 //     Function: PhysxPlane::set
00153 //       Access: Published
00154 //  Description:
00155 ////////////////////////////////////////////////////////////////////
00156 PhysxPlane PhysxPlane::
00157 set(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &p2) {
00158 
00159   PhysxPlane plane;
00160 
00161   nassertr(!p0.is_nan(), plane);
00162   nassertr(!p1.is_nan(), plane);
00163   nassertr(!p2.is_nan(), plane);
00164 
00165   plane._plane = _plane.set(PhysxManager::point3_to_nxVec3(p0),
00166                             PhysxManager::point3_to_nxVec3(p1),
00167                             PhysxManager::point3_to_nxVec3(p2));
00168   return plane;
00169 }
00170 
00171 ////////////////////////////////////////////////////////////////////
00172 //     Function: PhysxPlane::zero
00173 //       Access: Published
00174 //  Description:
00175 ////////////////////////////////////////////////////////////////////
00176 PhysxPlane PhysxPlane::
00177 zero() {
00178 
00179   PhysxPlane plane;
00180   plane._plane = _plane.zero();
00181   return plane;
00182 }
00183 
 All Classes Functions Variables Enumerations