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 */
21get_radius() const {
22
23 return _capsule.radius;
24}
25
26/**
27 * Sets the capsule's radius.
28 */
30set_radius(float radius) {
31
32 _capsule.radius = radius;
33}
34
35/**
36 * Returns the start point of the segment.
37 */
39get_p0() const {
40
41 return PhysxManager::nxVec3_to_vec3(_capsule.p0);
42}
43
44/**
45 * Sets the start point of the segment.
46 */
48set_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 */
59get_p1() const {
60
61 return PhysxManager::nxVec3_to_vec3(_capsule.p1);
62}
63
64/**
65 * Sets the end point of the segment.
66 */
68set_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 */
79get_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 */
89compute_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 */
102compute_length() const {
103
104 return _capsule.computeLength();
105}
106
107/**
108 * Computes a point on the segment.
109 */
111compute_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 */
125compute_square_length() const {
126
127 return _capsule.computeSquareLength();
128}
129
130/**
131 * Setup this capsule from origin (start point) and direction vector.
132 */
134set_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),
141}
LPoint3f get_p1() const
Returns the end point of the segment.
void set_radius(float value)
Sets the capsule's radius.
float compute_square_length() const
Returns the square distance from the segment's start point to it's end point.
void set_p1(LPoint3f p)
Sets the end point of the segment.
LPoint3f get_p0() const
Returns the start point of the segment.
float get_radius() const
Returns the capsule's radius.
void set_p0(LPoint3f p)
Sets the start point of the segment.
void compute_point(LPoint3f &p, float t) const
Computes a point on the segment.
LPoint3f get_origin() const
Returns the start point of the segment.
float compute_length() const
Returns the distance from the segment's start point to it's end point.
void set_origin_direction(const LPoint3f &origin, const LVector3f &direction)
Setup this capsule from origin (start point) and direction vector.
void compute_direction(LPoint3f &dir) const
Returns the direction vector from the segment's start point to it's end point.
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 LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
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.