Revision: 1706
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1706&view=rev
Author:   rorthomas
Date:     2011-02-28 00:14:19 +0000 (Mon, 28 Feb 2011)

Log Message:
-----------
removed mirrors, added experimental videocameras
fixed content bugs

Modified Paths:
--------------
    trunk/source/main/RoRPrerequisites.h
    trunk/source/main/framework/ContentManager.cpp
    trunk/source/main/framework/ContentManager.h
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gameplay/RoRFrameListener.h
    trunk/source/main/gfx/envmap.cpp
    trunk/source/main/physics/Beam.cpp
    trunk/source/main/physics/Beam.h
    trunk/source/main/physics/BeamData.h
    trunk/source/main/physics/BeamFactory.cpp
    trunk/source/main/physics/BeamFactory.h
    trunk/source/main/physics/input_output/BeamLoadTruck.cpp

Added Paths:
-----------
    trunk/source/main/gfx/vidcam.cpp
    trunk/source/main/gfx/vidcam.h

Removed Paths:
-------------
    trunk/source/main/gfx/mirrors.cpp
    trunk/source/main/gfx/mirrors.h

Modified: trunk/source/main/RoRPrerequisites.h
===================================================================
--- trunk/source/main/RoRPrerequisites.h        2011-02-27 19:09:15 UTC (rev 
1705)
+++ trunk/source/main/RoRPrerequisites.h        2011-02-28 00:14:19 UTC (rev 
1706)
@@ -96,6 +96,7 @@
 class Turboprop;
 class TorqueCurve;
 class TruckHUD;
+class VideoCamera;
 class Water;
 
 namespace Ogre

Modified: trunk/source/main/framework/ContentManager.cpp
===================================================================
--- trunk/source/main/framework/ContentManager.cpp      2011-02-27 19:09:15 UTC 
(rev 1705)
+++ trunk/source/main/framework/ContentManager.cpp      2011-02-28 00:14:19 UTC 
(rev 1706)
@@ -195,20 +195,21 @@
 
        // and the content
        //main synced streams
-       
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("Streams
 Path"),      "FileSystem", "Streams", true);
+       
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("Streams
 Path"),      "FileSystem", "Streams");
        
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"packs", "FileSystem", "Packs", true);
        
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"mods",  "FileSystem", "Packs", true);
 
-       
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"vehicles", "FileSystem", "VehicleFolders", true);
-       
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"terrains", "FileSystem", "TerrainFolders", true);
+       
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"vehicles", "FileSystem", "VehicleFolders");
+       
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"terrains", "FileSystem", "TerrainFolders");
 
