Panda3D

physxBox.cxx

00001 // Filename: physxBox.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 "physxBox.h"
00016 #include "physxManager.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: PhysxBox::Constructor
00020 //       Access: Published
00021 //  Description:
00022 ////////////////////////////////////////////////////////////////////
00023 PhysxBox::
00024 PhysxBox(const LPoint3f &center, const LVector3f &extents, const LMatrix3f &rot) {
00025 
00026   _box = NxBox(PhysxManager::point3_to_nxVec3(center),
00027                PhysxManager::vec3_to_nxVec3(extents),
00028                PhysxManager::mat3_to_nxMat33(rot));
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: PhysxBox::is_valid
00033 //       Access: Published
00034 //  Description: Returns TRUE if the box is valid.
00035 ////////////////////////////////////////////////////////////////////
00036 bool PhysxBox::
00037 is_valid() const {
00038 
00039   return _box.isValid();
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: PhysxBox::rotate
00044 //       Access: Published
00045 //  Description: Recomputes the box after an arbitrary transform by
00046 //               a 4x4 matrix.
00047 ////////////////////////////////////////////////////////////////////
00048 void PhysxBox::
00049 rotate(const LMatrix4f &m, PhysxBox &obb) const {
00050 
00051   nassertv(!m.is_nan());
00052 
00053   _box.rotate(PhysxManager::mat4_to_nxMat34(m), obb._box);
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: PhysxBox::set_empty
00058 //       Access: Published
00059 //  Description: Setups an empty box.
00060 ////////////////////////////////////////////////////////////////////
00061 void PhysxBox::
00062 set_empty() {
00063 
00064   _box.setEmpty();
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: PhysxBox::get_center
00069 //       Access: Published
00070 //  Description: Return center of the box.
00071 ////////////////////////////////////////////////////////////////////
00072 LPoint3f PhysxBox::
00073 get_center() const {
00074 
00075   return PhysxManager::nxVec3_to_point3(_box.GetCenter());
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //     Function: PhysxBox::get_extents
00080 //       Access: Published
00081 //  Description: Returns the extents (radii) of the box.
00082 ////////////////////////////////////////////////////////////////////
00083 LVector3f PhysxBox::
00084 get_extents() const {
00085 
00086   return PhysxManager::nxVec3_to_vec3(_box.GetExtents());
00087 }
00088 
00089 ////////////////////////////////////////////////////////////////////
00090 //     Function: PhysxBox::get_rot
00091 //       Access: Published
00092 //  Description: Return the rotation of the box.
00093 ////////////////////////////////////////////////////////////////////
00094 LMatrix3f PhysxBox::
00095 get_rot() const {
00096 
00097   return PhysxManager::nxMat33_to_mat3(_box.GetRot());
00098 }
00099 
00100 ////////////////////////////////////////////////////////////////////
00101 //     Function: PhysxBox::set_center
00102 //       Access: Published
00103 //  Description: Sets the center of the box.
00104 ////////////////////////////////////////////////////////////////////
00105 void PhysxBox::
00106 set_center(LPoint3f center) {
00107 
00108   nassertv(!center.is_nan());
00109 
00110   _box.center = PhysxManager::vec3_to_nxVec3(center);
00111 }
00112 
00113 ////////////////////////////////////////////////////////////////////
00114 //     Function: PhysxBox::set_extents
00115 //       Access: Published
00116 //  Description: Sets the extents of the box.
00117 ////////////////////////////////////////////////////////////////////
00118 void PhysxBox::
00119 set_extents(LVector3f extents) {
00120 
00121   nassertv(!extents.is_nan());
00122 
00123   _box.extents = PhysxManager::vec3_to_nxVec3(extents);
00124 }
00125 
00126 ////////////////////////////////////////////////////////////////////
00127 //     Function: PhysxBox::set_rot
00128 //       Access: Published
00129 //  Description: Sets the rotation of the box.
00130 ////////////////////////////////////////////////////////////////////
00131 void PhysxBox::
00132 set_rot(LMatrix3f rot) {
00133 
00134   nassertv(!rot.is_nan());
00135 
00136   _box.rot = PhysxManager::mat3_to_nxMat33(rot);
00137 }
00138 
 All Classes Functions Variables Enumerations