Panda3D
 All Classes Functions Variables Enumerations
physxRay.cxx
00001 // Filename: physxRay.cxx
00002 // Created by:  enn0x (21Oct09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "physxRay.h"
00016 #include "physxManager.h"
00017 
00018 ////////////////////////////////////////////////////////////////////
00019 //     Function: PhysxRay::set_origin
00020 //       Access: Published
00021 //  Description: Sets the ray origin.
00022 ////////////////////////////////////////////////////////////////////
00023 void PhysxRay::
00024 set_origin(const LPoint3f &origin) {
00025 
00026   nassertv_always(!origin.is_nan());
00027   _ray.orig = PhysxManager::point3_to_nxVec3(origin);
00028 }
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //     Function: PhysxRay::get_origin
00032 //       Access: Published
00033 //  Description: Returns the ray origin
00034 ////////////////////////////////////////////////////////////////////
00035 LPoint3f PhysxRay::
00036 get_origin() const {
00037 
00038   return PhysxManager::nxVec3_to_point3(_ray.orig);
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: PhysxRay::set_direction
00043 //       Access: Published
00044 //  Description: Set the ray direction. It is not required to pass
00045 //               a normalized vector.
00046 ////////////////////////////////////////////////////////////////////
00047 void PhysxRay::
00048 set_direction(const LVector3f &direction) {
00049 
00050   nassertv_always(!direction.is_nan());
00051 
00052   _ray.dir = PhysxManager::vec3_to_nxVec3(direction);
00053   _ray.dir.normalize();
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: PhysxRay::get_direction
00058 //       Access: Published
00059 //  Description: Returns the ray direction.
00060 ////////////////////////////////////////////////////////////////////
00061 LVector3f PhysxRay::
00062 get_direction() const {
00063 
00064   return PhysxManager::nxVec3_to_vec3(_ray.dir);
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: PhysxRay::set_length
00069 //       Access: Published
00070 //  Description: Sets the ray length. If no length is set then the
00071 //               ray will be virtually infinite (the maximum
00072 //               floating point number will be used, e.g.
00073 //               3.40282346639e+038).
00074 ////////////////////////////////////////////////////////////////////
00075 void PhysxRay::
00076 set_length(float length) {
00077 
00078   nassertv_always(length > 0.0f);
00079   _length = length;
00080 }
00081 
00082 ////////////////////////////////////////////////////////////////////
00083 //     Function: PhysxRay::get_length
00084 //       Access: Published
00085 //  Description: Returns the ray length.
00086 ////////////////////////////////////////////////////////////////////
00087 float PhysxRay::
00088 get_length() const {
00089 
00090   return _length;
00091 }
00092 
00093 
 All Classes Functions Variables Enumerations