Panda3D

Loading...
Searching...
No Matches
physxBox.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 physxBox.cxx
10 * @author enn0x
11 * @date 2009-10-31
12 */
13
14#include "physxBox.h"
15#include "physxManager.h"
16
17/**
18 *
19 */
20PhysxBox::
21PhysxBox(const LPoint3f &center, const LVector3f &extents, const LMatrix3f &rot) {
22
23 _box = NxBox(PhysxManager::point3_to_nxVec3(center),
24 PhysxManager::vec3_to_nxVec3(extents),
25 PhysxManager::mat3_to_nxMat33(rot));
26}
27
28/**
29 * Returns TRUE if the box is valid.
30 */
31 bool PhysxBox::
32 is_valid() const {
33
34 return _box.isValid();
35}
36
37/**
38 * Recomputes the box after an arbitrary transform by a 4x4 matrix.
39 */
40 void PhysxBox::
41 rotate(const LMatrix4f &m, PhysxBox &obb) const {
42
43 nassertv(!m.is_nan());
44
45 _box.rotate(PhysxManager::mat4_to_nxMat34(m), obb._box);
46}
47
48/**
49 * Setups an empty box.
50 */
51 void PhysxBox::
52 set_empty() {
53
54 _box.setEmpty();
55}
56
57/**
58 * Return center of the box.
59 */
60LPoint3f PhysxBox::
61 get_center() const {
62
63 return PhysxManager::nxVec3_to_point3(_box.GetCenter());
64}
65
66/**
67 * Returns the extents (radii) of the box.
68 */
69LVector3f PhysxBox::
70 get_extents() const {
71
72 return PhysxManager::nxVec3_to_vec3(_box.GetExtents());
73}
74
75/**
76 * Return the rotation of the box.
77 */
78LMatrix3f PhysxBox::
79 get_rot() const {
80
81 return PhysxManager::nxMat33_to_mat3(_box.GetRot());
82}
83
84/**
85 * Sets the center of the box.
86 */
87 void PhysxBox::
88 set_center(LPoint3f center) {
89
90 nassertv(!center.is_nan());
91
92 _box.center = PhysxManager::vec3_to_nxVec3(center);
93}
94
95/**
96 * Sets the extents of the box.
97 */
98 void PhysxBox::
99 set_extents(LVector3f extents) {
100
101 nassertv(!extents.is_nan());
102
103 _box.extents = PhysxManager::vec3_to_nxVec3(extents);
104}
105
106/**
107 * Sets the rotation of the box.
108 */
109 void PhysxBox::
110 set_rot(LMatrix3f rot) {
111
112 nassertv(!rot.is_nan());
113
114 _box.rot = PhysxManager::mat3_to_nxMat33(rot);
115}
PhysxBox::set_extents
void set_extents(LVector3f extents)
Sets the extents of the box.
Definition physxBox.cxx:99
PhysxBox::get_center
LPoint3f get_center() const
Return center of the box.
Definition physxBox.cxx:61
PhysxBox::get_extents
LVector3f get_extents() const
Returns the extents (radii) of the box.
Definition physxBox.cxx:70
PhysxBox::get_rot
LMatrix3f get_rot() const
Return the rotation of the box.
Definition physxBox.cxx:79
PhysxBox::set_empty
void set_empty()
Setups an empty box.
Definition physxBox.cxx:52
PhysxBox::rotate
void rotate(const LMatrix4f &m, PhysxBox &obb) const
Recomputes the box after an arbitrary transform by a 4x4 matrix.
Definition physxBox.cxx:41
PhysxBox::set_center
void set_center(LPoint3f center)
Sets the center of the box.
Definition physxBox.cxx:88
PhysxBox::is_valid
bool is_valid() const
Returns TRUE if the box is valid.
Definition physxBox.cxx:32
PhysxBox::set_rot
void set_rot(LMatrix3f rot)
Sets the rotation of the box.
Definition physxBox.cxx:110
PhysxManager::vec3_to_nxVec3
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition physxManager.I:27
PhysxManager::point3_to_nxVec3
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition physxManager.I:63
PhysxManager::mat4_to_nxMat34
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition physxManager.I:119
PhysxManager::nxVec3_to_point3
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition physxManager.I:72
PhysxManager::nxMat33_to_mat3
static LMatrix3f nxMat33_to_mat3(const NxMat33 &m)
Converts from NxMat33 to LMatrix3f.
Definition physxManager.I:150
PhysxManager::mat3_to_nxMat33
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition physxManager.I:139
PhysxManager::nxVec3_to_vec3
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition physxManager.I:36
physxBox.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.