|
From: <mk...@us...> - 2003-04-11 23:43:10
|
Update of /cvsroot/csp/APPLICATIONS/CSPSim/Source
In directory sc8-pr-cvs1:/tmp/cvs-serv5133/Source
Modified Files:
AeroDynamics.cpp CSPSim.cpp ObjectModel.cpp StaticObject.cpp
Log Message:
see CHANGES.current
Index: AeroDynamics.cpp
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/AeroDynamics.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** AeroDynamics.cpp 3 Apr 2003 10:40:42 -0000 1.13
--- AeroDynamics.cpp 11 Apr 2003 23:43:06 -0000 1.14
***************
*** 469,482 ****
static const float groundBeta = 1.0e+6;
double impact = simdata::Dot(V, m_GroundN);
double scale = - (height*groundK + impact*fabs(impact)*groundBeta);
if (fabs(scale)>groundK) {
// dissipate some extra energy
if (impact < -10.0) {
//m_VelocityBody *= 0.50;
! m_VelocityBody -= 0.50 * impact * m_GroundN;
std::cout << "SLAM!!!!\n";
} else {
//m_VelocityBody *= 0.95;
! m_VelocityBody -= 0.95 * impact * m_GroundN;
std::cout << "SLAM!\n";
}
--- 469,486 ----
static const float groundBeta = 1.0e+6;
double impact = simdata::Dot(V, m_GroundN);
+ // spring plus damping terms
double scale = - (height*groundK + impact*fabs(impact)*groundBeta);
+ // semiarbitrary force limit
if (fabs(scale)>groundK) {
// dissipate some extra energy
+ double body_impact = simdata::Dot(m_VelocityBody, bodyn);
if (impact < -10.0) {
//m_VelocityBody *= 0.50;
!
! m_VelocityBody -= 0.25 * body_impact * bodyn;
std::cout << "SLAM!!!!\n";
} else {
//m_VelocityBody *= 0.95;
! m_VelocityBody -= 0.05 * body_impact * bodyn;
std::cout << "SLAM!\n";
}
***************
*** 489,493 ****
--- 493,499 ----
simdata::Vector3 force = scale * bodyn;
+ // sliding velocity
V -= impact * m_GroundN;
+ // in body coordinates
V = LocalToBody(V);
if (height < -1.0) height = -1.0;
Index: CSPSim.cpp
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/CSPSim.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** CSPSim.cpp 11 Apr 2003 18:59:20 -0000 1.18
--- CSPSim.cpp 11 Apr 2003 23:43:06 -0000 1.19
***************
*** 47,50 ****
--- 47,51 ----
#include "Platform.h"
#include "SimObject.h"
+ #include "StaticObject.h"
#include "VirtualBattlefield.h"
#include "ConsoleCommands.h"
***************
*** 53,56 ****
--- 54,58 ----
#include <SimData/Exception.h>
#include <SimData/DataArchive.h>
+ #include <SimData/Exception.h>
SDLWave m_audioWave;
***************
*** 180,284 ****
}
void CSPSim::init()
{
- CSP_LOG(CSP_APP, CSP_INFO, "Starting CSPSim...");
-
- std::string data_path = g_Config.getPath("Paths", "DataPath", ".", true);
- std::string archive_file = ospath::join(data_path, "sim.dar");
-
- // open the primary data archive
try {
! m_DataArchive = new simdata::DataArchive(archive_file.c_str(), 1);
! assert(m_DataArchive);
! }
! catch (simdata::Exception e) {
! CSP_LOG(CSP_APP, CSP_ERROR, "Error opening data archive " << archive_file);
! CSP_LOG(CSP_APP, CSP_ERROR, e.getType() << ": " << e.getMessage());
! ::exit(0);
! }
!
! // initialize SDL
! initSDL();
!
! SDL_WM_SetCaption("CSPSim", "");
! // put up Logo screen then do rest of initialization
! LogoScreen logoScreen(m_ScreenWidth, m_ScreenHeight);
! logoScreen.OnInit();
! glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
! logoScreen.onRender();
! SDL_GL_SwapBuffers();
! // load all interface maps and create a virtual hid for the active object
! m_InterfaceMaps = new EventMapIndex();
! m_InterfaceMaps->loadAllMaps();
! m_Interface = new VirtualHID();
! // FIXME: these functions should be separated!
! // create the battlefield + scenegraph
! m_Battlefield = new VirtualBattlefield();
! m_Battlefield->create();
! m_Battlefield->buildScene();
! // eventually this will be set in an entirely different way...
! m_ActiveTerrain = m_DataArchive->getObject("sim:terrain.balkan");
! m_ActiveTerrain->activate(m_Battlefield);
!
! // get view parameters from configuration file. ultimately there should
! // be an in-game ui for this and probably a separate config file.
! bool wireframe = g_Config.getBool("View", "Wireframe", false, true);
! m_Battlefield->setWireframeMode(wireframe);
! int view_distance = g_Config.getInt("View", "ViewDistance", 35000, true);
! m_Battlefield->setViewDistance(view_distance);
! bool fog = g_Config.getBool("View", "Fog", true, true);
! m_Battlefield->setFogMode(fog);
! int fog_start = g_Config.getInt("View", "FogStart", 20000, true);
! m_Battlefield->setFogStart(fog_start);
! int fog_end = g_Config.getInt("View", "FogEnd", 35000, true);
! m_Battlefield->setFogEnd(fog_end);
! // create a couple test objects
! simdata::Pointer<AircraftObject> ao = m_DataArchive->getObject("sim:vehicles.aircraft.m2k");
! assert(ao.valid());
! //ao->setGlobalPosition(483000, 499000, 2000);
! ao->setGlobalPosition(483000, 499000, 91.2);
! ao->setOrientation(0, 5.0, 0);
! ao->setVelocity(0, 120.0, 0);
! ao->setVelocity(0, 2.0, 0);
! ao->addToScene(m_Battlefield);
! m_Battlefield->addObject(ao);
!
! /*
! simdata::Pointer<DynamicObject> to = m_DataArchive->getObject("sim:vehicles.aircraft.m2k");
! assert(to.valid());
! to->setGlobalPosition(483000, 501000, 0);
! to->addToScene(m_Battlefield);
! m_Battlefield->addObject(to);
! */
! // create screens
! m_GameScreen = new GameScreen;
! // setup screens
! m_GameScreen->SetBattlefield(m_Battlefield);
! m_GameScreen->OnInit();
! // start in the aircraft
! setActiveObject(ao);
#if 0
! // set the Main Menu then start the main loop
! m_MainMenuScreen = new MenuScreen;
! m_MainMenuScreen->OnInit();
! changeScreen(m_MainMenuScreen);
#endif
! changeScreen(m_GameScreen);
!
! logoScreen.OnExit();
}
--- 182,298 ----
}
+
void CSPSim::init()
{
try {
! CSP_LOG(CSP_APP, CSP_INFO, "Starting CSPSim...");
! std::string data_path = g_Config.getPath("Paths", "DataPath", ".", true);
! std::string archive_file = ospath::join(data_path, "sim.dar");
!
! // open the primary data archive
! try {
! m_DataArchive = new simdata::DataArchive(archive_file.c_str(), 1);
! assert(m_DataArchive);
! }
! catch (simdata::Exception e) {
! CSP_LOG(CSP_APP, CSP_ERROR, "Error opening data archive " << archive_file);
! CSP_LOG(CSP_APP, CSP_ERROR, e.getType() << ": " << e.getMessage());
! ::exit(0);
! }
!
! // initialize SDL
! initSDL();
! SDL_WM_SetCaption("CSPSim", "");
! // put up Logo screen then do rest of initialization
! LogoScreen logoScreen(m_ScreenWidth, m_ScreenHeight);
! logoScreen.OnInit();
! glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
! logoScreen.onRender();
! SDL_GL_SwapBuffers();
! // load all interface maps and create a virtual hid for the active object
! m_InterfaceMaps = new EventMapIndex();
! m_InterfaceMaps->loadAllMaps();
! m_Interface = new VirtualHID();
! // FIXME: these functions should be separated!
! // create the battlefield + scenegraph
! m_Battlefield = new VirtualBattlefield();
! m_Battlefield->create();
! m_Battlefield->buildScene();
! // eventually this will be set in an entirely different way...
! m_ActiveTerrain = m_DataArchive->getObject("sim:terrain.balkan");
! m_ActiveTerrain->activate(m_Battlefield);
! // get view parameters from configuration file. ultimately there should
! // be an in-game ui for this and probably a separate config file.
! bool wireframe = g_Config.getBool("View", "Wireframe", false, true);
! m_Battlefield->setWireframeMode(wireframe);
! int view_distance = g_Config.getInt("View", "ViewDistance", 35000, true);
! m_Battlefield->setViewDistance(view_distance);
! bool fog = g_Config.getBool("View", "Fog", true, true);
! m_Battlefield->setFogMode(fog);
! int fog_start = g_Config.getInt("View", "FogStart", 20000, true);
! m_Battlefield->setFogStart(fog_start);
! int fog_end = g_Config.getInt("View", "FogEnd", 35000, true);
! m_Battlefield->setFogEnd(fog_end);
! // create a couple test objects
! simdata::Pointer<AircraftObject> ao = m_DataArchive->getObject("sim:vehicles.aircraft.m2k");
! assert(ao.valid());
! //ao->setGlobalPosition(483000, 499000, 2000);
! ao->setGlobalPosition(483000, 499000, 91.2);
! ao->setOrientation(0, 5.0, 0);
! ao->setVelocity(0, 120.0, 0);
! ao->setVelocity(0, 2.0, 0);
! ao->addToScene(m_Battlefield);
! m_Battlefield->addObject(ao);
#if 0
! static simdata::Pointer<StaticObject> so = m_DataArchive->getObject("sim:objects.runway");
! assert(so.valid());
! so->setGlobalPosition(483000, 499000, 100.0);
! so->addToScene(m_Battlefield);
#endif
+ // create screens
+ m_GameScreen = new GameScreen;
! // setup screens
! m_GameScreen->SetBattlefield(m_Battlefield);
! m_GameScreen->OnInit();
!
! // start in the aircraft
! setActiveObject(ao);
!
! #if 0
! // set the Main Menu then start the main loop
! m_MainMenuScreen = new MenuScreen;
! m_MainMenuScreen->OnInit();
! changeScreen(m_MainMenuScreen);
! #endif
!
! changeScreen(m_GameScreen);
! logoScreen.OnExit();
! }
! catch(DemeterException * pEx) {
! CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught Demeter exception during initialazation: " << pEx->GetErrorMessage());
! ::exit(1);
! }
! catch(simdata::Exception * pEx) {
! CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught SimData exception during initialization: " << pEx->getMessage());
! ::exit(1);
! }
! catch (...) {
! CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught unknown exception during initialazation.");
! ::exit(1);
! }
}
***************
*** 408,417 ****
CSP_LOG(CSP_APP, CSP_ERROR, "Caught Demeter Exception: " << pEx->GetErrorMessage());
cleanup();
! ::exit(0);
}
catch(...) {
CSP_LOG(CSP_APP, CSP_ERROR, "MAIN: Unexpected exception, GLErrorNUM: " << glGetError());
cleanup();
! ::exit(0);
}
--- 422,431 ----
CSP_LOG(CSP_APP, CSP_ERROR, "Caught Demeter Exception: " << pEx->GetErrorMessage());
cleanup();
! ::exit(1);
}
catch(...) {
CSP_LOG(CSP_APP, CSP_ERROR, "MAIN: Unexpected exception, GLErrorNUM: " << glGetError());
cleanup();
! ::exit(1);
}
Index: ObjectModel.cpp
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/ObjectModel.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ObjectModel.cpp 24 Mar 2003 10:37:02 -0000 1.6
--- ObjectModel.cpp 11 Apr 2003 23:43:06 -0000 1.7
***************
*** 33,37 ****
--- 33,39 ----
#include <osgDB/ReadFile>
#include <osgUtil/SmoothingVisitor>
+ #include <osg/NodeVisitor>
#include <osg/Geometry>
+ #include <osg/Texture>
#include <osg/Geode>
***************
*** 40,43 ****
--- 42,92 ----
+ /**
+ * Visit nodes, applying anisotropic filtering to textures.
+ */
+ class TrilinearFilterVisitor: public osg::NodeVisitor
+ {
+ float m_MaxAnisotropy;
+ public:
+ TrilinearFilterVisitor(float MaxAnisotropy=16.0):
+ m_MaxAnisotropy(MaxAnisotropy),
+ osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {
+ }
+
+ virtual void apply(osg::Node& node) {
+ osg::StateSet* ss = node.getStateSet();
+ filter(ss);
+ traverse(node);
+ }
+
+ virtual void apply(osg::Geode& geode) {
+ osg::StateSet* ss = geode.getStateSet();
+ filter(ss);
+ for(unsigned int i=0;i<geode.getNumDrawables();++i) {
+ osg::Drawable* drawable = geode.getDrawable(i);
+ if (drawable) {
+ ss = drawable->getStateSet();
+ filter(ss);
+ }
+ }
+ }
+
+ void filter(osg::StateSet *set) {
+ if (!set) return;
+ osg::StateSet::TextureAttributeList& attr = set->getTextureAttributeList();
+ osg::StateSet::TextureAttributeList::iterator i;
+ for (i = attr.begin(); i != attr.end(); i++) {
+ osg::StateSet::AttributeList::iterator tex = i->find(osg::StateAttribute::TEXTURE);
+ if (tex != i->end()) {
+ osg::Texture* texture = dynamic_cast<osg::Texture*>(tex->second.first.get());
+ if (texture) {
+ texture->setMaxAnisotropy(m_MaxAnisotropy);
+ }
+ }
+ }
+ }
+ };
+
+
std::string g_ModelPath = "";
***************
*** 50,53 ****
--- 99,103 ----
m_Scale = 1.0;
m_Smooth = true;
+ m_Filter = true;
}
***************
*** 64,67 ****
--- 114,118 ----
p.pack(m_Scale);
p.pack(m_Smooth);
+ p.pack(m_Filter);
p.pack(m_Contacts);
}
***************
*** 76,79 ****
--- 127,131 ----
p.unpack(m_Scale);
p.unpack(m_Smooth);
+ p.unpack(m_Filter);
p.unpack(m_Contacts);
}
***************
*** 128,131 ****
--- 180,184 ----
}
+
void ObjectModel::loadModel() {
if (g_ModelPath == "") {
***************
*** 185,188 ****
--- 238,247 ----
osgUtil::SmoothingVisitor sv;
m_Transform->accept(sv);
+ }
+
+ if (m_Filter) {
+ // FIXME: level should come from global graphics settings
+ TrilinearFilterVisitor tfv(16.0);
+ m_Transform->accept(tfv);
}
Index: StaticObject.cpp
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/StaticObject.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** StaticObject.cpp 26 Jan 2003 23:33:38 -0000 1.2
--- StaticObject.cpp 11 Apr 2003 23:43:06 -0000 1.3
***************
*** 26,29 ****
--- 26,33 ----
#include "StaticObject.h"
+ #include <SimData/InterfaceRegistry.h>
+
+ //SIMDATA_REGISTER_INTERFACE(StaticObject)
+
StaticObject::StaticObject(): SimObject()
|