Update of /cvsroot/csp/APPLICATIONS/CSPSim/Source In directory sc8-pr-cvs1:/tmp/cvs-serv6764 Modified Files: Animation.cpp CSPSim.cpp FlightModel.cpp GameScreen.cpp ObjectModel.cpp PrimaryAeroDynamics.cpp Sky.cpp Log Message: Index: Animation.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Animation.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Animation.cpp 18 Jul 2003 20:55:11 -0000 1.1 --- Animation.cpp 16 Aug 2003 10:23:26 -0000 1.2 *************** *** 28,31 **** --- 28,34 ---- #include "Config.h" + #include <SimData/Math.h> + + SIMDATA_REGISTER_INTERFACE(DrivenRotation) *************** *** 61,66 **** DrivenRotation::DrivenRotation(): m_Axis(0.0f, 0.0f, 0.0f), ! m_Limit0(-G_PI), ! m_Limit1(G_PI), m_Gain(1.0f), m_Offset(0.0f) --- 64,69 ---- DrivenRotation::DrivenRotation(): m_Axis(0.0f, 0.0f, 0.0f), ! m_Limit0(-simdata::PI), ! m_Limit1(simdata::PI), m_Gain(1.0f), m_Offset(0.0f) Index: CSPSim.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/CSPSim.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** CSPSim.cpp 23 Jul 2003 07:11:57 -0000 1.35 --- CSPSim.cpp 16 Aug 2003 10:23:26 -0000 1.36 *************** *** 378,384 **** --- 378,386 ---- csp::SimDataFatalException(pEx, "initialization"); } + /* catch (...) { csp::OtherFatalException("initialization"); } + */ } Index: FlightModel.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/FlightModel.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FlightModel.cpp 6 Aug 2003 06:25:18 -0000 1.5 --- FlightModel.cpp 16 Aug 2003 10:23:27 -0000 1.6 *************** *** 153,157 **** Object::postCreate(); m_AspectRatio = m_WingSpan * m_WingSpan / m_WingArea; ! m_CD_i = 1.0 / (0.9 * G_PI * m_AspectRatio); m_HalfWingArea = 0.5 * m_WingArea; } --- 153,157 ---- Object::postCreate(); m_AspectRatio = m_WingSpan * m_WingSpan / m_WingArea; ! m_CD_i = 1.0 / (0.9 * simdata::PI * m_AspectRatio); m_HalfWingArea = 0.5 * m_WingArea; } Index: GameScreen.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/GameScreen.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** GameScreen.cpp 6 Aug 2003 06:25:18 -0000 1.26 --- GameScreen.cpp 16 Aug 2003 10:23:27 -0000 1.27 *************** *** 53,57 **** */ ! double const GameScreen::OffsetRate = 30.0 * (G_PI / 180.0); // x deg / s, even if it is used for Zoom also ... --- 53,57 ---- */ ! double const GameScreen::OffsetRate = 30.0 * (simdata::PI / 180.0); // x deg / s, even if it is used for Zoom also ... *************** *** 61,65 **** m_AngleRotZ = 0.0; m_NeckPhi = 0.0; ! m_NeckTheta = 0.5*G_PI; m_PanRateX = 0.0; m_PanRateZ = 0.0; --- 61,65 ---- m_AngleRotZ = 0.0; m_NeckPhi = 0.0; ! m_NeckTheta = 0.5*simdata::PI; m_PanRateX = 0.0; m_PanRateZ = 0.0; *************** *** 326,330 **** m_LookRelative = false; if (m_ViewMode == 9) { ! m_AngleRotX = 0.5*G_PI-m_NeckTheta; m_AngleRotZ = m_NeckPhi; } --- 326,330 ---- m_LookRelative = false; if (m_ViewMode == 9) { ! m_AngleRotX = 0.5*simdata::PI-m_NeckTheta; m_AngleRotZ = m_NeckPhi; } *************** *** 400,404 **** if (m_Padlock != m_ActiveObject) { if (m_ViewMode == 1) { ! m_NeckTheta = m_AngleRotX-0.5*G_PI; m_NeckPhi = m_AngleRotZ; } --- 400,404 ---- if (m_Padlock != m_ActiveObject) { if (m_ViewMode == 1) { ! m_NeckTheta = m_AngleRotX-0.5*simdata::PI; m_NeckPhi = m_AngleRotZ; } *************** *** 650,655 **** case 1: // view_mode one is normal inside the cockpit view { ! turnViewAboutX(dt,G_PI / 3); ! turnViewAboutZ(dt,G_PI / 3); simdata::Vector3 planePos = m_ActiveObject->getGlobalPosition(); simdata::Vector3 planeDir = m_ActiveObject->getDirection(); --- 650,655 ---- case 1: // view_mode one is normal inside the cockpit view { ! turnViewAboutX(dt,simdata::PI / 3); ! turnViewAboutZ(dt,simdata::PI / 3); simdata::Vector3 planePos = m_ActiveObject->getGlobalPosition(); simdata::Vector3 planeDir = m_ActiveObject->getDirection(); Index: ObjectModel.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/ObjectModel.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ObjectModel.cpp 6 Aug 2003 06:25:18 -0000 1.21 --- ObjectModel.cpp 16 Aug 2003 10:23:27 -0000 1.22 *************** *** 362,366 **** adjust->addChild(m_Model.get()); m_Model = adjust; ! simdata::Matrix3 sd_adjust = simdata::fromOSG(model_orientation).getInverse(); for (unsigned i = 0; i < m_Contacts.size(); i++) { m_Contacts[i] = sd_adjust * m_Contacts[i] + m_Offset; --- 362,366 ---- adjust->addChild(m_Model.get()); m_Model = adjust; ! simdata::Matrix3 sd_adjust = simdata::fromOSG(model_orientation); //.getInverse(); for (unsigned i = 0; i < m_Contacts.size(); i++) { m_Contacts[i] = sd_adjust * m_Contacts[i] + m_Offset; Index: PrimaryAeroDynamics.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/PrimaryAeroDynamics.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PrimaryAeroDynamics.cpp 6 Aug 2003 06:25:18 -0000 1.7 --- PrimaryAeroDynamics.cpp 16 Aug 2003 10:23:27 -0000 1.8 *************** *** 181,185 **** Object::postCreate(); m_AspectRatio = m_WingSpan * m_WingSpan / m_WingArea; ! m_CD_i = 1.0 / (0.9 * G_PI * m_AspectRatio); m_HalfWingArea = 0.5 * m_WingArea; m_depsilon = 0.5 * std::min(m_GMax,fabs(m_GMin)); --- 181,185 ---- Object::postCreate(); m_AspectRatio = m_WingSpan * m_WingSpan / m_WingArea; ! m_CD_i = 1.0 / (0.9 * simdata::PI * m_AspectRatio); m_HalfWingArea = 0.5 * m_WingArea; m_depsilon = 0.5 * std::min(m_GMax,fabs(m_GMin)); *************** *** 199,203 **** void PrimaryAeroDynamics::initializeSimulationStep(double dt) { BaseDynamics::initializeSimulationStep(dt); ! //double u = (0.034 + dt)/(1.0 - atan(m_AirSpeed) / G_PI); double u = 0.05 + dt; m_ElevatorScale = (1.0 - u) * m_ElevatorScale + u * controlInputValue( m_gForce ); --- 199,203 ---- void PrimaryAeroDynamics::initializeSimulationStep(double dt) { BaseDynamics::initializeSimulationStep(dt); ! //double u = (0.034 + dt)/(1.0 - atan(m_AirSpeed) / simdata::PI); double u = 0.05 + dt; m_ElevatorScale = (1.0 - u) * m_ElevatorScale + u * controlInputValue( m_gForce ); Index: Sky.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Sky.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Sky.cpp 6 Aug 2003 06:25:18 -0000 1.20 --- Sky.cpp 16 Aug 2003 10:23:27 -0000 1.21 *************** *** 40,43 **** --- 40,44 ---- #include <SimData/InterfaceRegistry.h> #include <SimData/DataManager.h> + #include <SimData/Math.h> #include <osg/BlendFunc> *************** *** 59,62 **** --- 60,65 ---- using namespace osg; + using simdata::toRadians; + using simdata::toDegrees; const float TURBIDITY = 3.0f; *************** *** 281,286 **** void setObserver(double lat, double lmst, float ambient) { ! rz = 270.0 - lmst * R2D; ! rx = - 90.0 + lat * R2D; if (ambient < 0.0) ambient = 0.0; if (ambient > 1.0) ambient = 1.0; --- 284,289 ---- void setObserver(double lat, double lmst, float ambient) { ! rz = 270.0 - toDegrees(lmst); ! rx = - 90.0 + toDegrees(lat); if (ambient < 0.0) ambient = 0.0; if (ambient > 1.0) ambient = 1.0; *************** *** 304,308 **** const double AstronomicalBody::_earth_radius = 6370000.0; ! const double AstronomicalBody::_earth_tilt = 23.4397 * D2R; const double AstronomicalBody::_cos_earth_tilt = cos(_earth_tilt); const double AstronomicalBody::_sin_earth_tilt = sin(_earth_tilt); --- 307,311 ---- const double AstronomicalBody::_earth_radius = 6370000.0; ! const double AstronomicalBody::_earth_tilt = toRadians(23.4397); const double AstronomicalBody::_cos_earth_tilt = cos(_earth_tilt); const double AstronomicalBody::_sin_earth_tilt = sin(_earth_tilt); *************** *** 317,321 **** double AstronomicalBody::refract(double h) const { double f = 0.000305 / (0.000305 + h * h); // localize effect at horizon (semi-arbitrary approx) ! return h + 0.57 * f * D2R; } --- 320,324 ---- double AstronomicalBody::refract(double h) const { double f = 0.000305 / (0.000305 + h * h); // localize effect at horizon (semi-arbitrary approx) ! return h + toRadians(0.57 * f); } *************** *** 451,460 **** double M = -3.18 + 0.98560 * dt; double L = M - 77.11; ! M = M * D2R; double C = 1.915 * sin(M) + 0.0201 * sin(2*M); // in AU = 1.496x10^11 m (23455 R_earth) // double R = 1.00140 - 0.016708*cos(M) - 0.000141*cos(2*M) _beta = 0.0; ! _lambda = (L + C) * D2R; _pi = 0.00004263; // just taking an average orbital radius of the earth _stale = true; --- 454,463 ---- double M = -3.18 + 0.98560 * dt; double L = M - 77.11; ! M = toRadians(M); double C = 1.915 * sin(M) + 0.0201 * sin(2*M); // in AU = 1.496x10^11 m (23455 R_earth) // double R = 1.00140 - 0.016708*cos(M) - 0.000141*cos(2*M) _beta = 0.0; ! _lambda = toRadians(L + C); _pi = 0.00004263; // just taking an average orbital radius of the earth _stale = true; *************** *** 516,520 **** Vec3 to_eye_projection = to_eye^_axis; if (to_eye_projection.normalize() > 0.0) { ! float rotation_angle = G_PI+acos(to_eye_projection*_onormal); Vec3 pivot = _onormal^to_eye_projection; matrix.makeRotate(rotation_angle, pivot); --- 519,523 ---- Vec3 to_eye_projection = to_eye^_axis; if (to_eye_projection.normalize() > 0.0) { ! float rotation_angle = simdata::PI+acos(to_eye_projection*_onormal); Vec3 pivot = _onormal^to_eye_projection; matrix.makeRotate(rotation_angle, pivot); *************** *** 714,718 **** float sun_angle = getBeta() * 0.38/159.6; // (distance ratio moon:sun) float a0 = 0.5 * m_Phase; ! float a1 = 0.5 * (G_PI - m_Phase); float f0 = fabs(tan(0.5*a0)); float f1 = fabs(tan(0.5*a1)); --- 717,721 ---- float sun_angle = getBeta() * 0.38/159.6; // (distance ratio moon:sun) float a0 = 0.5 * m_Phase; ! float a1 = 0.5 * (simdata::PI - m_Phase); float f0 = fabs(tan(0.5*a0)); float f1 = fabs(tan(0.5*a1)); *************** *** 742,747 **** void Moon::_maskPhase(float phi, float beta) { { ! int n = (int) (phi / (2.0*G_PI)); ! phi -= n * 2.0 * G_PI; //cout << "MOON PHASE = " << phi << endl; } --- 745,750 ---- void Moon::_maskPhase(float phi, float beta) { { ! int n = (int) (phi / (2.0*simdata::PI)); ! phi -= n * 2.0 * simdata::PI; //cout << "MOON PHASE = " << phi << endl; } *************** *** 901,905 **** float yc = 0.15346 * s3 - 0.26756 * s2 + 0.06670 * s + 0.26688; float yz = ya * t2 + yb * t + yc; ! float chi = (0.4444444 - T * 0.008333333) * (G_PI - 2.0*s); float Yz = (4.0453 * T - 4.9710) * tan(chi) - 0.2155 * T + 2.4192; // Yz is in units of kcd/m^2 --- 904,908 ---- float yc = 0.15346 * s3 - 0.26756 * s2 + 0.06670 * s + 0.26688; float yz = ya * t2 + yb * t + yc; ! float chi = (0.4444444 - T * 0.008333333) * (simdata::PI - 2.0*s); float Yz = (4.0453 * T - 4.9710) * tan(chi) - 0.2155 * T + 2.4192; // Yz is in units of kcd/m^2 *************** *** 923,939 **** void SkyShader::setSunElevation(float h) { m_AzimuthCorrection = 0.0; ! if (h < -G_PI) { ! h += 2.0 * G_PI * int((G_PI - h) / (2.0 * G_PI)); } else ! if (h > G_PI) { ! h -= 2.0 * G_PI * int((G_PI + h) / (2.0 * G_PI)); } ! if (h > 0.5 *G_PI) { ! h = G_PI - h; ! m_AzimuthCorrection = G_PI; } else ! if (h < -0.5*G_PI) { ! h = -G_PI - h; ! m_AzimuthCorrection = -G_PI; } m_SunElevation = h; --- 926,942 ---- void SkyShader::setSunElevation(float h) { m_AzimuthCorrection = 0.0; ! if (h < -simdata::PI) { ! h += 2.0 * simdata::PI * int((simdata::PI - h) / (2.0 * simdata::PI)); } else ! if (h > simdata::PI) { ! h -= 2.0 * simdata::PI * int((simdata::PI + h) / (2.0 * simdata::PI)); } ! if (h > 0.5 *simdata::PI) { ! h = simdata::PI - h; ! m_AzimuthCorrection = simdata::PI; } else ! if (h < -0.5*simdata::PI) { ! h = -simdata::PI - h; ! m_AzimuthCorrection = -simdata::PI; } m_SunElevation = h; *************** *** 944,948 **** m_Dirty = false; ! m_SunTheta = 0.5*G_PI - m_SunElevation; m_SunVector[0] = 0.0; m_SunVector[1] = sin(m_SunTheta); --- 947,951 ---- m_Dirty = false; ! m_SunTheta = 0.5*simdata::PI - m_SunElevation; m_SunVector[0] = 0.0; m_SunVector[1] = sin(m_SunTheta); *************** *** 969,974 **** #ifdef CUSTOM // only rescale down to the horizon, bad things happen if we go further ! if (m_SunTheta >= 0.5*G_PI) { ! m_MaxY = Perez(0.5*G_PI, 0.0, 0.5*G_PI, m_Zenith.getC(), m_Coefficients.Y); } else { m_MaxY = Perez(m_SunTheta, 0.0, m_SunTheta, m_Zenith.getC(), m_Coefficients.Y); --- 972,977 ---- #ifdef CUSTOM // only rescale down to the horizon, bad things happen if we go further ! if (m_SunTheta >= 0.5*simdata::PI) { ! m_MaxY = Perez(0.5*simdata::PI, 0.0, 0.5*simdata::PI, m_Zenith.getC(), m_Coefficients.Y); } else { m_MaxY = Perez(m_SunTheta, 0.0, m_SunTheta, m_Zenith.getC(), m_Coefficients.Y); *************** *** 981,985 **** // the drop at the horizon. NightBase is scaling with the sun 90 // degrees below the horizon. ! m_F =(atan(m_SunElevation*m_SunsetSharpness)/G_PI+0.5)*(1.0-m_NightBase) + m_NightBase; #endif --- 984,988 ---- // the drop at the horizon. NightBase is scaling with the sun 90 // degrees below the horizon. ! m_F =(atan(m_SunElevation*m_SunsetSharpness)/simdata::PI+0.5)*(1.0-m_NightBase) + m_NightBase; #endif *************** *** 988,992 **** Color SkyShader::SkyColor(float elevation, float azimuth, float dark, float &intensity) { if (m_Dirty) _computeBase(); ! float theta = 0.5*G_PI - elevation; float A = azimuth + m_AzimuthCorrection; float v[3] = {sin(A)*sin(theta), cos(A)*sin(theta), cos(theta)}; --- 991,995 ---- Color SkyShader::SkyColor(float elevation, float azimuth, float dark, float &intensity) { if (m_Dirty) _computeBase(); ! float theta = 0.5*simdata::PI - elevation; float A = azimuth + m_AzimuthCorrection; float v[3] = {sin(A)*sin(theta), cos(A)*sin(theta), cos(theta)}; *************** *** 1098,1102 **** void updateHorizon(float altitude, float clip) { float a = 0.0; ! float da = 2.0 * G_PI / m_Segments; float radius = std::min(1000000.0, std::max(1.5*clip, sqrt(2.0 * 6370000.0 * altitude))); // variation less than 2 pixels under most conditions: --- 1101,1105 ---- void updateHorizon(float altitude, float clip) { float a = 0.0; ! float da = 2.0 * simdata::PI / m_Segments; float radius = std::min(1000000.0, std::max(1.5*clip, sqrt(2.0 * 6370000.0 * altitude))); // variation less than 2 pixels under most conditions: *************** *** 1355,1359 **** void Sky::_updateShading(double sun_h, double sun_A) { Vec4Array& colors = *(dynamic_cast<Vec4Array*>(m_SkyDome->getColorArray())); ! double da = 2.0 * G_PI / (m_nseg); double min_a = 0.5*da; double jitter = 0.0; --- 1358,1362 ---- void Sky::_updateShading(double sun_h, double sun_A) { Vec4Array& colors = *(dynamic_cast<Vec4Array*>(m_SkyDome->getColorArray())); ! double da = 2.0 * simdata::PI / (m_nseg); double min_a = 0.5*da; double jitter = 0.0; *************** *** 1363,1369 **** osg::Vec4 horizon_average; for (i = 0; i < m_nlev; ++i) { ! double elev = m_lev[i] * D2R; if (elev < 0.0) elev = 0.0; // sub horizon colors aren't correct ! double azimuth = -sun_A - 0.5 * G_PI; bool at_vertex = fabs(elev - sun_h) < min_a; // this is only a rough measure for (j = 0; j < m_nseg; ++j) { --- 1366,1372 ---- osg::Vec4 horizon_average; for (i = 0; i < m_nlev; ++i) { ! double elev = toRadians(m_lev[i]); if (elev < 0.0) elev = 0.0; // sub horizon colors aren't correct ! double azimuth = -sun_A - 0.5 * simdata::PI; bool at_vertex = fabs(elev - sun_h) < min_a; // this is only a rough measure for (j = 0; j < m_nseg; ++j) { *************** *** 1416,1420 **** for (i = 0; i < 32; ++i) { double x = i / 30.0; ! double elevation = (1.0 - sqrt(x*x+y*y)) * 0.5 * G_PI; if (elevation >= -0.15) { if (elevation < 0.0) elevation = 0.0; --- 1419,1423 ---- for (i = 0; i < 32; ++i) { double x = i / 30.0; ! double elevation = (1.0 - sqrt(x*x+y*y)) * 0.5 * simdata::PI; if (elevation >= -0.15) { if (elevation < 0.0) elevation = 0.0; *************** *** 1437,1442 **** { // separate evaluation for horizon colors int n = m_HorizonColors->size(); ! double da = 2.0 * G_PI / n; ! double azimuth = -sun_A - 0.5 * G_PI; for (i = 0; i < n; ++i) { float intensity; --- 1440,1445 ---- { // separate evaluation for horizon colors int n = m_HorizonColors->size(); ! double da = 2.0 * simdata::PI / n; ! double azimuth = -sun_A - 0.5 * simdata::PI; for (i = 0; i < n; ++i) { float intensity; *************** *** 1450,1459 **** { // update texture coordinates int ci = 0; ! double da = 2.0 * G_PI / (m_nseg); for (i = 0; i < m_nlev; ++i) { ! double elev = m_lev[i] * D2R; if (elev < 0.0) elev = 0.0; // sub horizon colors aren't correct ! double azimuth = -sun_A - 0.5 * G_PI; ! float factor = (1.0 - 2.0 * elev / G_PI) * 30.0 / 32.0; for (j = 0; j < m_nseg; ++j) { float x = 0.5 * (1.0 + sin(azimuth) * factor) + 0.5 / 64.0; --- 1453,1462 ---- { // update texture coordinates int ci = 0; ! double da = 2.0 * simdata::PI / (m_nseg); for (i = 0; i < m_nlev; ++i) { ! double elev = toRadians(m_lev[i]); if (elev < 0.0) elev = 0.0; // sub horizon colors aren't correct ! double azimuth = -sun_A - 0.5 * simdata::PI; ! float factor = (1.0 - 2.0 * elev / simdata::PI) * 30.0 / 32.0; for (j = 0; j < m_nseg; ++j) { float x = 0.5 * (1.0 + sin(azimuth) * factor) + 0.5 / 64.0; *************** *** 1492,1496 **** void Sky::update(double lat, double lon, simdata::SimDate const &t) { ! m_LMST = t.getMST(lon) + m_SpinTheWorld * 2.0 * G_PI; m_JD = t.getJulianDate() + m_SpinTheWorld; m_Latitude = lat; --- 1495,1499 ---- void Sky::update(double lat, double lon, simdata::SimDate const &t) { ! m_LMST = t.getMST(lon) + m_SpinTheWorld * 2.0 * simdata::PI; m_JD = t.getJulianDate() + m_SpinTheWorld; m_Latitude = lat; |