+       exploreFolders("VehicleFolders");
+       exploreFolders("TerrainFolders");
+       exploreFolders("Streams");
+
        LogManager::getSingleton().logMessage("initialiseAllResourceGroups() - 
Content");
        try
        {
-               
ResourceGroupManager::getSingleton().initialiseResourceGroup("Streams");
                
ResourceGroupManager::getSingleton().initialiseResourceGroup("Packs");
-               
ResourceGroupManager::getSingleton().initialiseResourceGroup("VehicleFolders");
-               
ResourceGroupManager::getSingleton().initialiseResourceGroup("TerrainFolders");
        } catch(Ogre::Exception& e)
        {
                LogManager::getSingleton().logMessage("catched error while 
initializing Content Resource groups: " + e.getFullDescription());
@@ -235,3 +236,31 @@
 {
        return false;
 }
+
+       
+void ContentManager::exploreFolders(Ogre::String rg)
+{
+       String dirsep="/";
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+       dirsep="\\";
+#endif
+       ResourceGroupManager& rgm = ResourceGroupManager::getSingleton();
+
+       FileInfoListPtr files= rgm.findResourceFileInfo(rg, "*", 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", rg);
+       }
+       LogManager::getSingleton().logMessage("initialiseResourceGroups: 
VehicleFolders");
+       try
+       {
+               
ResourceGroupManager::getSingleton().initialiseResourceGroup(rg);
+       } catch(Ogre::Exception& e)
+       {
+               LogManager::getSingleton().logMessage("catched error while 
initializing Resource group '" + rg + "' : " + e.getFullDescription());
+       }
+}
\ No newline at end of file

Modified: trunk/source/main/framework/ContentManager.h
===================================================================
--- trunk/source/main/framework/ContentManager.h        2011-02-27 19:09:15 UTC 
(rev 1705)
+++ trunk/source/main/framework/ContentManager.h        2011-02-28 00:14:19 UTC 
(rev 1706)
@@ -40,11 +40,13 @@
 
        void loadMainResource(Ogre::String name, Ogre::String 
group=Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
 
+       void exploreFolders(Ogre::String rg);
 
        // implementation for resource loading listener
        Ogre::DataStreamPtr resourceLoading(const Ogre::String &name, const 
Ogre::String &group, Ogre::Resource *resource);
        void resourceStreamOpened(const Ogre::String &name, const Ogre::String 
&group, Ogre::Resource *resource, Ogre::DataStreamPtr& dataStream);
        bool resourceCollision(Ogre::Resource *resource, Ogre::ResourceManager 
*resourceManager);
+
 };
 
 #endif // CONTENTMANAGER_H__

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2011-02-27 19:09:15 UTC 
(rev 1705)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2011-02-28 00:14:19 UTC 
(rev 1706)
@@ -49,6 +49,7 @@
 #include "TruckHUD.h"
 #include "DotSceneLoader.h"
 #include "AdvancedScreen.h"
+#include "vidcam.h"
 
 #ifdef USE_MPLATFORM
 #include "mplatform_fd.h"
@@ -96,7 +97,6 @@
 #include "LoadingWindow.h"
 #endif //MYGUI
 
-#include "mirrors.h"
 #include "autopilot.h"
 #include "ResourceBuffer.h"
 #include "CacheSystem.h"
@@ -846,7 +846,6 @@
        hidegui=false;
        collisions=0;
        editor=0;
-       mirror=0;
        dashboard=0;//new Dashboard(scm,win);
 
        mSceneMgr=scm;
@@ -1229,7 +1228,7 @@
 #endif //SOCKETW
 
        // new beam factory
-       new BeamFactory(this, trucks, mSceneMgr, mSceneMgr->getRootSceneNode(), 
mWindow, net, &mapsizex, &mapsizez, collisions, hfinder, w, mCamera, mirror);
+       new BeamFactory(this, trucks, mSceneMgr, mSceneMgr->getRootSceneNode(), 
mWindow, net, &mapsizex, &mapsizez, collisions, hfinder, w, mCamera);
 
 
        // setup a benchmark if required
@@ -4078,7 +4077,7 @@
                                        if(config.size() == 0) configptr = 0;
 
                                        localTruck = 
BeamFactory::getSingleton().createLocal(reload_pos, reload_dir, selected, 
reload_box, false, flaresMode, configptr, skin);
-                                       //trucks[free_truck] = new 
Beam(free_truck, mSceneMgr, mSceneMgr->getRootSceneNode(), mWindow, net, 
&mapsizex, &mapsizez, reload_pos.x, reload_pos.y, reload_pos.z, reload_dir, 
selected, collisions, dustp, clumpp, sparksp, dripp, splashp, ripplep, hfinder, 
w, mCamera, mirror, true, false, false, reload_box, false, flaresMode, 
configptr, skin);
+                                       //trucks[free_truck] = new 
Beam(free_truck, mSceneMgr, mSceneMgr->getRootSceneNode(), mWindow, net, 
&mapsizex, &mapsizez, reload_pos.x, reload_pos.y, reload_pos.z, reload_dir, 
selected, collisions, dustp, clumpp, sparksp, dripp, splashp, ripplep, hfinder, 
w, mCamera, true, false, false, reload_box, false, flaresMode, configptr, skin);
                                }
 
 
@@ -5421,13 +5420,6 @@
                envmap=new Envmap(mSceneMgr, mWindow, mCamera, 
SETTINGS.getSetting("Envmap")=="Yes");
        }
 
-       //mirrors!
-       if(SETTINGS.getSetting("Mirrors")=="Yes")
-       {
-               mirror = new Mirrors(mSceneMgr, mWindow, mCamera);
-       }
-       BeamFactory::getSingleton().mmirror0 = mirror;
-
        //dashboard
        // always enabled
        {
@@ -6158,9 +6150,7 @@
                                        }
                                }
                        }
-                       //trucks[free_truck]=new Beam(free_truck, mSceneMgr, 
mSceneMgr->getRootSceneNode(), mWindow, net, &mapsizex, &mapsizez, spawnpos.x, 
spawnpos.y, spawnpos.z, spawnrot, selectedchr, collisions, dustp, clumpp, 
sparksp, dripp, splashp, ripplep, hfinder, w, mCamera, mirror, false, false, 
netmode,0,false,flaresMode, truckconfig);
                        b = BeamFactory::getSingleton().createLocal(spawnpos, 
spawnrot, selectedchr, 0, false, flaresMode, truckconfig);
-//IMI - on network mode we should be directly jump in
                        if (b && enterTruck)
                        {
                                        cameramode = CAMERA_INT;
@@ -6171,7 +6161,6 @@
                } else
                {
                        Beam *b = 
BeamFactory::getSingleton().createLocal(Vector3(truckx, trucky, truckz), 
Quaternion::ZERO, selectedchr, 0, false, flaresMode, truckconfig);
-                       //trucks[free_truck]=new Beam(free_truck, mSceneMgr, 
mSceneMgr->getRootSceneNode(), mWindow, net, &mapsizex, &mapsizez, truckx, 
trucky, truckz, Quaternion::ZERO, selectedchr, collisions, dustp, clumpp, 
sparksp, dripp, splashp, ripplep, hfinder, w, mCamera, mirror, false, false, 
netmode,0,false,flaresMode, truckconfig);
                        if(b && enterTruck)
                        {
                                setCurrentTruck(b->trucknum);
@@ -6205,9 +6194,6 @@
                for (i=0; i<truck_preload_num; i++)
                {
                        Beam *b = 
BeamFactory::getSingleton().createLocal(Vector3(truck_preload[i].px, 
truck_preload[i].py, truck_preload[i].pz), truck_preload[i].rotation, 
truck_preload[i].name, 0, truck_preload[i].ismachine, flaresMode, truckconfig, 
0, truck_preload[i].freePosition);
-
-                       //trucks[free_truck]=new Beam(free_truck, mSceneMgr, 
mSceneMgr->getRootSceneNode(), mWindow, net,
-                       //      &mapsizex, &mapsizez, truck_preload[i].px, 
truck_preload[i].py, truck_preload[i].pz, truck_preload[i].rotation, 
truck_preload[i].name, collisions, dustp, clumpp, sparksp, dripp, splashp, 
ripplep, hfinder, w, mCamera, 
mirror,false,false,false,0,truck_preload[i].ismachine,flaresMode, truckconfig);
 #ifdef USE_MYGUI
                        if(b && bigMap)
                        {
@@ -6939,9 +6925,19 @@
        return true;
 }
 
-
 bool RoRFrameListener::updateTruckMirrors(float dt)
 {
+       // TODO: improve this so its usable from the outside as well
+       if(current_truck == -1 || !trucks[current_truck]) return false;
+
+       Beam *t = trucks[current_truck];
+       for(int i=0;i=t->vidcams.size(); i++)
+       {
+               VideoCamera *v = t->vidcams[i];
+               if(!v) continue;
+               v->update();
+       }
+#if 0
        //mirror
        if (mirror && current_truck!=-1)
        {
@@ -7028,6 +7024,8 @@
                }
        }
        return true;
+#endif //0
+       return true;
 }
 
 // Override frameStarted event to process that (don't care about frameEnded)
