Panda3D
|
00001 // Filename: physxBoxController.cxx 00002 // Created by: enn0x (24Sep09) 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 "physxBoxController.h" 00016 #include "physxManager.h" 00017 00018 TypeHandle PhysxBoxController::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: PhysxBoxController::link 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 void PhysxBoxController:: 00026 link(NxController *controllerPtr) { 00027 00028 nassertv(controllerPtr->getType() == NX_CONTROLLER_BOX); 00029 00030 // Link self 00031 _ptr = (NxBoxController *)controllerPtr; 00032 _error_type = ET_ok; 00033 00034 PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData; 00035 scene->_controllers.add(this); 00036 00037 // Link actor 00038 PT(PhysxActor) actor = new PhysxActor(); 00039 actor->link(_ptr->getActor()); 00040 actor->link_controller(this); 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: PhysxBoxController::unlink 00045 // Access: Public 00046 // Description: 00047 //////////////////////////////////////////////////////////////////// 00048 void PhysxBoxController:: 00049 unlink() { 00050 00051 // Unlink actor 00052 PT(PhysxActor) actor = (PhysxActor *)ptr()->getActor()->userData; 00053 actor->unlink(); 00054 00055 // Unlink self 00056 _error_type = ET_released; 00057 00058 PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData; 00059 scene->_controllers.remove(this); 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: PhysxBoxController::set_extents 00064 // Access: Published 00065 // Description: Sets controller's extents. 00066 //////////////////////////////////////////////////////////////////// 00067 void PhysxBoxController:: 00068 set_extents(const LVector3f &extents) { 00069 00070 nassertv(_error_type == ET_ok); 00071 _ptr->setExtents(PhysxManager::vec3_to_nxVec3(extents)); 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: PhysxBoxController::get_extents 00076 // Access: Published 00077 // Description: Returns controller's extents. 00078 //////////////////////////////////////////////////////////////////// 00079 LVector3f PhysxBoxController:: 00080 get_extents() const { 00081 00082 nassertr(_error_type == ET_ok, LVector3f::zero()); 00083 return PhysxManager::nxVec3_to_vec3(_ptr->getExtents()); 00084 } 00085