00001 /* 00002 Sheep - A Rigid Body Dynamics Engine 00003 Copyright (C) 2001-2004 Francois Beaune 00004 Contact: http://toxicengine.sourceforge.net/ 00005 00006 This file is part of Sheep. 00007 00008 Sheep is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 Sheep is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Sheep; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #include "sceneorbiter.h" // include first 00024 00025 using namespace sheep; 00026 00027 void SceneOrbiter::tumble(const Vector2 &delta) { 00028 Real dx = delta.m_x; 00029 00030 #ifdef REVERSE_AZIMUTH 00031 if(m_reverse_azimuth) 00032 dx = -dx; 00033 #endif // REVERSE_AZIMUTH 00034 00035 m_azimuth = NormalizeAngle(m_azimuth + dx * PI / 2.0); 00036 m_elevation = NormalizeAngle(m_elevation - delta.m_y * PI / 2.0); 00037 } 00038 00039 void SceneOrbiter::track(const Vector2 &delta) { 00040 const Real t = fabs(cos(m_elevation)); 00041 00042 const Vector3 w(cos(m_azimuth) * t, sin(m_elevation), sin(m_azimuth) * t); 00043 assert(w.IsUnitLength()); 00044 00045 Vector3 u(w.m_z, 0.0, -w.m_x); // Vector3 u = Vector3(0.0, 1.0, 0.0) ^ w; 00046 u.Normalize(); 00047 00048 const Vector3 v = w ^ u; 00049 assert(v.IsUnitLength()); 00050 00051 m_center -= delta.m_x * u + delta.m_y * v; 00052 } 00053 00054 void SceneOrbiter::dolly(const Vector2 &delta) { 00055 m_distance -= log(m_distance + 1.0) * delta.m_y; 00056 00057 if(m_distance < 0.01) 00058 m_distance = 0.01; 00059 }
1.3.6