Panda3D
Loading...
Searching...
No Matches
physxRay.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 physxRay.cxx
10 * @author enn0x
11 * @date 2009-10-21
12 */
13
14#include "physxRay.h"
15#include "physxManager.h"
16
17/**
18 * Sets the ray origin.
19 */
21set_origin(const LPoint3f &origin) {
22
23 nassertv_always(!origin.is_nan());
24 _ray.orig = PhysxManager::point3_to_nxVec3(origin);
25}
26
27/**
28 * Returns the ray origin
29 */
30LPoint3f PhysxRay::
31get_origin() const {
32
33 return PhysxManager::nxVec3_to_point3(_ray.orig);
34}
35
36/**
37 * Set the ray direction. It is not required to pass a normalized vector.
38 */
40set_direction(const LVector3f &direction) {
41
42 nassertv_always(!direction.is_nan());
43
44 _ray.dir = PhysxManager::vec3_to_nxVec3(direction);
45 _ray.dir.normalize();
46}
47
48/**
49 * Returns the ray direction.
50 */
51LVector3f PhysxRay::
52get_direction() const {
53
54 return PhysxManager::nxVec3_to_vec3(_ray.dir);
55}
56
57/**
58 * Sets the ray length. If no length is set then the ray will be virtually
59 * infinite (the maximum floating point number will be used, e.g.
60 * 3.40282346639e+038).
61 */
63set_length(float length) {
64
65 nassertv_always(length > 0.0f);
66 _length = length;
67}
68
69/**
70 * Returns the ray length.
71 */
73get_length() const {
74
75 return _length;
76}
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.
void set_origin(const LPoint3f &origin)
Sets the ray origin.
Definition physxRay.cxx:21
void set_length(float length)
Sets the ray length.
Definition physxRay.cxx:63
LPoint3f get_origin() const
Returns the ray origin.
Definition physxRay.cxx:31
LVector3f get_direction() const
Returns the ray direction.
Definition physxRay.cxx:52
float get_length() const
Returns the ray length.
Definition physxRay.cxx:73
void set_direction(const LVector3f &direction)
Set the ray direction.
Definition physxRay.cxx:40
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.