Panda3D
physxBoxController.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxBoxController.cxx
10  * @author enn0x
11  * @date 2009-09-24
12  */
13 
14 #include "physxBoxController.h"
15 #include "physxManager.h"
16 
17 TypeHandle PhysxBoxController::_type_handle;
18 
19 /**
20  *
21  */
22 void PhysxBoxController::
23 link(NxController *controllerPtr) {
24 
25  nassertv(controllerPtr->getType() == NX_CONTROLLER_BOX);
26 
27  // Link self
28  _ptr = (NxBoxController *)controllerPtr;
29  _error_type = ET_ok;
30 
31  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
32  scene->_controllers.add(this);
33 
34  // Link actor
35  PT(PhysxActor) actor = new PhysxActor();
36  actor->link(_ptr->getActor());
37  actor->link_controller(this);
38 }
39 
40 /**
41  *
42  */
43 void PhysxBoxController::
44 unlink() {
45 
46  // Unlink actor
47  PT(PhysxActor) actor = (PhysxActor *)ptr()->getActor()->userData;
48  actor->unlink();
49 
50  // Unlink self
51  _error_type = ET_released;
52 
53  PhysxScene *scene = (PhysxScene *)_ptr->getActor()->getScene().userData;
54  scene->_controllers.remove(this);
55 }
56 
57 /**
58  * Sets controller's extents.
59  */
61 set_extents(const LVector3f &extents) {
62 
63  nassertv(_error_type == ET_ok);
64  _ptr->setExtents(PhysxManager::vec3_to_nxVec3(extents));
65 }
66 
67 /**
68  * Returns controller's extents.
69  */
70 LVector3f PhysxBoxController::
71 get_extents() const {
72 
73  nassertr(_error_type == ET_ok, LVector3f::zero());
74  return PhysxManager::nxVec3_to_vec3(_ptr->getExtents());
75 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition: physxScene.h:69
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
Actors are the main simulation objects.
Definition: physxActor.h:44
LVector3f get_extents() const
Returns controller's extents.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
void set_extents(const LVector3f &extents)
Sets controller's extents.