|
From: <mk...@us...> - 2003-03-23 19:05:17
|
Update of /cvsroot/csp/APPLICATIONS/CSPSim/Source
In directory sc8-pr-cvs1:/tmp/cvs-serv29607
Modified Files:
AeroDynamics.cpp Atmosphere.cpp CSPSim.py ScreenInfo.cpp
Log Message:
Index: AeroDynamics.cpp
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/AeroDynamics.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** AeroDynamics.cpp 22 Mar 2003 12:38:27 -0000 1.9
--- AeroDynamics.cpp 23 Mar 2003 19:05:02 -0000 1.10
***************
*** 374,381 ****
if (atmosphere != NULL) {
double density = atmosphere->getDensity(m_PositionLocal.z);
- density += atmosphere->getTurbulence(m_PositionLocal, m_Distance);
qBarFactor *= density;
m_Gravity = atmosphere->getGravity(m_PositionLocal.z);
Wind = atmosphere->getWind(m_PositionLocal);
} else {
qBarFactor *= 1.25;
--- 374,381 ----
if (atmosphere != NULL) {
double density = atmosphere->getDensity(m_PositionLocal.z);
qBarFactor *= density;
m_Gravity = atmosphere->getGravity(m_PositionLocal.z);
Wind = atmosphere->getWind(m_PositionLocal);
+ Wind += atmosphere->getTurbulence(m_PositionLocal, m_Distance);
} else {
qBarFactor *= 1.25;
Index: Atmosphere.cpp
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Atmosphere.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Atmosphere.cpp 22 Mar 2003 12:38:27 -0000 1.2
--- Atmosphere.cpp 23 Mar 2003 19:05:04 -0000 1.3
***************
*** 142,145 ****
--- 142,146 ----
void Atmosphere::generateWinds() {
Perlin1D noise;
+ int i;
// pressure variation (10 days)
***************
*** 151,161 ****
noise.set(0.9, 6);
noise.randomize();
! m_DensityTime = noise.generate(1000, true, 10.0, 0.02, 0.0);
// turbulence altitude buffers (15000 m)
noise.set(0.9, 6);
noise.randomize();
! m_TurbulenceAltA = noise.generate(1000, false, 10.0, 2.0, -1.0);
! m_TurbulenceAltB = noise.generate(1000, false, 10.0, 2.0, -1.0);
// wind direction variation (30000 m)
--- 152,182 ----
noise.set(0.9, 6);
noise.randomize();
! m_TurbulenceX = noise.generate(1000, true, 10.0, 1.0, 0.0);
! noise.randomize();
! m_TurbulenceY = noise.generate(1000, true, 10.0, 1.0, 0.0);
! noise.randomize();
! m_TurbulenceZ = noise.generate(1000, true, 10.0, 1.0, 0.0);
! for (i = 0; i < 1000; i++) {
! float a;
! a= m_TurbulenceX[i];
! m_TurbulenceX[i] *= 10.0 * a * fabs(a);
! a = m_TurbulenceY[i];
! m_TurbulenceY[i] *= 10.0 * a * fabs(a);
! a = m_TurbulenceZ[i];
! m_TurbulenceZ[i] *= 10.0 * a * fabs(a);
! }
// turbulence altitude buffers (15000 m)
noise.set(0.9, 6);
noise.randomize();
! m_TurbulenceAltA = noise.generate(1000, false, 10.0, 3.0, -1.5);
! noise.randomize();
! m_TurbulenceAltB = noise.generate(1000, false, 10.0, 3.0, -1.5);
! for (i = 0; i < 1000; i++) {
! float f = i * 0.015; // f in km
! f = (12.5 * f + 7.6) / (f*f + 45.0);
! m_TurbulenceAltA[i] *= f;
! m_TurbulenceAltB[i] *= f;
! }
// wind direction variation (30000 m)
***************
*** 192,205 ****
f = h - idx;
}
wind.x += m_WindAltX[idx]*(1.0-f) + m_WindAltX[idx+1]*f;
wind.y += m_WindAltY[idx]*(1.0-f) + m_WindAltY[idx+1]*f;
! return wind * m_WindScale * m_GustModulation;
}
! double Atmosphere::getTurbulence(simdata::Vector3 const &p, double dist) const {
! if (dist < 0.0) dist = - dist;
! int idx = int(dist * 0.1) % 1000;
! float d = m_DensityTime[idx];
! idx = int(p.z * 1000.0 / 15000.0);
if (idx < 0) idx = 0;
else if (idx > 999) idx = 999;
--- 213,225 ----
f = h - idx;
}
+ double alt_scale = 1.0 + h*h*0.0025;
+ if (alt_scale > 2.0) alt_scale = 2.0;
wind.x += m_WindAltX[idx]*(1.0-f) + m_WindAltX[idx+1]*f;
wind.y += m_WindAltY[idx]*(1.0-f) + m_WindAltY[idx+1]*f;
! return wind * m_WindScale * m_GustModulation * alt_scale;
}
! simdata::Vector3 Atmosphere::getTurbulence(simdata::Vector3 const &p, double dist) const {
! int idx = int(p.z * 1000.0 / 15000.0);
if (idx < 0) idx = 0;
else if (idx > 999) idx = 999;
***************
*** 209,221 ****
if (b < 0.0) b = 0.0;
a = a * (1.0 - m_TurbulenceBlend) + b * m_TurbulenceBlend;
/*
static int i = 0;
if ((i++ % 40) == 0) {
! std::cout << a << ":" << d << "\n";
}
*/
! // first try didn't show much effect. * 30 does something, but hard to notice.
! // * 100 is too much. need to tune...
! return a * d * 30.0;
}
--- 229,245 ----
if (b < 0.0) b = 0.0;
a = a * (1.0 - m_TurbulenceBlend) + b * m_TurbulenceBlend;
+
/*
static int i = 0;
if ((i++ % 40) == 0) {
! std::cout << a << "\n";
}
*/
!
! if (a <= 0.0) return simdata::Vector3::ZERO;
!
! if (dist < 0.0) dist = - dist;
! idx = int(dist * 0.1) % 1000;
! return simdata::Vector3(a*m_TurbulenceX[idx],a*m_TurbulenceY[idx],a*m_TurbulenceZ[idx]);
}
***************
*** 330,333 ****
--- 354,362 ----
m_TurbulenceBlendUp = false;
m_TurbulenceAltA = noise.generate(1000, false, 10.0, 2.0, -1.0);
+ for (int i = 0; i < 1000; i++) {
+ float f = i * 0.015; // f in km
+ f = (12.5 * f + 7.6) / (f*f + 45.0);
+ m_TurbulenceAltA[i] *= f;
+ }
}
} else {
***************
*** 340,343 ****
--- 369,377 ----
m_TurbulenceBlendUp = true;
m_TurbulenceAltB = noise.generate(1000, false, 10.0, 2.0, -1.0);
+ for (int i = 0; i < 1000; i++) {
+ float f = i * 0.015; // f in km
+ f = (12.5 * f + 7.6) / (f*f + 45.0);
+ m_TurbulenceAltB[i] *= f;
+ }
}
}
Index: CSPSim.py
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/CSPSim.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CSPSim.py 22 Mar 2003 08:32:32 -0000 1.1
--- CSPSim.py 23 Mar 2003 19:05:04 -0000 1.2
***************
*** 3,6 ****
--- 3,9 ----
import sys, os.path
+ #import Shell
+ #from SimData.Compile import Compiler, CompilerUsageError
+
# enable lazy loading of shared library modules if available
if hasattr(sys, "setdlopenflags"):
***************
*** 71,74 ****
--- 74,80 ----
action = None
config = "../Data/CSPSim.ini"
+ if os.path.exists("CSPSim.ini") or not os.path.exists(config):
+ config = "CSPSim.ini"
+
Index: ScreenInfo.cpp
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/ScreenInfo.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ScreenInfo.cpp 22 Mar 2003 12:47:20 -0000 1.6
--- ScreenInfo.cpp 23 Mar 2003 19:05:04 -0000 1.7
***************
*** 76,81 ****
m_maxFps = max(m_maxFps,fps);
std::ostringstream osstr;
! osstr << setprecision(1) << fixed << fps << " FPS min: " << m_minFps << " max: " << m_maxFps;
! m_Text->setText(osstr.str());
simdata::SimDate artificial_time = CSPSim::theSim->getCurrentTime();
--- 76,81 ----
m_maxFps = max(m_maxFps,fps);
std::ostringstream osstr;
! osstr << setprecision(1) << setw(5) << fixed << fps << " FPS min: " << m_minFps << " max: " << m_maxFps;
! m_Text->setText(osstr.str());
simdata::SimDate artificial_time = CSPSim::theSim->getCurrentTime();
***************
*** 110,138 ****
std::ostringstream osstr;
osstr << "Terrain Polygons: " << CSPSim::theSim->getBattlefield()->getTerrainPolygonsRendered();
! m_Text->setText(osstr.str());
simdata::Pointer<DynamicObject const> const activeObject = CSPSim::theSim->getActiveObject();
if (!activeObject.isNull()) {
-
simdata::Vector3 pos = activeObject->getLocalPosition();
osstr.str("");
! osstr << "LocalPosition: (" << setprecision(precision) << fixed
! << setw(6 + precision) << setfill('0') << pos.x << ", ";
osstr << setw(6 + precision) << setfill('0') << pos.y << ", ";
osstr << setw(6 + precision) << setfill('0') << pos.z << ")";
! m_LocalPosition->setText(osstr.str());
pos = activeObject->getGlobalPosition();
osstr.str("");
! osstr << "GlobalPosition: (" << setprecision(precision) << fixed
! << setw(7 + precision) << setfill('0') << pos.x << ", ";
osstr << setw(7 + precision) << setfill('0') << pos.y << ", ";
osstr << setw(7 + precision) << setfill('0') << pos.z << ")";
! m_GlobalPosition->setText(osstr.str());
simdata::Vector3 vel = activeObject->getVelocity();
! osstr.str("");
! osstr << "Velocity: (" << setprecision(2) << fixed << vel.x << ", " << vel.y << ", " << vel.z << ")";
! m_Velocity->setText(osstr.str());
}
}
--- 110,137 ----
std::ostringstream osstr;
osstr << "Terrain Polygons: " << CSPSim::theSim->getBattlefield()->getTerrainPolygonsRendered();
! m_Text->setText(osstr.str());
simdata::Pointer<DynamicObject const> const activeObject = CSPSim::theSim->getActiveObject();
if (!activeObject.isNull()) {
simdata::Vector3 pos = activeObject->getLocalPosition();
osstr.str("");
! osstr << "LocalPosition: (" << setprecision(precision) << fixed
! << setw(6 + precision) << setfill('0') << pos.x << ", ";
osstr << setw(6 + precision) << setfill('0') << pos.y << ", ";
osstr << setw(6 + precision) << setfill('0') << pos.z << ")";
! m_LocalPosition->setText(osstr.str());
pos = activeObject->getGlobalPosition();
osstr.str("");
! osstr << "GlobalPosition: (" << setprecision(precision) << fixed
! << setw(7 + precision) << setfill('0') << pos.x << ", ";
osstr << setw(7 + precision) << setfill('0') << pos.y << ", ";
osstr << setw(7 + precision) << setfill('0') << pos.z << ")";
! m_GlobalPosition->setText(osstr.str());
simdata::Vector3 vel = activeObject->getVelocity();
! osstr.str("");
! osstr << "Velocity: (" << setprecision(2) << fixed << vel.x << ", " << vel.y << ", " << vel.z << ")";
! m_Velocity->setText(osstr.str());
}
}
|