@@ -7093,9 +7091,12 @@
        }
 
        // updating mirrors fixes its shaking!
-       if (cameramode==CAMERA_INT)
-               updateTruckMirrors(dt);
+       // TODO
+       //if (cameramode==CAMERA_INT)
+       updateTruckMirrors(dt);
 
+
+
        moveCamera(dt); //antishaking
 
        // update water after the camera!

Modified: trunk/source/main/gameplay/RoRFrameListener.h
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.h       2011-02-27 19:09:15 UTC 
(rev 1705)
+++ trunk/source/main/gameplay/RoRFrameListener.h       2011-02-28 00:14:19 UTC 
(rev 1706)
@@ -79,7 +79,6 @@
 class Network;
 //class BeamJoystick;
 class Collisions;
-class Mirrors;
 class Beam;
 class MapControl;
 class HDRListener;
@@ -456,7 +455,6 @@
 
        Ogre::String terrainUID;
        Road *road;
-       Mirrors *mirror;
        Dashboard *dashboard;
        FILE *editorfd;
        //      Dirt *dirt;

Modified: trunk/source/main/gfx/envmap.cpp
===================================================================
--- trunk/source/main/gfx/envmap.cpp    2011-02-27 19:09:15 UTC (rev 1705)
+++ trunk/source/main/gfx/envmap.cpp    2011-02-28 00:14:19 UTC (rev 1706)
@@ -19,25 +19,8 @@
 */
 #include "envmap.h"
 #include "Beam.h"
