Panda3D

Loading...
Searching...
No Matches
physxCapsule.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 physxCapsule.cxx
10 * @author enn0x
11 * @date 2009-10-31
12 */
13
14#include "physxCapsule.h"
15#include "physxManager.h"
16
17/**
18 * Returns the capsule's radius.
19 */
20 float PhysxCapsule::
21 get_radius() const {
22
23 return _capsule.radius;
24}
25
26/**
27 * Sets the capsule's radius.
28 */
29 void PhysxCapsule::
30 set_radius(float radius) {
31
32 _capsule.radius = radius;
33}
34
35/**
36 * Returns the start point of the segment.
37 */
38LPoint3f PhysxCapsule::
39 get_p0() const {
40
41 return PhysxManager::nxVec3_to_vec3(_capsule.p0);
42}
43
44/**
45 * Sets the start point of the segment.
46 */
47 void PhysxCapsule::
48 set_p0(LPoint3f p) {
49
50 nassertv(!p.is_nan());
51
52 _capsule.p0 = PhysxManager::vec3_to_nxVec3(p);
53}
54
55/**
56 * Returns the end point of the segment.
57 */
58LPoint3f PhysxCapsule::
59 get_p1() const {
60
61 return PhysxManager::nxVec3_to_vec3(_capsule.p1);
62}
63
64/**
65 * Sets the end point of the segment.
66 */
67 void PhysxCapsule::
68 set_p1(LPoint3f p) {
69
70 nassertv(!p.is_nan());
71
72 _capsule.p1 = PhysxManager::vec3_to_nxVec3(p);
73}
74
75/**
76 * Returns the start point of the segment.
77 */
78LPoint3f PhysxCapsule::
79 get_origin() const {
80
81 return PhysxManager::nxVec3_to_point3(_capsule.getOrigin());
82}
83
84/**
85 * Returns the direction vector from the segment's start point to it's end
86 * point.
87 */
88 void PhysxCapsule::
89 compute_direction(LPoint3f &dir) const {
90
91 nassertv(!dir.is_nan());
92
93 NxVec3 nDir = PhysxManager::point3_to_nxVec3(dir);
94 _capsule.computeDirection(nDir);
95 PhysxManager::update_point3_from_nxVec3(dir, nDir);
96}
97
98/**
99 * Returns the distance from the segment's start point to it's end point.
100 */
101 float PhysxCapsule::
102 compute_length() const {
103
104 return _capsule.computeLength();
105}
106
107/**
108 * Computes a point on the segment.
109 */
110 void PhysxCapsule::
111 compute_point(LPoint3f &p, float t) const {
112
113 nassertv(!p.is_nan());
114
115 NxVec3 nP = PhysxManager::point3_to_nxVec3(p);
116 _capsule.computePoint(nP, t);
117 PhysxManager::update_point3_from_nxVec3(p, nP);
118}
119
120/**
121 * Returns the square distance from the segment's start point to it's end
122 * point.
123 */
124 float PhysxCapsule::
125 compute_square_length() const {
126
127 return _capsule.computeSquareLength();
128}
129
130/**
131 * Setup this capsule from origin (start point) and direction vector.
132 */
133 void PhysxCapsule::
134 set_origin_direction(const LPoint3f &origin, const LVector3f &direction) {
135
136 nassertv(!origin.is_nan());
137 nassertv(!direction.is_nan());
138
139 _capsule.setOriginDirection(PhysxManager::point3_to_nxVec3(origin),
140 PhysxManager::vec3_to_nxVec3(direction));
141}
PhysxCapsule::get_p1
LPoint3f get_p1() const
Returns the end point of the segment.
Definition physxCapsule.cxx:59
PhysxCapsule::set_radius
void set_radius(float value)
Sets the capsule's radius.
Definition physxCapsule.cxx:30
PhysxCapsule::compute_square_length
float compute_square_length() const
Returns the square distance from the segment's start point to it's end point.
Definition physxCapsule.cxx:125
PhysxCapsule::set_p1
void set_p1(LPoint3f p)
Sets the end point of the segment.
Definition physxCapsule.cxx:68
PhysxCapsule::get_p0
LPoint3f get_p0() const
Returns the start point of the segment.
Definition physxCapsule.cxx:39
PhysxCapsule::get_radius
float get_radius() const
Returns the capsule's radius.
Definition physxCapsule.cxx:21
PhysxCapsule::set_p0
void set_p0(LPoint3f p)
Sets the start point of the segment.
Definition physxCapsule.cxx:48
PhysxCapsule::compute_point
void compute_point(LPoint3f &p, float t) const
Computes a point on the segment.
Definition physxCapsule.cxx:111
PhysxCapsule::get_origin
LPoint3f get_origin() const
Returns the start point of the segment.
Definition physxCapsule.cxx:79
PhysxCapsule::compute_length
float compute_length() const
Returns the distance from the segment's start point to it's end point.
Definition physxCapsule.cxx:102
PhysxCapsule::set_origin_direction
void set_origin_direction(const LPoint3f &origin, const LVector3f &direction)
Setup this capsule from origin (start point) and direction vector.
Definition physxCapsule.cxx:134
PhysxCapsule::compute_direction
void compute_direction(LPoint3f &dir) const
Returns the direction vector from the segment's start point to it's end point.
Definition physxCapsule.cxx:89
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::nxVec3_to_point3
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition physxManager.I:72
PhysxManager::nxVec3_to_vec3
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition physxManager.I:36
physxCapsule.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.