| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2000-2004 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: physicalmodel.h 6014 2007-08-09 07:51:16Z Konstantin_Baumann $ 00019 // 00020 // $Log$ 00021 // Revision 1.1 2005/02/15 18:29:08 buchholz 00022 // first check-in 00023 // 00024 00025 #ifndef VRS_SG_PHYSICALMODEL_H 00026 #define VRS_SG_PHYSICALMODEL_H 00027 00028 #include <vrs/sharedobj.h> 00029 #include <vrs/vector.h> 00030 00031 namespace VRS { 00032 00035 class VRS_CORE_API PhysicalModel : public SharedObj { 00036 public: 00037 00039 PhysicalModel(const Vector& startPos); 00040 00047 void setViscosity(double viscosity = .5); 00048 00055 double getViscosity() const; 00056 00058 void setSpringStrength(double strength = 50.0); 00059 00061 double getSpringStrength() const; 00062 00068 double getMeterDefinition() const; 00069 00075 void setMeterDefinition(double factor = 1.0); 00076 00079 void initializeModel(const Vector& startPos); 00080 00082 void setNewTargetPosition(const Vector& targetPosition); 00083 00089 void brake(); 00090 00092 Vector getCameraPosition() const; 00093 00095 Vector getCameraVelocity() const; 00096 00098 Vector getCameraAcceleration() const; 00099 00104 Vector getTargetPosition() const; 00105 00108 void onTimer(double elapsedTime); 00109 00110 VRS_TYPEINFO(PhysicalModel, SharedObj); 00111 VRS_SERIALIZABLE(PhysicalModel); 00112 00113 private: 00114 00115 PhysicalModel(); // only for serialization! 00116 00117 void solveMotionEquations(Vector& dPos, Vector& dVel, Vector& dAcc, double elapsedTime) const; 00118 /* It calculates the changes of the camera's position, velocity and acceleration by the given values: 00119 - current camera position, 00120 - current camera velocity, 00121 - current camera acceleration and the 00122 - current target position 00123 - old target position, before user interaction changed the target position 00124 - time interval defines the time steps between two calculations 00125 */ 00126 00127 void updatePhysicalModelData(const Vector& dPos, const Vector& dVel, const Vector& dAcc); 00128 /* The delta values for tha camera's position, velocity and acceleration 00129 (dPosition_, dVelocity_ and dAcceleration_) which were calculated 00130 during the last solving of the physical motion equations are added to 00131 cameraPosition_, cameraVelocity_ and cameraAcceleration_. */ 00132 00133 00134 // configuration variables 00135 double viscosity_; 00136 double springStrength_; 00137 double meterDefinition_; 00138 00139 // state variables 00140 Vector cameraPosition_; 00141 Vector cameraVelocity_; 00142 Vector cameraAcceleration_; 00143 Vector targetPosition_; 00144 Vector oldTargetPosition_; 00145 bool brakeFlag_; // set to true when brake() is calles, set to false in the subsequent onTimer() call 00146 double oldViscosity_; // used temporarily for viscosity changes at runtime 00147 double oldSpringStrength_; // used temporarily for spring strength changes at runtim 00148 double elapsedTime_; // time since last model update 00149 00150 static const double Epsilon; 00151 static const double MaxDistance2; 00152 00153 }; // class PhysicalModel 00154 00155 } // namespace VRS 00156 00157 #endif // VRS_SG_PHYSICALMODEL_H