| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2003 Computer Graphics Systems Group at the 00004 * Hasso-Plattner-Institute (HPI), Potsdam, Germany. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at 00009 * your option) any later version. This library is distributed in the hope 00010 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 00011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. You should have received 00013 * a copy of the GNU Lesser+ General Public License along with this library; if 00014 * not, write to the FreeSoftware Foundation, Inc., 59 Temple Place, Suite 330, 00015 * Boston, MA, 02111-1307, USA. 00016 ******************************************************************************/ 00017 00018 // $Id: lookat.h 4633 2005-01-03 01:43:11Z klimetschek $ 00019 // $Date: 2005-01-03 02:43:11 +0100 (Mon, 03 Jan 2005) $ 00020 // $Revision: 4633 $ 00021 // $State$ 00022 // $Author: klimetschek $ 00023 // 00024 // $Log$ 00025 // Revision 1.21 2005/01/03 01:43:08 klimetschek 00026 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00027 // - removed vrs.vcproj 00028 // minor things: 00029 // - added all glutexamples to vrs4glut.sln 00030 // - fixed some problems in glutexamples 00031 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00032 // 00033 // Revision 1.20 2004/11/05 13:58:09 basch 00034 // Class comment changed (Doxygen style) 00035 // 00036 // Revision 1.19 2004/04/22 09:12:18 baumann 00037 // eye distance removed 00038 // 00039 // Revision 1.18 2004/03/12 16:28:38 baumann 00040 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00041 // 00042 // Revision 1.17 2004/01/19 11:43:57 baumann 00043 // serialization mechanism improved 00044 // 00045 // Revision 1.16 2003/11/07 14:19:24 kirsch 00046 // removed leading underscore from include guards 00047 // 00048 // Revision 1.15 2003/06/29 11:53:40 baumann 00049 // - added: void VRS::LookAt::setFromToUp(from, to, up) 00050 // 00051 // Revision 1.14 2003/06/29 11:13:59 baumann 00052 // - added: static bool VRS::LookAt::isValid(from, to, up) 00053 // - renamed (non-static) method VRS::LookAt::valid() to VRS::LookAt::isValid() 00054 // 00055 // Revision 1.13 2003/04/16 11:22:39 buchholz 00056 // now (0,1,0) is default up vector again, another up vector is computed only if the specified one is invalid. 00057 // 00058 // Revision 1.12 2003/04/10 12:14:04 buchholz 00059 // degeneracy check and additional constructor included. The alternate constructor computes an up vector that is always nonzero and perpendicular to the direction vector. 00060 // 00061 // Revision 1.11 2002/10/29 10:32:52 baumann 00062 // macros VRS_CLASSNAME_* and VRS_IMPL_TYPEINFO_* removed 00063 // 00064 // Revision 1.10 2002/05/06 13:08:02 kirsch 00065 // cleanup: used mutable instead of const cast, removed declared but 00066 // undefined methods, in serialize only set rebuild flag if reading 00067 // 00068 // Revision 1.9 2002/03/03 21:44:24 kosta 00069 // VRS_TYPEINFO-macro rewritten 00070 // 00071 // Revision 1.8 2002/02/19 10:34:09 kosta 00072 // undone all changes since 2002-02-15 00073 // 00074 // Revision 1.5 2002/02/05 07:48:25 kosta 00075 // new persistency macros: 00076 // VRS_SERIALIZABLE(CLASS_NAME); 00077 // VRS_SERIALIZABLE_ABSTRACT_CLASS(CLASS_NAME); 00078 // VRS_SERIALIZABLE_NO_SO_CLASS(CLASS_NAME) 00079 // 00080 // Revision 1.4 2002/02/04 13:07:19 kosta 00081 // VRS_SERIALIZABLE macros completely rewritten 00082 // 00083 // Revision 1.3 2002/01/15 16:25:54 kosta 00084 // macros rewritten for a better namespace support 00085 // 00086 // Revision 1.2 2001/11/13 16:36:30 kirsch 00087 // changed line feed to unix style (removed control-M) 00088 // 00089 // Revision 1.1.1.1 2001/06/08 08:09:20 kirsch 00090 // imported alpha-version by olli 00091 // 00092 00093 00094 #ifndef VRS_LOOKAT_H 00095 #define VRS_LOOKAT_H 00096 00097 #include <vrs/transform.h> 00098 00099 namespace VRS { 00100 00102 class VRS_CORE_API LookAt : public Transform { 00103 00104 public: 00105 LookAt(const Vector& from = Vector(0.0, 0.0, 1.0), 00106 const Vector& to = Vector::origin, 00107 const Vector& up = Vector(0.0, 1.0, 0.0) 00108 ); 00116 void setFromToUp(const Vector& from, const Vector& to, const Vector& up); 00118 00119 void setFrom(const Vector& from); 00120 Vector getFrom() const; 00122 00123 void setTo(const Vector& to); 00124 Vector getTo() const; 00126 00127 void setUp(const Vector& up); 00128 Vector getUp() const; 00130 00131 bool isValid() const; 00132 static bool isValid(const Vector& from, const Vector& to, const Vector& up); 00142 virtual const Matrix& matrix(Engine* engine = NULL) const; 00144 00145 VRS_TYPEINFO(LookAt, Transform); 00146 VRS_SERIALIZABLE(LookAt); 00147 00148 private: 00149 void rebuild() const; 00150 00151 Vector from_; 00152 Vector to_; 00153 Vector up_; 00154 00155 mutable Matrix orientation_; 00156 mutable bool rebuild_; 00157 mutable bool valid_; 00158 }; 00159 00160 inline Vector LookAt::getFrom() const { return from_; } 00161 inline Vector LookAt::getTo() const { return to_; } 00162 inline Vector LookAt::getUp() const { return up_; } 00163 00164 } // namespace VRS 00165 00166 #endif // VRS_LOOKAT_H