Panda3D
 All Classes Functions Variables Enumerations
physxCapsuleController.cxx
00001 // Filename: physxCapsuleController.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 "physxCapsuleController.h"
00016 
00017 TypeHandle PhysxCapsuleController::_type_handle;
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: PhysxCapsuleController::link
00021 //       Access: Public
00022 //  Description: 
00023 ////////////////////////////////////////////////////////////////////
00024 void PhysxCapsuleController::
00025 link(NxController *controllerPtr) {
00026 
00027   nassertv(controllerPtr->getType() == NX_CONTROLLER_CAPSULE);
00028 
00029   // Link self
00030   _ptr = (NxCapsuleController *)controllerPtr;
00031   _error_type = ET_ok;
00032 
00033   PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
00034   scene->_controllers.add(this);
00035 
00036   // Link actor
00037   PT(PhysxActor) actor = new PhysxActor();
00038   actor->link(_ptr->getActor());
00039   actor->link_controller(this);
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: PhysxCapsuleController::unlink
00044 //       Access: Public
00045 //  Description: 
00046 ////////////////////////////////////////////////////////////////////
00047 void PhysxCapsuleController::
00048 unlink() {
00049 
00050   // Unlink actor
00051   PT(PhysxActor) actor = (PhysxActor *)ptr()->getActor()->userData;
00052   actor->unlink();
00053 
00054   // Unlink self
00055   _error_type = ET_released;
00056 
00057   PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
00058   scene->_controllers.remove(this);
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: PhysxCapsuleController::set_radius
00063 //       Access: Published
00064 //  Description: Resets the controller's radius.
00065 ////////////////////////////////////////////////////////////////////
00066 void PhysxCapsuleController::
00067 set_radius(float radius) {
00068 
00069   nassertv(_error_type == ET_ok);
00070   _ptr->setRadius(radius);
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: PhysxCapsuleController::set_height
00075 //       Access: Published
00076 //  Description: Resets the controller's height.
00077 ////////////////////////////////////////////////////////////////////
00078 void PhysxCapsuleController::
00079 set_height(float height) {
00080 
00081   nassertv(_error_type == ET_ok);
00082   _ptr->setHeight(height);
00083 }
00084 
00085 ////////////////////////////////////////////////////////////////////
00086 //     Function: PhysxCapsuleController::get_radius
00087 //       Access: Published
00088 //  Description: Returns the controller's radius.
00089 ////////////////////////////////////////////////////////////////////
00090 float PhysxCapsuleController::
00091 get_radius() const {
00092 
00093   nassertr(_error_type == ET_ok, 0.0f);
00094   return _ptr->getRadius();
00095 }
00096 
00097 ////////////////////////////////////////////////////////////////////
00098 //     Function: PhysxCapsuleController::get_height
00099 //       Access: Published
00100 //  Description: Returns the controller's height.
00101 ////////////////////////////////////////////////////////////////////
00102 float PhysxCapsuleController::
00103 get_height() const {
00104 
00105   nassertr(_error_type == ET_ok, 0.0f);
00106   return _ptr->getHeight();
00107 }
00108 
 All Classes Functions Variables Enumerations