Panda3D
 All Classes Functions Variables Enumerations
physxRay.cxx
1 // Filename: physxRay.cxx
2 // Created by: enn0x (21Oct09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "physxRay.h"
16 #include "physxManager.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: PhysxRay::set_origin
20 // Access: Published
21 // Description: Sets the ray origin.
22 ////////////////////////////////////////////////////////////////////
23 void PhysxRay::
24 set_origin(const LPoint3f &origin) {
25 
26  nassertv_always(!origin.is_nan());
27  _ray.orig = PhysxManager::point3_to_nxVec3(origin);
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: PhysxRay::get_origin
32 // Access: Published
33 // Description: Returns the ray origin
34 ////////////////////////////////////////////////////////////////////
36 get_origin() const {
37 
38  return PhysxManager::nxVec3_to_point3(_ray.orig);
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: PhysxRay::set_direction
43 // Access: Published
44 // Description: Set the ray direction. It is not required to pass
45 // a normalized vector.
46 ////////////////////////////////////////////////////////////////////
47 void PhysxRay::
48 set_direction(const LVector3f &direction) {
49 
50  nassertv_always(!direction.is_nan());
51 
52  _ray.dir = PhysxManager::vec3_to_nxVec3(direction);
53  _ray.dir.normalize();
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: PhysxRay::get_direction
58 // Access: Published
59 // Description: Returns the ray direction.
60 ////////////////////////////////////////////////////////////////////
62 get_direction() const {
63 
64  return PhysxManager::nxVec3_to_vec3(_ray.dir);
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: PhysxRay::set_length
69 // Access: Published
70 // Description: Sets the ray length. If no length is set then the
71 // ray will be virtually infinite (the maximum
72 // floating point number will be used, e.g.
73 // 3.40282346639e+038).
74 ////////////////////////////////////////////////////////////////////
75 void PhysxRay::
76 set_length(float length) {
77 
78  nassertv_always(length > 0.0f);
79  _length = length;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: PhysxRay::get_length
84 // Access: Published
85 // Description: Returns the ray length.
86 ////////////////////////////////////////////////////////////////////
87 float PhysxRay::
88 get_length() const {
89 
90  return _length;
91 }
92 
93 
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:77
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:463
void set_length(float length)
Sets the ray length.
Definition: physxRay.cxx:76
LVector3f get_direction() const
Returns the ray direction.
Definition: physxRay.cxx:62
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:44
float get_length() const
Returns the ray length.
Definition: physxRay.cxx:88
void set_origin(const LPoint3f &origin)
Sets the ray origin.
Definition: physxRay.cxx:24
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:88
LPoint3f get_origin() const
Returns the ray origin.
Definition: physxRay.cxx:36
void set_direction(const LVector3f &direction)
Set the ray direction.
Definition: physxRay.cxx:48