Revision: 1646
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1646&view=rev
Author: rorthomas
Date: 2011-02-05 23:44:50 +0000 (Sat, 05 Feb 2011)
Log Message:
-----------
code cleanup, improved directory structure
Added Paths:
-----------
trunk/source/main/main_sim/
trunk/source/main/main_sim/RigsOfRods.cpp
trunk/source/main/main_sim/RigsOfRods.h
trunk/source/main/main_sim/icon.rc
trunk/source/main/main_sim/main.cpp
trunk/source/main/main_sim/resource.h
trunk/source/main/main_sim/ror.ico
Added: trunk/source/main/main_sim/RigsOfRods.cpp
===================================================================
--- trunk/source/main/main_sim/RigsOfRods.cpp (rev 0)
+++ trunk/source/main/main_sim/RigsOfRods.cpp 2011-02-05 23:44:50 UTC (rev
1646)
@@ -0,0 +1,573 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005,2006,2007,2008,2009 Pierre-Michel Ricordel
+Copyright 2007,2008,2009 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "RigsOfRods.h"
+#include "OgreLineStreamOverlayElement.h"
+#include "language.h"
+#include "errorutils.h"
+#include "SoundScriptManager.h"
+
+#include <OgreHeaderPrefix.h>
+
+/** This class simply demonstrates basic usage of the CRTShader system.
+It sub class the material manager listener class and when a target scheme
callback
+is invoked with the shader generator scheme it tries to create an equvialent
shader
+based technique based on the default technique of the given material.
+*/
+class ShaderGeneratorTechniqueResolverListener : public
MaterialManager::Listener
+{
+public:
+
+ ShaderGeneratorTechniqueResolverListener(RTShader::ShaderGenerator*
pShaderGenerator)
+ {
+ mShaderGenerator = pShaderGenerator;
+ }
+
+ virtual Technique* handleSchemeNotFound(unsigned short schemeIndex,
+ const String& schemeName, Material* originalMaterial, unsigned
short lodIndex,
+ const Renderable* rend)
+ {
+ // Case this is the default shader generator scheme.
+ if (schemeName ==
RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME)
+ {
+ MaterialRegisterIterator itFind =
mRegisteredMaterials.find(originalMaterial);
+ bool techniqueCreated = false;
+
+ // This material was not registered before.
+ if (itFind == mRegisteredMaterials.end())
+ {
+ techniqueCreated =
mShaderGenerator->createShaderBasedTechnique(
+ originalMaterial->getName(),
+ MaterialManager::DEFAULT_SCHEME_NAME,
+ schemeName);
+ }
+ mRegisteredMaterials[originalMaterial] =
techniqueCreated;
+ }
+
+ return NULL;
+ }
+
+protected:
+ typedef std::map<Material*, bool> MaterialRegisterMap;
+ typedef MaterialRegisterMap::iterator MaterialRegisterIterator;
+
+protected:
+ MaterialRegisterMap mRegisteredMaterials;
// Registered material map.
+ RTShader::ShaderGenerator* mShaderGenerator;
// The shader generator instance.
+};
+
+RigsOfRods::RigsOfRods(Ogre::String name, unsigned int hwnd, unsigned int
mainhwnd) :
+ mRoot(0),
+ mCamera(0),
+ mSceneMgr(0),
+ mFrameListener(0),
+ mWindow(0),
+ ssm(0),
+ hwnd(hwnd),
+ mainhwnd(mainhwnd),
+ name(name)
+{
+ useogreconfig=false;
+}
+
+RigsOfRods::~RigsOfRods()
+{
+ // this is the end of all and everything
+ if (mFrameListener)
+ delete mFrameListener;
+ if (mRoot)
+ {
+ if (mWindow)
+ mRoot->detachRenderTarget(mWindow);
+ try
+ {
+ mRoot->shutdown();
+ // XXX : commented out code below crashes
+ //
+ //if(mRoot)
+ // delete mRoot;
+ } catch(Ogre::Exception& e)
+ {
+ LogManager::getSingleton().logMessage("error while
closing RoR: " + e.getFullDescription());
+ }
+ }
+}
+
+void RigsOfRods::go(void)
+{
+ if (!setup())
+ return;
+
+ mRoot->startRendering();
+
+ // clean up
+ //destroyScene(); we don't!
+}
+
+void RigsOfRods::loadMainResource(String name, String group)
+{
+ String dirsep="/";
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ dirsep="\\";
+#endif
+
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("Resources
Path")+dirsep+name, "FileSystem", group, true);
+ try
+ {
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("Resources
Path")+name+".zip", "Zip", group, true);
+ } catch(...) {}
+}
+
+bool RigsOfRods::setup(void)
+{
+ //try to get correct paths
+ //note: we don't have LogManager available yet!
+ //FIRST: Get the "program path" and the user space path
+
+ // note: this is now done in the settings class, so set it up
+ // note: you need to set the buildmode correcty before you build the
paths!
+ SETTINGS.setSetting("BuildMode", buildmode?"Yes":"No");
+ if(!SETTINGS.setupPaths())
+ return false;
+
+ // load RoR.cfg directly after setting up paths
+ SETTINGS.loadSettings(SETTINGS.getSetting("Config Root")+"RoR.cfg");
+
+ //CREATE OGRE ROOT
+ String logFilename = SETTINGS.getSetting("Log Path") + name +
Ogre::String(".log");
+ String pluginsConfig = SETTINGS.getSetting("plugins.cfg");
+ String ogreConfig = SETTINGS.getSetting("ogre.cfg");
+ mRoot = new Root(pluginsConfig, ogreConfig, logFilename);
+
+ // log verbosity change
+ if(SETTINGS.getSetting("Logging Level") == "verbose")
+ LogManager::getSingleton().setLogDetail(LL_BOREME);
+ else if(SETTINGS.getSetting("Logging Level") == "normal")
+ LogManager::getSingleton().setLogDetail(LL_NORMAL);
+ else if(SETTINGS.getSetting("Logging Level") == "low")
+ LogManager::getSingleton().setLogDetail(LL_LOW);
+ //FROM NOW ON WE HAVE LOGMANAGER!
+
+ // by default, display everything in the depth map
+ Ogre::MovableObject::setDefaultVisibilityFlags(DEPTHMAP_ENABLED);
+
+
+ CACHE.setLocation(SETTINGS.getSetting("Cache Path"),
SETTINGS.getSetting("Config Root"));
+
+ ColoredTextAreaOverlayElementFactory *cef = new
ColoredTextAreaOverlayElementFactory();
+ OverlayManager::getSingleton().addOverlayElementFactory(cef);
+
+ // load factory to be able to create stream lines
+ OverlayManager& overlayManager = OverlayManager::getSingleton();
+ overlayManager.addOverlayElementFactory(new
LineStreamOverlayElementFactory());
+
+#ifdef HAS_EDITOR
+ spinfact=new SpinControlOverlayElementFactory();
+ Ogre::OverlayManager::getSingleton().addOverlayElementFactory(spinfact);
+#endif
+
+ //load bootstrap and main resources
+ String dirsep="/";
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ dirsep="\\";
+#endif
+ //bootstrap
+ LogManager::getSingleton().logMessage("Loading Bootstrap");
+ loadMainResource("OgreCore", "Bootstrap");
+ //main game resources
+ LogManager::getSingleton().logMessage("Loading main resources");
+ loadMainResource("airfoils");
+ loadMainResource("materials");
+ loadMainResource("meshes");
+ loadMainResource("overlays");
+ loadMainResource("particles");
+ loadMainResource("mygui", "cache"); // HACK for mygui only supporting
one resource group
+ loadMainResource("scripts");
+ loadMainResource("textures");
+ loadMainResource("flags");
+ loadMainResource("icons");
+
+ // optional ones
+
+ // sound iss a bit special as we mark the base sounds so we dont clear
them accidentially later on
+#ifdef USE_OPENAL
+ LogManager::getSingleton().logMessage("Creating Sound Manager");
+ SoundScriptManager *ssm = SoundScriptManager::getSingleton();
+ if(ssm) ssm->setLoadingBaseSounds(true);
+#endif // USE_OPENAL
+ if (SETTINGS.getSetting("3D Sound renderer") != "No sound")
+ loadMainResource("sounds");
+
+ if (SETTINGS.getSetting("Sky effects") == "Caelum (best looking,
slower)")
+ loadMainResource("caelum");
+
+ if(SETTINGS.getSetting("Hydrax") == "Yes")
+ loadMainResource("hydrax", "Hydrax"); // special resourcegroup
required!
+
+ if(SETTINGS.getSetting("Vegetation") != "None (fastest)")
+ loadMainResource("paged");
+
+ if(SETTINGS.getSetting("HDR") == "Yes")
+ loadMainResource("hdr");
+
+ if(SETTINGS.getSetting("DOF") == "Yes")
+ loadMainResource("dof");
+
+ if(SETTINGS.getSetting("Glow") == "Yes")
+ loadMainResource("glow");
+
+ if(SETTINGS.getSetting("Motion blur") == "Yes")
+ loadMainResource("blur");
+
+ if(SETTINGS.getSetting("HeatHaze") == "Yes")
+ loadMainResource("heathaze");
+
+ if (SETTINGS.getSetting("Sunburn")!="Yes")
+ loadMainResource("sunburn");
+
+ if (SETTINGS.getSetting("Shadow technique")=="Parallel-split Shadow
Maps")
+ loadMainResource("pssm");
+
+ //streams path, to be processed later by the cache system
+ LogManager::getSingleton().logMessage("Loading filesystems");
+
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
Path")+"cache", "FileSystem", "cache");
+ //config, flat
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
Path")+"config", "FileSystem",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ //packs, to be processed later by the cache system
+
+ // add scripts folder
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
Path")+"scripts", "FileSystem", "Scripts", true);
+
+ // init skin manager, important to happen before trucks resource
loading!
+ LogManager::getSingleton().logMessage("registering Skin Manager");
+ new SkinManager();
+
+ LogManager::getSingleton().logMessage("registering colored text overlay
factory");
+ ColoredTextAreaOverlayElementFactory *pCT = new
ColoredTextAreaOverlayElementFactory();
+ OverlayManager::getSingleton().addOverlayElementFactory(pCT);
+
+ LogManager::getSingleton().logMessage("Configuring");
+ bool carryOn = configure();
+ if (!carryOn) return false;
+
+ //CREATE SCENE MANAGER
+ LogManager::getSingleton().logMessage("Creating Scene Manager");
+ if(SETTINGS.getSetting("new Terrain Mode") == "Yes")
+ {
+ mSceneMgr = mRoot->createSceneManager(ST_GENERIC);
+ } else
+ {
+ mSceneMgr = mRoot->createSceneManager(ST_EXTERIOR_CLOSE);
+ }
+
+ //CREATE CAMERA
+ LogManager::getSingleton().logMessage("Creating camera");
+ // Create the camera
+ mCamera = mSceneMgr->createCamera("PlayerCam");
+ // Position it at 500 in Z direction
+ mCamera->setPosition(Vector3(128,25,128));
+ // Look back along -Z
+ mCamera->lookAt(Vector3(0,0,-300));
+ mCamera->setNearClipDistance( 0.5 );
+ mCamera->setFarClipDistance( 1000.0*1.733 );
+ mCamera->setFOVy(Degree(60));
+ mCamera->setAutoAspectRatio(true);
+
+ //CREATE VIEWPORT
+ LogManager::getSingleton().logMessage("Creating Viewport");
+ // Create one viewport, entire window
+ vp = mWindow->addViewport(mCamera);
+ vp->setBackgroundColour(ColourValue(0,0,0));
+
+ // create RTShader System (after creating the viewport)
+ if (SETTINGS.getSetting("Use RTShader System")=="Yes")
+ initRTShaderSystem();
+
+ // Set default mipmap level (NB some APIs ignore this)
+ TextureManager::getSingleton().setDefaultNumMipmaps(5);
+ //mRoot->setFrameSmoothingPeriod(2.0);
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+#ifndef _UNICODE
+ if(hwnd == 0)
+ {
+ // only in non-embedded mode
+ size_t hWnd = 0;
+ mWindow->getCustomAttribute("WINDOW", &hWnd);
+
+ char buf[MAX_PATH];
+ ::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
+
+ HINSTANCE instance = ::GetModuleHandleA(buf);
+ HICON hIcon = ::LoadIconA(instance, MAKEINTRESOURCE(1001));
+ if (hIcon)
+ {
+ ::SendMessageA((HWND)hWnd, WM_SETICON, 1,
(LPARAM)hIcon);
+ ::SendMessageA((HWND)hWnd, WM_SETICON, 0,
(LPARAM)hIcon);
+ }
+ }
+#endif //_UNICODE
+#endif //OGRE_PLATFORM_WIN32
+
+ // load all resources now, so the zip files are also initiated
+ LogManager::getSingleton().logMessage("initialiseAllResourceGroups()");
+ try
+ {
+
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+ } catch(Ogre::Exception& e)
+ {
+ LogManager::getSingleton().logMessage("catched error while
initializing Resource groups: " + e.getFullDescription());
+ }
+#ifdef USE_OPENAL
+ if(ssm) ssm->setLoadingBaseSounds(false);
+#endif // USE_OPENAL
+
+
+ // and the content
+ //main synced streams
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("Streams
Path"), "FileSystem", "Streams");
+ exploreStreams(); //this will explore subdirs and register them as
Packs dirs
+ //cache, flat
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
Path")+"packs", "FileSystem", "Packs", true);
+ //user vehicles, to be processed later by the cache system
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
Path")+"vehicles", "FileSystem", "VehicleFolders");
+ exploreVehicles(); //this will add subdirs contents into General
+ //user terrains, to be processed later by the cache system
+
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
Path")+"terrains", "FileSystem", "TerrainFolders");
+ exploreTerrains(); //this will add subdirs contents into General
+ LogManager::getSingleton().logMessage("initialiseAllResourceGroups() -
Content");
+ try
+ {
+
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+ } catch(Ogre::Exception& e)
+ {
+ LogManager::getSingleton().logMessage("catched error while
initializing Content Resource groups: " + e.getFullDescription());
+ }
+
+
//rgm.initialiseResourceGroup(ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+
+#ifndef NOLANG
+ // load language, must happen after initializing Settings class and
Ogre Root!
+ // also it must happen after loading all basic resources!
+ LanguageEngine::Instance().setup();
+#endif //NOLANG
+
+ // Create the scene
+
+ LogManager::getSingleton().logMessage("createScene()");
+ createScene();
+
+ LogManager::getSingleton().logMessage("Adding Frame Listener");
+ bool isEmbedded = (hwnd != 0);
+ mFrameListener = new RoRFrameListener(mWindow, mCamera, mSceneMgr,
mRoot, isEmbedded, mainhwnd);
+ mRoot->addFrameListener(mFrameListener);
+
+ LogManager::getSingleton().logMessage("Setup finished successfully");
+ return true;
+}
+
+void RigsOfRods::initRTShaderSystem()
+{
+ if(!Ogre::RTShader::ShaderGenerator::initialize())
+ return;
+
+ // Add the shader libs resource location.
+ loadMainResource("rtshader");
+
+ // Grab the shader generator pointer.
+ mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
+
+ // Set shader cache path.
+ mShaderGenerator->setShaderCachePath(SETTINGS.getSetting("Cache Path"));
+
+ // Set the scene manager.
+ mShaderGenerator->addSceneManager(mSceneMgr);
+
+ //ShaderGeneratorTechniqueResolverListener *mMaterialMgrListener = new
ShaderGeneratorTechniqueResolverListener(mShaderGenerator);
+ //MaterialManager::getSingleton().addListener(mMaterialMgrListener);
+
+ // Apply the shader generated based techniques.
+
vp->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
+}
+
+void RigsOfRods::createScene(void)
+{
+ String tft=SETTINGS.getSetting("Texture Filtering");
+ TextureFilterOptions tfo=TFO_NONE;
+ if (tft=="Bilinear") tfo=TFO_BILINEAR;
+ if (tft=="Trilinear") tfo=TFO_TRILINEAR;
+ if (tft=="Anisotropic (best looking)") tfo=TFO_ANISOTROPIC;
+
+ // Set ambient light
+ // mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
+ mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
+ //lighten shadows
+ // mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5));
+
+ // Accept default settings: point light, white diffuse, just set
position
+ // NB I could attach the light to a SceneNode if I wanted it to move
automatically with
+ // other objects, but I don't
+ // l->setPosition(-20000,80000,-50000);
+
+ MaterialManager::getSingleton().setDefaultAnisotropy(8);
+ MaterialManager::getSingleton().setDefaultTextureFiltering(tfo);
+}
+
+bool RigsOfRods::configure(void)
+{
+ // Show the configuration dialog and initialise the system
+ // You can skip this and use root.restoreConfig() to load configuration
+ // settings if you were sure there are valid ones saved in ogre.cfg
+ if(hwnd == 0)
+ {
+ //default mode
+ bool ok = false;
+ if(useogreconfig)
+ ok = mRoot->showConfigDialog();
+ else
+ ok = mRoot->restoreConfig();
+ if(ok)
+ {
+ // If returned true, user clicked OK so initialise
+ // Here we choose to let the system create a default
rendering window by passing 'true'
+ mWindow = mRoot->initialise(true);
+ return true;
+ }
+ else
+ {
+ showError(_L("Configuration error"), _L("Run the
RoRconfig program first."));
+ return false;
+ }
+ } else
+ {
+ // embedded mode
+ if(!mRoot->restoreConfig())
+ {
+ showError(_L("Configuration error"), _L("Run the
RoRconfig program first."));
+ return false;
+ }
+
+ mRoot->initialise(false);
+
+ Ogre::NameValuePairList param;
+ param["externalWindowHandle"] =
Ogre::StringConverter::toString(hwnd);
+ mWindow = mRoot->createRenderWindow(name, 320, 240, false,
¶m);
+ return true;
+ }
+ return false;
+}
+
+void RigsOfRods::exploreStreams()
+{
+ String dirsep="/";
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ dirsep="\\";
+#endif
+ ResourceGroupManager& rgm = ResourceGroupManager::getSingleton();
+ //explore stream folders, add their content as packs
+ FileInfoListPtr files= rgm.findResourceFileInfo("Streams", "*", true);
//searching for dirs
+ FileInfoList::iterator iterFiles = files->begin();
+ for (; iterFiles!= files->end(); ++iterFiles)
+ {
+ if (iterFiles->filename==String(".svn")) continue;
+ String filename = SETTINGS.getSetting("Streams Path") +
(*iterFiles).filename;
+ rgm.addResourceLocation(filename, "FileSystem", "Packs");
+
+ // HACK: add subfolders
+ rgm.addResourceLocation(filename+dirsep+"vehicles",
"FileSystem", "streams");
+ rgm.addResourceLocation(filename+dirsep+"terrains",
"FileSystem", "streams");
+ }
+ LogManager::getSingleton().logMessage("initialiseResourceGroups:
streams");
+ try
+ {
+
ResourceGroupManager::getSingleton().initialiseResourceGroup("streams");
+ } catch(Ogre::Exception& e)
+ {
+ LogManager::getSingleton().logMessage("catched error while
initializing streams Resource groups: " + e.getFullDescription());
+ }
+}
+
+void RigsOfRods::exploreVehicles()
+{
+ String dirsep="/";
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ dirsep="\\";
+#endif
+ ResourceGroupManager& rgm = ResourceGroupManager::getSingleton();
+ //explore vehicles folders, add their content as flat
+ FileInfoListPtr files= rgm.findResourceFileInfo("VehicleFolders", "*",
true); //searching for dirs
+ FileInfoList::iterator iterFiles = files->begin();
+ for (; iterFiles!= files->end(); ++iterFiles)
+ {
+ if ((*iterFiles).filename==String(".svn")) continue;
+ //trying to get the full path
+ String fullpath=(*iterFiles).archive->getName()+dirsep;
+ rgm.addResourceLocation(fullpath+(*iterFiles).filename,
"FileSystem", "VehicleFolders");
+ //add textures/temp for unpacked ddx support
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"textures"+dirsep+"temp",
"FileSystem", "VehicleFolders");
+ }
+ LogManager::getSingleton().logMessage("initialiseResourceGroups:
VehicleFolders");
+ try
+ {
+
ResourceGroupManager::getSingleton().initialiseResourceGroup("VehicleFolders");
+ } catch(Ogre::Exception& e)
+ {
+ LogManager::getSingleton().logMessage("catched error while
initializing VehicleFolders Resource groups: " + e.getFullDescription());
+ }
+}
+
+void RigsOfRods::exploreTerrains()
+{
+ String dirsep="/";
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ dirsep="\\";
+#endif
+ ResourceGroupManager& rgm = ResourceGroupManager::getSingleton();
+ //explore vehicles folders, add their content as flat
+ FileInfoListPtr files= rgm.findResourceFileInfo("TerrainFolders", "*",
true); //searching for dirs
+ FileInfoList::iterator iterFiles = files->begin();
+ for (; iterFiles!= files->end(); ++iterFiles)
+ {
+ if ((*iterFiles).filename==String(".svn")) continue;
+ //trying to get the full path
+ String fullpath=(*iterFiles).archive->getName()+dirsep;
+ rgm.addResourceLocation(fullpath+(*iterFiles).filename,
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"textures"+dirsep+"temp",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"objects",
"FileSystem", "TerrainFolders");
+ // ogitor support below
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Caelum",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Hydrax",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Materials",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Models",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Scripts",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"SkyX",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Temp",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Templates",
"FileSystem", "TerrainFolders");
+
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"Terrain",
"FileSystem", "TerrainFolders");
+ }
+ LogManager::getSingleton().logMessage("initialiseResourceGroups:
TerrainFolders");
+ try
+ {
+
ResourceGroupManager::getSingleton().initialiseResourceGroup("TerrainFolders");
+ } catch(Ogre::Exception& e)
+ {
+ LogManager::getSingleton().logMessage("catched error while
initializing TerrainFolders Resource groups: " + e.getFullDescription());
+ }
+}
Added: trunk/source/main/main_sim/RigsOfRods.h
===================================================================
--- trunk/source/main/main_sim/RigsOfRods.h (rev 0)
+++ trunk/source/main/main_sim/RigsOfRods.h 2011-02-05 23:44:50 UTC (rev
1646)
@@ -0,0 +1,111 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005,2006,2007,2008,2009 Pierre-Michel Ricordel
+Copyright 2007,2008,2009 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*! @mainpage
+
+ have fun coding :)
+
+ please note that the documentation is work in progress
+*/
+#ifndef RIGSOFRODS_H__
+#define RIGSOFRODS_H__
+
+#include <Ogre.h>
+#include <OgreRTShaderSystem.h>
+#include <OgreConfigFile.h>
+#include <OgreConfigDialog.h>
+
+#include "RoRFrameListener.h"
+//#include "OgrePlatformManager.h"
+#ifdef HAS_EDITOR
+#include "spincontrol.h"
+#endif
+#include "Skidmark.h"
+#include "ColoredTextAreaOverlayElementFactory.h"
+#include "CacheSystem.h"
+#include "skinmanager.h"
+#include "Settings.h"
+
+using namespace Ogre;
+
+//#include "FlexMesh.h"
+#include "Beam.h"
+#include "OgreSceneManager.h"
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+//#include <CFUserNotification.h>
+#endif
+
+class RigsOfRods
+{
+public:
+ RigsOfRods(Ogre::String name = Ogre::String("RoR"), unsigned int
hwnd=0, unsigned int mainhwnd=0);
+ ~RigsOfRods();
+ // creates Ogre Root
+ bool setup(void);
+ // setup and start game
+ void go();
+ void shutdown(void);
+
+ bool useogreconfig;
+ bool buildmode;
+
+ SceneManager *getSceneManager() { return mSceneMgr; };
+ RenderWindow *getRenderWindow() { return mWindow; };
+ Camera *getCamera() { return mCamera; };
+ Viewport *getViewport() { return vp; };
+ Root *getRoot() { return mRoot; };
+ RoRFrameListener *getRoRFrameListener() { return mFrameListener; };
+
+ Ogre::RTShader::ShaderGenerator *getShaderGenerator() { return
mShaderGenerator; };
+
+protected:
+ Root *mRoot;
+ Camera* mCamera;
+ SceneManager* mSceneMgr;
+ RoRFrameListener* mFrameListener;
+ RenderWindow* mWindow;
+ SoundScriptManager* ssm;
+ Viewport* vp;
+ unsigned int hwnd, mainhwnd;
+ Ogre::String name;
+ Ogre::RTShader::ShaderGenerator *mShaderGenerator;
+
+#ifdef HAS_EDITOR
+ SpinControlOverlayElementFactory* spinfact;
+#endif
+
+ void loadMainResource(String name, String
group=ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+
+ void initRTShaderSystem();
+
+ // create scene
+ void createScene(void);
+
+ /** Configures the application - returns false if the user chooses to
abandon configuration. */
+ bool configure(void);
+
+ //resource utilities
+ void exploreStreams();
+ void exploreTerrains();
+ void exploreVehicles();
+};
+
+#endif //RIGSOFRODS_H__
Added: trunk/source/main/main_sim/icon.rc
===================================================================
--- trunk/source/main/main_sim/icon.rc (rev 0)
+++ trunk/source/main/main_sim/icon.rc 2011-02-05 23:44:50 UTC (rev 1646)
@@ -0,0 +1,72 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+//#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// French (France) resources
+
+//#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
+//#ifdef _WIN32
+//LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
+//#pragma code_page(1252)
+//#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1 ICON DISCARDABLE "ror.ico"
+
+//#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+//1 TEXTINCLUDE DISCARDABLE
+//BEGIN
+// "resource.h\0"
+//END
+
+//2 TEXTINCLUDE DISCARDABLE
+//BEGIN
+// "#include ""afxres.h""\r\n"
+// "\0"
+//END
+
+//3 TEXTINCLUDE DISCARDABLE
+//BEGIN
+// "\r\n"
+// "\0"
+//END
+
+//#endif // APSTUDIO_INVOKED
+
+//#endif // French (France) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+//#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+//#endif // not APSTUDIO_INVOKED
+
Added: trunk/source/main/main_sim/main.cpp
===================================================================
--- trunk/source/main/main_sim/main.cpp (rev 0)
+++ trunk/source/main/main_sim/main.cpp 2011-02-05 23:44:50 UTC (rev 1646)
@@ -0,0 +1,316 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005,2006,2007,2008,2009 Pierre-Michel Ricordel
+Copyright 2007,2008,2009 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef ROR_EMBEDDED
+
+#include "RigsOfRods.h"
+#include "language.h"
+#include "errorutils.h"
+
+Ogre::String getVersionString()
+{
+ char tmp[1024] = "";
+ sprintf(tmp, "Rigs of Rods\n"
+ " version: %s\n"
+ " revision: %s\n"
+ " full revision: %s\n"
+ " protocol version: %s\n"
+ " build time: %s, %s\n"
+ , ROR_VERSION_STRING, SVN_REVISION, SVN_ID, RORNET_VERSION,
__DATE__, __TIME__);
+ return Ogre::String(tmp);
+}
+
+#ifdef USE_CRASHRPT
+// see http://code.google.com/p/crashrpt/
+#include "crashrpt.h"
+
+// Define the crash callback
+BOOL WINAPI crashCallback(LPVOID /*lpvState*/)
+{
+ // Now add these two files to the error report
+
+ // logs
+ crAddFile((SETTINGS.getSetting("Log Path") + "RoR.log").c_str(), "Rigs
of Rods Log");
+ crAddFile((SETTINGS.getSetting("Log Path") + "mygui.log").c_str(),
"Rigs of Rods GUI Log");
+ crAddFile((SETTINGS.getSetting("Log Path") + "configlog.txt").c_str(),
"Rigs of Rods Configurator Log");
+ crAddFile((SETTINGS.getSetting("Program Path") + "wizard.log").c_str(),
"Rigs of Rods Installer Log");
+
+ // cache
+ crAddFile((SETTINGS.getSetting("Cache Path") + "mods.cache").c_str(),
"Rigs of Rods Cache File");
+
+ // configs
+ crAddFile((SETTINGS.getSetting("Config Root") +
"ground_models.cfg").c_str(), "Rigs of Rods Ground Configuration");
+ crAddFile((SETTINGS.getSetting("Config Root") + "input.map").c_str(),
"Rigs of Rods Input Configuration");
+ crAddFile((SETTINGS.getSetting("Config Root") + "ogre.cfg").c_str(),
"Rigs of Rods Renderer Configuration");
+ crAddFile((SETTINGS.getSetting("Config Root") + "RoR.cfg").c_str(),
"Rigs of Rods Configuration");
+
+ crAddProperty("Version", ROR_VERSION_STRING);
+ crAddProperty("Revision", SVN_REVISION);
+ crAddProperty("full_revision", SVN_ID);
+ crAddProperty("protocol_version", RORNET_VERSION);
+ crAddProperty("build_date", __DATE__);
+ crAddProperty("build_time", __TIME__);
+
+ crAddProperty("System_GUID", SETTINGS.getSetting("GUID").c_str());
+ crAddProperty("Multiplayer", (SETTINGS.getSetting("Network
enable")=="Yes")?"1":"0");
+
+ crAddScreenshot(CR_AS_MAIN_WINDOW);
+ // Return TRUE to allow crash report generation
+ return TRUE;
+}
+
+void install_crashrpt()
+{
+ // Install CrashRpt support
+ CR_INSTALL_INFO info;
+ memset(&info, 0, sizeof(CR_INSTALL_INFO));
+ info.cb = sizeof(CR_INSTALL_INFO);
+ info.pszAppName = "Rigs of Rods";
+ info.pszAppVersion = ROR_VERSION_STRING;
+ info.pszEmailSubject = "Error Report for Rigs of Rods";
+ info.pszEmailTo = "[email protected]";
+
+ char tmp[512]="";
+ sprintf(tmp, "http://api.rigsofrods.com/crashreport/?version=%s_%s",
__DATE__, __TIME__);
+ for(unsigned int i=0;i<strnlen(tmp, 512);i++)
+ {
+ if(tmp[i] == ' ')
+ tmp[i] = '_';
+ }
+
+ info.pszUrl = tmp;
+ info.pfnCrashCallback = crashCallback;
+ info.uPriorities[CR_HTTP] = 3; // Try HTTP the first
+ info.uPriorities[CR_SMTP] = 2; // Try SMTP the second
+ info.uPriorities[CR_SMAPI] = 1; // Try Simple MAPI the last
+ info.dwFlags = 0; // Install all available exception handlers
+ info.pszPrivacyPolicyURL =
"http://wiki.rigsofrods.com/pages/Crash_Report_Privacy_Policy"; // URL for the
Privacy Policy link
+
+ int nInstResult = crInstall(&info);
+ if(nInstResult!=0)
+ {
+ // Something goes wrong!
+ TCHAR szErrorMsg[512];
+ szErrorMsg[0]=0;
+
+ crGetLastErrorMsg(szErrorMsg, 512);
+ printf("%s\n", szErrorMsg);
+
+
+ showError("Exception handling registration problem",
String(szErrorMsg));
+
+ assert(nInstResult==0);
+ }
+}
+
+void uninstall_crashrpt()
+{
+ // Unset crash handlers
+ int nUninstResult = crUninstall();
+ assert(nUninstResult==0);
+}
+
+void test_crashrpt()
+{
+ // emulate null pointer exception (access violation)
+ crEmulateCrash(CR_WIN32_STRUCTURED_EXCEPTION);
+}
+#endif
+
+// simpleopt by http://code.jellycan.com/simpleopt/
+// license: MIT
+#include "SimpleOpt.h"
+
+#define HELPTEXT "--help (this)\n-map <map> (loads map on startup)\n-truck
<truck> (loads truck on startup)\n-setup shows the ogre configurator\n-version
shows the version information\n-enter enters the selected truck\n-userpath
<path> sets the user directory\nFor example: RoR.exe -map oahu -truck semi"
+
+// option identifiers
+enum { OPT_HELP, OPT_MAP, OPT_TRUCK, OPT_SETUP, OPT_CMD, OPT_WDIR, OPT_ETM,
OPT_BUILD, OPT_CONFIG, OPT_VER, OPT_CHECKCACHE, OPT_TRUCKCONFIG,
OPT_ENTERTRUCK, OPT_BENCH, OPT_STREAMCACHEGEN, OPT_BENCHNUM, OPT_USERPATH,
OPT_BENCHPOS, OPT_BENCHPOSERR, OPT_NOCRASHCRPT};
+
+// option array
+CSimpleOpt::SOption cmdline_options[] = {
+ { OPT_MAP, ((char *)"-map"), SO_REQ_SEP },
+ { OPT_MAP, ((char *)"-terrain"), SO_REQ_SEP },
+ { OPT_TRUCK, ((char *)"-truck"), SO_REQ_SEP },
+ { OPT_ENTERTRUCK, ((char *)"-enter"), SO_NONE },
+ { OPT_CMD, ((char *)"-cmd"), SO_REQ_SEP },
+ { OPT_WDIR, ((char *)"-wd"), SO_REQ_SEP },
+ { OPT_SETUP, ((char *)"-setup"), SO_NONE },
+ { OPT_CONFIG, ((char *)"-config"), SO_NONE },
+ { OPT_TRUCKCONFIG, ((char *)"-truckconfig"), SO_REQ_SEP },
+ { OPT_BUILD, ((char *)"-build"), SO_NONE },
+ { OPT_HELP, ((char *)"--help"), SO_NONE },
+ { OPT_HELP, ((char *)"-help"), SO_NONE },
+ { OPT_CHECKCACHE, ((char *)"-checkcache"), SO_NONE },
+ { OPT_VER, ((char *)"-version"), SO_NONE },
+ { OPT_USERPATH, ((char *)"-userpath"), SO_REQ_SEP },
+ { OPT_BENCH, ((char *)"-benchmark"), SO_REQ_SEP },
+ { OPT_BENCHPOS, ((char *)"-benchmark-final-position"),
SO_REQ_SEP },
+ { OPT_BENCHPOSERR, ((char *)"-benchmark-final-position-error"),
SO_REQ_SEP },
+ { OPT_BENCHNUM, ((char *)"-benchmarktrucks"), SO_REQ_SEP },
+ { OPT_BENCHNUM, ((char *)"-benchmark-trucks"), SO_REQ_SEP },
+ { OPT_STREAMCACHEGEN, ((char *)"-streamcachegen"), SO_NONE },
+ { OPT_NOCRASHCRPT, ((char *)"-nocrashrpt"), SO_NONE },
+SO_END_OF_OPTIONS
+};
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif //WIN32_LEAN_AND_MEAN
+#ifndef NOMINMAX
+#define NOMINMAX // required to stop windows.h messing up std::min
+#endif //NOMINMAX
+#include "windows.h"
+#include "ShellAPI.h"
+#endif //OGRE_PLATFORM_WIN32
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void showUsage()
+{
+ showInfo(_L("Command Line Arguments"), HELPTEXT);
+}
+
+void showVersion()
+{
+ showInfo(_L("Version Information"), getVersionString());
+#ifdef __GNUC__
+ printf(" * built with gcc %d.%d.%d\n", __GNUC_MINOR__, __GNUC_MINOR__,
__GNUC_PATCHLEVEL__);
+#endif //__GNUC__
+}
+
+int main(int argc, char *argv[])
+{
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+ //start working dir is highly unpredictable in MacOSX (typically you
start in "/"!)
+ //oh, thats quite hacked - thomas
+ char str[256];
+ strcpy(str, argv[0]);
+ char *pt=str+strlen(str);
+ while (*pt!='/') pt--;
+ *pt=0;
+ chdir(str);
+ chdir("../../..");
+ getwd(str);
+ printf("GETWD=%s\n", str);
+#endif
+
+ // Create application object
+ RigsOfRods app;
+ app.buildmode=false;
+
+//MacOSX adds an extra argument in the for of -psn_0_XXXXXX when the app is
double clicked
+#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE
+ CSimpleOpt args(argc, argv, cmdline_options);
+ while (args.Next()) {
+ if (args.LastError() == SO_SUCCESS) {
+ if (args.OptionId() == OPT_HELP) {
+ showUsage();
+ return 0;
+ } else if (args.OptionId() == OPT_TRUCK) {
+ SETTINGS.setSetting("Preselected Truck",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_TRUCKCONFIG) {
+ SETTINGS.setSetting("Preselected TruckConfig",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_MAP) {
+ SETTINGS.setSetting("Preselected Map",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_CMD) {
+ SETTINGS.setSetting("cmdline CMD",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_BENCH) {
+ SETTINGS.setSetting("Benchmark",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_BENCHNUM) {
+ SETTINGS.setSetting("BenchmarkTrucks",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_BENCHPOS) {
+ SETTINGS.setSetting("BenchmarkFinalPosition",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_BENCHPOSERR) {
+
SETTINGS.setSetting("BenchmarkFinalPositionError", String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_NOCRASHCRPT) {
+ SETTINGS.setSetting("NoCrashRpt", "Yes");
+ } else if (args.OptionId() == OPT_USERPATH) {
+ SETTINGS.setSetting("userpath",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_CONFIG) {
+ SETTINGS.setSetting("configfile",
String(args.OptionArg()));
+ } else if (args.OptionId() == OPT_WDIR) {
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+ SetCurrentDirectory(args.OptionArg());
+#endif
+ } else if (args.OptionId() == OPT_STREAMCACHEGEN) {
+
SETTINGS.setSetting("streamCacheGenerationOnly", "Yes");
+ } else if (args.OptionId() == OPT_CHECKCACHE) {
+ // just regen cache and exit
+ SETTINGS.setSetting("regen-cache-only", "True");
+ } else if (args.OptionId() == OPT_ENTERTRUCK) {
+ SETTINGS.setSetting("Enter Preselected Truck",
"Yes");
+ } else if (args.OptionId() == OPT_SETUP) {
+ app.useogreconfig = true;
+ } else if (args.OptionId() == OPT_BUILD) {
+ app.buildmode = true;
+ } else if (args.OptionId() == OPT_VER) {
+ showVersion();
+ return 0;
+ }
+ } else {
+ showUsage();
+ return 1;
+ }
+ }
+#endif
+
+#ifdef USE_CRASHRPT
+ if(SETTINGS.getSetting("NoCrashRpt").empty())
+ install_crashrpt();
+
+ //test_crashrpt();
+#endif //USE_CRASHRPT
+
+ try {
+ app.go();
+ } catch(Ogre::Exception& e)
+ {
+ // try to shutdown input system upon an error
+ if(InputEngine::instanceExists()) // this prevents the creating
of it, if not existing
+ INPUTENGINE.prepareShutdown();
+
+ String url =
"http://wiki.rigsofrods.com/index.php?title=Error_" +
StringConverter::toString(e.getNumber())+"#"+e.getSource();
+ showWebError("An exception has occured!",
e.getFullDescription(), url);
+ return 1;
+ }
+
+#ifdef USE_CRASHRPT
+ if(SETTINGS.getSetting("NoCrashRpt").empty())
+ uninstall_crashrpt();
+#endif //USE_CRASHRPT
+
+ return 0;
+}
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
+{
+ return main(__argc, __argv);
+}
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //ROR_EMBEDDED
\ No newline at end of file
Added: trunk/source/main/main_sim/resource.h
===================================================================
--- trunk/source/main/main_sim/resource.h (rev 0)
+++ trunk/source/main/main_sim/resource.h 2011-02-05 23:44:50 UTC (rev
1646)
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by icon.rc
+//
+#define IDI_ICON1 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
Added: trunk/source/main/main_sim/ror.ico
===================================================================
(Binary files differ)
Property changes on: trunk/source/main/main_sim/ror.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel