00001 #ifndef _RBRAY_HXX_
00002 #define _RBRAY_HXX_
00003
00004 #include <rglobals.hxx>
00005 #include <RBase/RVec2.hxx>
00006 #include <RBase/RVec3.hxx>
00007 #include <RBase/RTime.hxx>
00008
00009
00010 namespace RayGina {
00011 namespace CORE {
00012
00013 class RobGeometry;
00014
00015 class CORE_EXPORT RRay {
00016 private:
00017 RVec3r _org;
00018 RVec3r _dir;
00019 RReal _t;
00020 RReal _min_t;
00021 RVec2r _uv;
00022 RobGeometry* _hit;
00023 RTime* _time;
00024 RUInt16 _currThread;
00025 public:
00026
00027 inline RRay() : _org(0.0,0.0,0.0),_dir(0.0,0.0,0.0),_t((RReal)Infinity),_min_t(0.0),_uv(0.0,0.0),_hit(NULL),_currThread(0)
00028 {};
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 inline RRay(RVec3r norg,RVec3r ndir,RReal nt = Infinity,RReal nmin_t = 0.0,RVec2r nuv = RVec2r(0,0),RobGeometry* nhit = NULL,unsigned short ncurrThread = 0) : _org(norg),_dir(ndir),_t(nt),_min_t(nmin_t),_uv(nuv),_hit(nhit),_currThread(ncurrThread)
00049 {};
00050
00051 inline RRay(const RRay &oray) : _org(oray._org),_dir(oray._dir),_t(oray._t),_min_t(oray._min_t),_uv(oray._uv),_hit(oray._hit),_currThread(oray._currThread)
00052 {};
00053
00054 inline RRay(RRay* oray) : _org(oray->_org),_dir(oray->_dir),_t(oray->_t),_min_t(oray->_min_t),_uv(oray->_uv),_hit(oray->_hit),_currThread(oray->_currThread)
00055 {};
00056
00057 inline RRay(const RRay* oray) : _org(oray->_org),_dir(oray->_dir),_t(oray->_t),_min_t(oray->_min_t),_uv(oray->_uv),_hit(oray->_hit),_currThread(oray->_currThread)
00058 {};
00059
00060
00061
00062 inline RVec3r getOrigin() const {
00063 return _org;
00064 };
00065 inline void setOrigin(RVec3r norg) {
00066 _org=norg;
00067 };
00068
00069 inline RVec3r getDirection() const {
00070 return _dir;
00071 };
00072 inline void setDirection(RVec3r ndir) {
00073 ndir.normalize();
00074 _dir=ndir;
00075 };
00076 inline void setNormalizedDirection(RVec3r ndir) {
00077 _dir=ndir;
00078 };
00079 inline void setDirection(RReal x,RReal y,RReal z) {
00080 _dir.set(x,y,z);
00081 _dir.normalize();
00082 };
00083 inline void setNormalizedDirection(RReal x,RReal y,RReal z) {
00084 _dir.set(x,y,z);
00085 };
00086
00087 inline RReal getDistance() const {
00088 return _t;
00089 };
00090 inline void setDistance(RReal nt) {
00091 _t=nt;
00092 };
00093
00094 inline RReal getMinDistance() const {
00095 return _min_t;
00096 };
00097 inline void setMinDistance(RReal nmint) {
00098 _min_t=nmint;
00099 };
00100
00101 inline RReal getU() const {
00102 return _uv.x();
00103 };
00104 inline void setU(RReal nu) {
00105 _uv[0] = nu;
00106 };
00107
00108 inline RReal getV() const {
00109 return _uv.y();
00110 };
00111 inline void setV(RReal nv) {
00112 _uv[1] = nv;
00113 };
00114
00115 inline void setUV(RReal nu,RReal nv) {
00116 _uv.set(nu,nv);
00117 };
00118 inline void setUV(RVec2r nuv) {
00119 _uv=nuv;
00120 };
00121 inline RVec2r getUV() const {
00122 return _uv;
00123 };
00124
00125 inline RobGeometry* getHit() const {
00126 return _hit;
00127 };
00128 inline void setHit(RobGeometry* nhit) {
00129 _hit=nhit;
00130 };
00131
00132 inline RUInt16 getThreadnum() const {
00133 return _currThread;
00134 };
00135 inline void setThreadnum(RUInt16 ntn) {
00136 _currThread=ntn;
00137 };
00138
00139 };
00141 inline std::ostream& operator<<(std::ostream& os, const RRay& v) {
00142 os << "o=" << v.getOrigin() << " dir=" << v.getDirection() << " start_t=" << v.getMinDistance() << " to=" << v.getDistance();
00143 return os;
00144 };
00145
00146
00147 };
00148 }
00149 #endif