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),
26}
27
28/**
29 * Returns TRUE if the box is valid.
30 */
32is_valid() const {
33
34 return _box.isValid();
35}
36
37/**
38 * Recomputes the box after an arbitrary transform by a 4x4 matrix.
39 */
41rotate(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 */
52set_empty() {
53
54 _box.setEmpty();
55}
56
57/**
58 * Return center of the box.
59 */
60LPoint3f PhysxBox::
61get_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::
70get_extents() const {
71
72 return PhysxManager::nxVec3_to_vec3(_box.GetExtents());
73}
74
75/**
76 * Return the rotation of the box.
77 */
78LMatrix3f PhysxBox::
79get_rot() const {
80
81 return PhysxManager::nxMat33_to_mat3(_box.GetRot());
82}
83
84/**
85 * Sets the center of the box.
86 */
88set_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 */
99set_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 */
110set_rot(LMatrix3f rot) {
111
112 nassertv(!rot.is_nan());
113
114 _box.rot = PhysxManager::mat3_to_nxMat33(rot);
115}
Represents an oriented bounding box, as a center point, extents(radii) and a rotation.
Definition physxBox.h:29
void set_extents(LVector3f extents)
Sets the extents of the box.
Definition physxBox.cxx:99
LPoint3f get_center() const
Return center of the box.
Definition physxBox.cxx:61
LVector3f get_extents() const
Returns the extents (radii) of the box.
Definition physxBox.cxx:70
LMatrix3f get_rot() const
Return the rotation of the box.
Definition physxBox.cxx:79
void set_empty()
Setups an empty box.
Definition physxBox.cxx:52
void rotate(const LMatrix4f &m, PhysxBox &obb) const
Recomputes the box after an arbitrary transform by a 4x4 matrix.
Definition physxBox.cxx:41
void set_center(LPoint3f center)
Sets the center of the box.
Definition physxBox.cxx:88
bool is_valid() const
Returns TRUE if the box is valid.
Definition physxBox.cxx:32
void set_rot(LMatrix3f rot)
Sets the rotation of the box.
Definition physxBox.cxx:110
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
static LMatrix3f nxMat33_to_mat3(const NxMat33 &m)
Converts from NxMat33 to LMatrix3f.
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.