-/*
-Camera *mloCamera;
 
-class MirrorsListener : public RenderTargetListener
-{
-public:
-void preRenderTargetUpdate(const RenderTargetEvent& evt)
-{
-//mloCamera->setFOVy(mloCamera->getFOVy()/2.0);
-}
-void postRenderTargetUpdate(const RenderTargetEvent& evt)
-{
-//mloCamera->setFOVy(mloCamera->getFOVy()*2.0);
-}
 
-};
-
-MirrorsListener mMirrorsListener;
-*/
 Envmap::Envmap(SceneManager *mSceneMgr, RenderWindow *mWindow, Camera *incam, 
bool dynamic)
 {
        isDynamic=dynamic;
@@ -141,6 +124,5 @@
 
 void Envmap::prepareShutdown()
 {
-       //if (rttTex) rttTex->removeListener(&mMirrorsListener);
 }
 

Deleted: trunk/source/main/gfx/mirrors.cpp
===================================================================
--- trunk/source/main/gfx/mirrors.cpp   2011-02-27 19:09:15 UTC (rev 1705)
+++ trunk/source/main/gfx/mirrors.cpp   2011-02-28 00:14:19 UTC (rev 1706)
@@ -1,78 +0,0 @@
-/*
-This source file is part of Rigs of Rods
-Copyright 2005-2011 Pierre-Michel Ricordel
-Copyright 2007-2011 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 "mirrors.h"
-#include "ResourceBuffer.h"
-#include <Ogre.h>
-
-Mirrors::Mirrors(Ogre::SceneManager *mSceneMgr, Ogre::RenderWindow *mWindow, 
Ogre::Camera *camera)
-: 
-mCamera(camera)
-, mMirrorCam(mSceneMgr->createCamera("MirrorCam"))
-, rttTex(0)
-, mat(Ogre::MaterialManager::getSingleton().getByName("mirror"))
-{
-
-               Ogre::TexturePtr rttTexPtr 
-                       = 
Ogre::TextureManager::getSingleton().createManual("mirrortexture"
-                               , 
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
-                               , Ogre::TEX_TYPE_2D
-                               , 128
-                               , 256
-                               , 0
-                               , Ogre::PF_R8G8B8
-                               , Ogre::TU_RENDERTARGET
-                               , new ResourceBuffer());
-               rttTex = rttTexPtr->getBuffer()->getRenderTarget();
-               
-               mMirrorCam->setNearClipDistance(0.2);
-               mMirrorCam->setFarClipDistance(mCamera->getFarClipDistance());
-               mMirrorCam->setFOVy(Ogre::Degree(50));
-               mMirrorCam->setAspectRatio(
-                       ((Ogre::Real)mWindow->getViewport(0)->getActualWidth() 
/ 
-                       
(Ogre::Real)mWindow->getViewport(0)->getActualHeight())/2.0);
-
-               Ogre::Viewport *v = rttTex->addViewport( mMirrorCam );
-               v->setClearEveryFrame( true );
-               v->setBackgroundColour( 
camera->getViewport()->getBackgroundColour() );
-
-               
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("mirrortexture");
-               mat->getTechnique(0)->getPass(0)->setLightingEnabled(false);
-               v->setOverlaysEnabled(false);
-       }
-
-void Mirrors::setActive(bool state)
-{
-       rttTex->setActive(state);
-       if (state)
-               
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("mirrortexture");
-       else
-               
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("mirror.dds");
-
-}
-
-void Mirrors::update(Ogre::Vector3 normal, Ogre::Vector3 center, Ogre::Radian 
rollangle)
-{
-       Ogre::Plane plane=Ogre::Plane(normal, center);
-       mMirrorCam->setPosition(center); 
-       Ogre::Vector3 
project=plane.projectVector(mCamera->getPosition()-center);
-       mMirrorCam->lookAt(mCamera->getPosition()-2*project); 
-       mMirrorCam->roll(rollangle);
-}
-

Deleted: trunk/source/main/gfx/mirrors.h
===================================================================
--- trunk/source/main/gfx/mirrors.h     2011-02-27 19:09:15 UTC (rev 1705)
+++ trunk/source/main/gfx/mirrors.h     2011-02-28 00:14:19 UTC (rev 1706)
@@ -1,50 +0,0 @@
-/*
-This source file is part of Rigs of Rods
-Copyright 2005-2011 Pierre-Michel Ricordel
-Copyright 2007-2011 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 __Mirrors_H__
-#define __Mirrors_H__
-
-
-#include "RoRPrerequisites.h"
-
-#include <OgrePrerequisites.h>
-#include <OgreMaterial.h>
-
-
-
-class Mirrors
-{
-private:
-       Ogre::Camera *mCamera;
-       Ogre::Camera *mMirrorCam;
-       Ogre::RenderTexture* rttTex;
-       Ogre::MaterialPtr mat;
-
-public:
-
-       Mirrors(Ogre::SceneManager *mSceneMgr, Ogre::RenderWindow *mWindow, 
Ogre::Camera *camera);
-       void setActive(bool state);
-       
-       void update(Ogre::Vector3 normal, Ogre::Vector3 center, Ogre::Radian 
rollangle);
-
-};
-
-
-
-#endif

Added: trunk/source/main/gfx/vidcam.cpp
===================================================================
--- trunk/source/main/gfx/vidcam.cpp                            (rev 0)
+++ trunk/source/main/gfx/vidcam.cpp    2011-02-28 00:14:19 UTC (rev 1706)
@@ -0,0 +1,135 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005-2011 Pierre-Michel Ricordel
+Copyright 2007-2011 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 "vidcam.h"
+#include "ResourceBuffer.h"
+#include <Ogre.h>
+
+using namespace Ogre;
+
+int VideoCamera::counter = 0;
+
+VideoCamera::VideoCamera(Ogre::SceneManager *mSceneMgr, Ogre::Camera *camera, 
Beam *truck) : mSceneMgr(mSceneMgr), camera(camera), truck(truck)
+       , mVidCam()
+       , rttTex(0)
+       , mat()
+{
+}
+
+void VideoCamera::init()
+{
+       mat = Ogre::MaterialManager::getSingleton().getByName(materialName);
+
+       mVidCam = mSceneMgr->createCamera(materialName + "_camera");
+
+       Ogre::TexturePtr rttTexPtr = 
Ogre::TextureManager::getSingleton().createManual(materialName + "_texture"
+                       , 
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
+                       , Ogre::TEX_TYPE_2D
+                       , texx
+                       , texy
+                       , 0
+                       , Ogre::PF_R8G8B8
+                       , Ogre::TU_RENDERTARGET
+                       , new ResourceBuffer());
+       rttTex = rttTexPtr->getBuffer()->getRenderTarget();
+               
+       mVidCam->setNearClipDistance(minclip);
+       mVidCam->setFarClipDistance(maxclip);
+       mVidCam->setFOVy(Ogre::Degree(fov));
+       mVidCam->setAspectRatio((float)texx/(float)texy);
+       Ogre::Viewport *v = rttTex->addViewport(mVidCam);
+       v->setClearEveryFrame(true);
+       v->setBackgroundColour(camera->getViewport()->getBackgroundColour());
+
+       disabledTexture = 
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName();
+
+       
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(materialName
 + "_texture");
+       mat->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+       v->setOverlaysEnabled(false);
+}
+
+void VideoCamera::setActive(bool state)
+{
+       rttTex->setActive(state);
+       if (state)
+               
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(materialName
 + "_texture");
+       else
+               
mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(disabledTexture);
+}
+
+void VideoCamera::update()
+{
+       // get the normal of the camera plane now
+       Vector3 normal=(truck->nodes[nx].smoothpos - 
truck->nodes[nref].smoothpos).crossProduct(truck->nodes[ny].smoothpos - 
truck->nodes[nref].smoothpos);
+       normal.normalise();
+
+       Vector3 mposition = truck->nodes[nref].smoothpos + offx 
*(truck->nodes[nx].smoothpos - truck->nodes[nref].smoothpos) + offy * 
(truck->nodes[ny].smoothpos - truck->nodes[nref].smoothpos);
+       Vector3 pos = mposition + normal * offz;
+
+       //orientation
+       Vector3 refx = truck->nodes[nx].smoothpos - 
truck->nodes[nref].smoothpos;
+       refx.normalise();
+       
+       Vector3 refy=refx.crossProduct(normal);
+       
+       //Quaternion rot = Quaternion(refx, normal, refy) * driverSeat->rot * 
Quaternion(Degree(180), Vector3::UNIT_Y); // rotate towards the driving 
direction
+       Quaternion rot = Quaternion(refx, normal, refy);
+
+       // set the new position / orientation to the camera
+       mVidCam->setPosition(pos);
+       mVidCam->setOrientation(rot);
+}
+
+
+
+VideoCamera *VideoCamera::parseLine(Ogre::SceneManager *mSceneMgr, 
Ogre::Camera *camera, Beam *truck, const char *fname, char *line, int 
linecounter)
+{
+       int nx=-1, ny=-1, nref=-1, offx=0, offy=0, offz=0, texx=256, texy=256, 
cammode=-1;
+       float fov=-1, minclip=-1, maxclip=-1;
+       char materialname[255] = "";
+       int result = sscanf(line,"%d, %d, %d, %d, %d, %d, %f, %d, %d, %f, %f, 
%d, %s", &nx, &ny, &nref, &offx, &offy, &offz, &fov, &texx, &texy, &minclip, 
&maxclip, &cammode, materialname);
+       if (result < 11 || result == EOF)
+       {
+               LogManager::getSingleton().logMessage("Error parsing File 
(videocamera) " + String(fname) +" line " + 
StringConverter::toString(linecounter) + ". trying to continue ...");
+               return 0;
+       }
+
+       // TODO check for correct and resonable values
+
+       VideoCamera *v = new VideoCamera(mSceneMgr, camera, truck);
+       v->fov = fov;
+       v->minclip = minclip;
+       v->maxclip = maxclip;
+       v->nx = nx;
+       v->ny = ny;
+       v->nref = nref;
+
+       v->offx = offx;
+       v->offy = offy;
+       v->offz = offz;
+
+       v->texx = texx;
+       v->texy = texy;
+       v->cammode = cammode;
+       v->materialName = String(materialname);
+
+       v->init();
+
+       return v;
+}
\ No newline at end of file

Added: trunk/source/main/gfx/vidcam.h
===================================================================
--- trunk/source/main/gfx/vidcam.h                              (rev 0)
+++ trunk/source/main/gfx/vidcam.h      2011-02-28 00:14:19 UTC (rev 1706)
@@ -0,0 +1,60 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005-2011 Pierre-Michel Ricordel
+Copyright 2007-2011 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 VIDCAM_H__
+#define VIDCAM_H__
+
+#include "RoRPrerequisites.h"
+
+#include <OgreMaterial.h>
+
+#include "Beam.h"
+
+class VideoCamera
+{
+public:
+       VideoCamera(Ogre::SceneManager *mSceneMgr, Ogre::Camera *camera, Beam 
*truck);
+
+       void init();
+
+       void update();
+
+       void setActive(bool state);
+       
+       static VideoCamera *parseLine(Ogre::SceneManager *mSceneMgr, 
Ogre::Camera *camera, Beam *truck, const char *fname, char *line, int 
linecounter);
+
+       float fov, minclip, maxclip;
+       int nx, ny, nref, offx, offy, offz, texx, texy, cammode;
+       Ogre::String materialName, disabledTexture;
+
+protected:
+       Ogre::SceneManager *mSceneMgr;
+       Ogre::Camera *camera;
+       Beam *truck;
+       static int counter;
+       Ogre::Camera *mCamera;
+       Ogre::Camera *mVidCam;
+       Ogre::RenderTexture* rttTex;
+       Ogre::MaterialPtr mat;
+
+};
+
+
+
+#endif // VIDCAM_H__

Modified: trunk/source/main/physics/Beam.cpp
===================================================================
--- trunk/source/main/physics/Beam.cpp  2011-02-27 19:09:15 UTC (rev 1705)
+++ trunk/source/main/physics/Beam.cpp  2011-02-28 00:14:19 UTC (rev 1706)
@@ -32,7 +32,7 @@
 #include "DustPool.h"
 #include "errorutils.h"
 #include "Replay.h"
-#include "mirrors.h"
+#include "vidcam.h"
 #include "autopilot.h"
 #include "ScopeLog.h"
 #include "network.h"
@@ -303,7 +303,7 @@
 
 }
 
-Beam::Beam(int tnum, SceneManager *manager, SceneNode *parent, RenderWindow* 
win, Network *_net, float *_mapsizex, float *_mapsizez, Real px, Real py, Real 
pz, Quaternion rot, const char* fname, Collisions *icollisions, HeightFinder 
*mfinder, Water *w, Camera *pcam, Mirrors *mmirror, bool networked, bool 
networking, collision_box_t *spawnbox, bool ismachine, int _flaresMode, 
std::vector<Ogre::String> *_truckconfig, Skin *skin, bool freeposition) : \
+Beam::Beam(int tnum, SceneManager *manager, SceneNode *parent, RenderWindow* 
win, Network *_net, float *_mapsizex, float *_mapsizez, Real px, Real py, Real 
pz, Quaternion rot, const char* fname, Collisions *icollisions, HeightFinder 
*mfinder, Water *w, Camera *pcam, bool networked, bool networking, 
collision_box_t *spawnbox, bool ismachine, int _flaresMode, 
std::vector<Ogre::String> *_truckconfig, Skin *skin, bool freeposition) : \
        deleting(false)
 {
 
@@ -358,6 +358,8 @@
        memset(this->airbrakes, 0, sizeof(Airbrake *) * MAX_AIRBRAKES); 
free_airbrake = 0;
        memset(this->skidtrails, 0, sizeof(Skidmark *) * (MAX_WHEELS*2)); 
useSkidmarks = false;
        memset(this->flexbodies, 0, sizeof(FlexBody *) * MAX_FLEXBODIES); 
free_flexbody = 0;
+       vidcams.clear();
+
        // clearing done
 
        externalcameramode=0;
@@ -479,7 +481,6 @@
        default_plastic_coef=0.0f;
        strcpy(default_beam_material, "tracks/beam");
        driversseatfound=false;
-       mirror=mmirror;
        leftMirrorAngle=0.52;
        rightMirrorAngle=-0.52;
        if(ismachine)
@@ -3981,7 +3982,7 @@
                //setting camera
                mCamera->setNearClipDistance( 0.1 );
                //activate mirror
-               if (mirror) mirror->setActive(true);
+               //if (mirror) mirror->setActive(true);
                //enable transparent seat
                MaterialPtr 
seatmat=(MaterialPtr)(MaterialManager::getSingleton().getByName("driversseat"));
                seatmat->setDepthWriteEnabled(false);
@@ -4022,7 +4023,7 @@
                //setting camera
                mCamera->setNearClipDistance( 0.5 );
                //desactivate mirror
-               if (mirror) mirror->setActive(false);
+               //if (mirror) mirror->setActive(false);
                //disable transparent seat
                MaterialPtr 
seatmat=(MaterialPtr)(MaterialManager::getSingleton().getByName("driversseat"));
                seatmat->setDepthWriteEnabled(true);

Modified: trunk/source/main/physics/Beam.h
===================================================================
--- trunk/source/main/physics/Beam.h    2011-02-27 19:09:15 UTC (rev 1705)
+++ trunk/source/main/physics/Beam.h    2011-02-28 00:14:19 UTC (rev 1706)
@@ -73,7 +73,6 @@
                , HeightFinder *mfinder
                , Water *w
                , Camera *pcam
-               , Mirrors *mmirror
                , bool networked=false
                , bool networking=false
                , collision_box_t *spawnbox=NULL
@@ -543,7 +542,6 @@
        char texname[1024];
        int hasEmissivePass;
        bool isInside;
-       Mirrors *mirror;
        bool beacon;
        bool driversseatfound;
        float totalmass;

Modified: trunk/source/main/physics/BeamData.h
===================================================================
--- trunk/source/main/physics/BeamData.h        2011-02-27 19:09:15 UTC (rev 
1705)
+++ trunk/source/main/physics/BeamData.h        2011-02-28 00:14:19 UTC (rev 
1706)
@@ -145,6 +145,7 @@
        BTS_COMMENT,
        BTS_SECTION,
        BTS_IN_SECTION,
+       BTS_VIDCAM,
 };
 
 
@@ -771,6 +772,7 @@
        FlexBody *flexbodies[MAX_FLEXBODIES];
        int free_flexbody;
 
+       std::vector <VideoCamera *> vidcams;
 
        char guid[128];
 };

Modified: trunk/source/main/physics/BeamFactory.cpp
===================================================================
--- trunk/source/main/physics/BeamFactory.cpp   2011-02-27 19:09:15 UTC (rev 
1705)
+++ trunk/source/main/physics/BeamFactory.cpp   2011-02-28 00:14:19 UTC (rev 
1706)
@@ -28,7 +28,6 @@
 #include "sha1.h"
 #include "pthread.h"
 #include "RoRFrameListener.h"
-#include "mirrors.h"
 
 #ifdef USE_MYGUI
 #include "gui_mp.h"
@@ -39,7 +38,7 @@
 
 template<> BeamFactory *StreamableFactory < BeamFactory, Beam >::ms_Singleton 
= 0;
 
-BeamFactory::BeamFactory(RoRFrameListener *efl, Beam **trucks, SceneManager 
*manager, SceneNode *parent, RenderWindow* win, Network *net, float *mapsizex, 
float *mapsizez, Collisions *icollisions, HeightFinder *mfinder, Water *w, 
Camera *pcam, Mirrors *mmirror0) : efl(efl), trucks(trucks), manager(manager), 
parent(parent), win(win), net(net), mapsizex(mapsizex), mapsizez(mapsizez), 
icollisions(icollisions), mfinder(mfinder), pcam(pcam), mmirror0(mmirror0)
+BeamFactory::BeamFactory(RoRFrameListener *efl, Beam **trucks, SceneManager 
*manager, SceneNode *parent, RenderWindow* win, Network *net, float *mapsizex, 
float *mapsizez, Collisions *icollisions, HeightFinder *mfinder, Water *w, 
Camera *pcam) : efl(efl), trucks(trucks), manager(manager), parent(parent), 
win(win), net(net), mapsizex(mapsizex), mapsizez(mapsizez), 
icollisions(icollisions), mfinder(mfinder), pcam(pcam)
 {
 }
 
@@ -103,7 +102,6 @@
                mfinder,
                w,
                pcam,
-               mmirror0,
                networked,
                networking,
                spawnbox,
@@ -188,7 +186,6 @@
                mfinder,
                w,
                pcam,
-               mmirror0,
                networked,
                networking,
                0,

Modified: trunk/source/main/physics/BeamFactory.h
===================================================================
--- trunk/source/main/physics/BeamFactory.h     2011-02-27 19:09:15 UTC (rev 
1705)
+++ trunk/source/main/physics/BeamFactory.h     2011-02-28 00:14:19 UTC (rev 
1706)
@@ -34,7 +34,7 @@
        friend class Network;
        friend class RoRFrameListener;
        public:
-       BeamFactory(RoRFrameListener *efl, Beam **trucks, SceneManager 
*manager, SceneNode *parent, RenderWindow* win, Network *net, float *mapsizex, 
float *mapsizez, Collisions *icollisions, HeightFinder *mfinder, Water *w, 
Camera *pcam, Mirrors *mmirror0);
+       BeamFactory(RoRFrameListener *efl, Beam **trucks, SceneManager 
*manager, SceneNode *parent, RenderWindow* win, Network *net, float *mapsizex, 
float *mapsizez, Collisions *icollisions, HeightFinder *mfinder, Water *w, 
Camera *pcam);
        ~BeamFactory();
 
        Beam *createLocal(int slotid);
@@ -55,7 +55,6 @@
        HeightFinder *mfinder;
        Water *w;
        Ogre::Camera *pcam;
-       Mirrors *mmirror0;
        Beam **trucks;
 
 

Modified: trunk/source/main/physics/input_output/BeamLoadTruck.cpp
===================================================================
--- trunk/source/main/physics/input_output/BeamLoadTruck.cpp    2011-02-27 
19:09:15 UTC (rev 1705)
+++ trunk/source/main/physics/input_output/BeamLoadTruck.cpp    2011-02-28 
00:14:19 UTC (rev 1706)
@@ -34,6 +34,7 @@
 #include "Settings.h"
 #include "CmdKeyInertia.h"
 #include "MeshObject.h"
+#include "vidcam.h"
 
 // TODO not really needed for truck loading, or used very rarely
 #include "collisions.h"
@@ -206,6 +207,8 @@
                if (!strcmp("flares2",line)) {mode=BTS_FLARES2;continue;};
                if (!strcmp("animators",line)) {mode=BTS_ANIMATORS;continue;};
                if (!strcmp("nodecollision",line)) 
{mode=BTS_NODECOLLISION;continue;};
+               if (!strcmp("videocamera",line)) {mode=BTS_VIDCAM;continue;};
+               
                if (!strncmp("detacher_group", line, 14))
                {
                        int detgroup = DEFAULT_DETACHER_GROUP;
@@ -3923,6 +3926,15 @@
 
                        nodes[nodenum].collRadius = radius;
                }
+               else if (mode==BTS_VIDCAM)
+               {
+                       VideoCamera *v = VideoCamera::parseLine(manager, 
mCamera, this, fname, line, linecounter);
+                       if(v)
+                       {
+                               vidcams.push_back(v);
+                       }
+                       continue;
+               }
        };
        
        


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to