ViewPoint.hpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #ifndef sim_stat_ViewPoint_hpp
00023 #define sim_stat_ViewPoint_hpp
00024 
00025 #include "util/vecmath/Point3.hpp"
00026 #include "util/vecmath/Euler3.hpp"
00027 #include "util/vecmath/Quat4.hpp"
00028 #include "util/error/Log.hpp"
00029 
00030 namespace se_core {
00031 
00032     class _SeCoreExport ViewPoint {
00033     public:
00034         ViewPoint() {}
00035         ViewPoint(const ViewPoint& vp) 
00036             : face_(vp.face_), coor_(vp.coor_) {
00037         }
00038 
00039         bool viewPointEquals(const ViewPoint& c) const {
00040             return (c.coor_.equals(coor_) && c.face_.equals(face_));
00041         }
00042 
00043         bool viewPointEquals(const ViewPoint& c
00044                              , coor_t coorEpsilon, bray_t faceEpsilon) const {
00045             return (c.coor_.epsilonEquals(coor_, coorEpsilon) 
00046                     && c.face_.epsilonEquals(face_, faceEpsilon));
00047         }
00048 
00049         inline void setViewPoint(const ViewPoint& original) {
00050             coor_.set(original.coor_);
00051             face_.set(original.face_);
00052         }
00053 
00054 
00055         inline void setIdentity() {
00056             coor_.reset();
00057             face_.setIdentity();
00058         }
00059 
00060         #ifdef SE_QUAT
00061         const Quat4& face() const { return face_; }
00062         Quat4& face() { return face_; }
00063         #else
00064         const Euler3& face() const { return face_; }
00065         Euler3& face() { return face_; }
00066         #endif
00067 
00068         inline void setCoor(const Point3& c) { coor_.set(c); }
00069 
00070         inline void setFace(const Quat4& f) { face_.set(f); }
00071         inline void setFace(const Euler3& f) { face_.set(f); }
00072 
00073         void face(Quat4& dest) {
00074             dest.set(face_);
00075         }
00076 
00077         const Point3& coor() const { return coor_; }
00078         Point3& coor() { return coor_; }
00079 
00080         void interpolate(ViewPoint& vp, scale_t alpha) {
00081             coor_.interpolate(vp.coor_, alpha);
00082             face_.interpolate(vp.face_, alpha);
00083         }
00084 
00085 
00086         void add(const ViewPoint& other) {
00087             if(!other.face_.isIdentity()) {
00088                 face_.rotate(other.face_);
00089                 coor_.rotate(other.face_);
00090             }
00091             coor_.add(other.coor_);
00092         }
00093 
00094         void sub(const ViewPoint& other) {
00095             coor_.sub(other.coor_);
00096             if(!other.face_.isIdentity()) {
00097                 coor_.rotateInverse(other.face_);
00098                 face_.rotateInverse(other.face_);
00099             }
00100         }
00101 
00109         inline void setFaceDirection(bray_t d) { face_.setYaw(d & BRAY_MASK); }
00110         const char* toLog() const;
00111 
00112     public: // Attributes
00113         #ifdef SE_QUAT
00114         Quat4 face_;
00115         #else
00116         Euler3 face_;
00117         #endif
00118         Point3 coor_;
00119     };
00120 
00121     se_err::Log& operator<< (se_err::Log& log, const ViewPoint& vp);
00122 
00123 }
00124 
00125 #endif

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:13 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo