Panda3D
 All Classes Functions Variables Enumerations
physxBoxShape.cxx
00001 // Filename: physxBoxShape.cxx
00002 // Created by:  enn0x (16Sep09)
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 "physxBoxShape.h"
00016 #include "physxBoxShapeDesc.h"
00017 #include "physxManager.h"
00018 
00019 TypeHandle PhysxBoxShape::_type_handle;
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //     Function: PhysxBoxShape::link
00023 //       Access: Public
00024 //  Description: 
00025 ////////////////////////////////////////////////////////////////////
00026 void PhysxBoxShape::
00027 link(NxShape *shapePtr) {
00028 
00029   _ptr = shapePtr->isBox();
00030   _ptr->userData = this;
00031   _error_type = ET_ok;
00032 
00033   set_name(shapePtr->getName());
00034 
00035   PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
00036   actor->_shapes.add(this);
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: PhysxBoxShape::unlink
00041 //       Access: Public
00042 //  Description: 
00043 ////////////////////////////////////////////////////////////////////
00044 void PhysxBoxShape::
00045 unlink() {
00046 
00047   _ptr->userData = NULL;
00048   _error_type = ET_released;
00049 
00050   PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData;
00051   actor->_shapes.remove(this);
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function : PhysxBoxShape::save_to_desc
00056 //       Access : Published
00057 //  Description : Saves the state of the shape object to a 
00058 //                descriptor.
00059 ////////////////////////////////////////////////////////////////////
00060 void PhysxBoxShape::
00061 save_to_desc(PhysxBoxShapeDesc &shapeDesc) const {
00062 
00063   nassertv(_error_type == ET_ok);
00064   _ptr->saveToDesc(shapeDesc._desc);
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: PhysxBoxShape::set_dimensions
00069 //       Access: Published
00070 //  Description: Sets the box dimensions. 
00071 //
00072 //               The dimensions are the 'radii' of the box,
00073 //               meaning 1/2 extents in x dimension, 1/2 extents
00074 //               in y dimension, 1/2 extents in z dimension.
00075 ////////////////////////////////////////////////////////////////////
00076 void PhysxBoxShape::
00077 set_dimensions(const LVector3f &vec) {
00078 
00079   nassertv(_error_type == ET_ok);
00080   _ptr->setDimensions(PhysxManager::vec3_to_nxVec3(vec));
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: PhysxBoxShape::get_dimensions
00085 //       Access: Published
00086 //  Description: Retrieves the dimensions of the box. 
00087 //
00088 //               The dimensions are the 'radii' of the box,
00089 //               meaning 1/2 extents in x dimension, 1/2 extents
00090 //               in y dimension, 1/2 extents in z dimension.
00091 ////////////////////////////////////////////////////////////////////
00092 LVector3f PhysxBoxShape::
00093 get_dimensions() const {
00094 
00095   nassertr(_error_type == ET_ok, LVector3f::zero());
00096   return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions());
00097 }
00098 
 All Classes Functions Variables Enumerations