Revision: 2714 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2714&view=rev Author: ulteq Date: 2012-05-26 22:03:20 +0000 (Sat, 26 May 2012) Log Message: ----------- moved survey map stuff to /terrain/map fixed character fixed autopilot fixed TerrainGeometryManager
Modified Paths: -------------- trunk/source/main/CMakeLists.txt trunk/source/main/gameplay/Character.cpp trunk/source/main/gameplay/autopilot.cpp trunk/source/main/gameplay/autopilot.h trunk/source/main/terrain/TerrainGeometryManager.cpp trunk/source/main/terrain/TerrainGeometryManager.h Added Paths: ----------- trunk/source/main/terrain/map/ trunk/source/main/terrain/map/MapControl.cpp trunk/source/main/terrain/map/MapControl.h trunk/source/main/terrain/map/MapEntity.cpp trunk/source/main/terrain/map/MapEntity.h trunk/source/main/terrain/map/MapTextureCreator.cpp trunk/source/main/terrain/map/MapTextureCreator.h Removed Paths: ------------- trunk/source/main/gui/MapControl.cpp trunk/source/main/gui/MapControl.h trunk/source/main/gui/MapEntity.cpp trunk/source/main/gui/MapEntity.h trunk/source/main/gui/MapTextureCreator.cpp trunk/source/main/gui/MapTextureCreator.h Modified: trunk/source/main/CMakeLists.txt =================================================================== --- trunk/source/main/CMakeLists.txt 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/CMakeLists.txt 2012-05-26 22:03:20 UTC (rev 2714) @@ -74,6 +74,7 @@ add_sub_dir(${BINNAME} audio) add_sub_dir(${BINNAME} gameplay) add_sub_dir(${BINNAME} terrain) + add_sub_dir(${BINNAME} terrain/map) add_sub_dir(${BINNAME} gfx) add_sub_dir(${BINNAME} gfx/camera) add_sub_dir(${BINNAME} gfx/dof) Modified: trunk/source/main/gameplay/Character.cpp =================================================================== --- trunk/source/main/gameplay/Character.cpp 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gameplay/Character.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -24,14 +24,13 @@ #include "collisions.h" #include "IHeightFinder.h" #include "InputEngine.h" -#include "IWater.h" #include "MapControl.h" #include "MapEntity.h" #include "network.h" #include "NetworkStreamManager.h" #include "PlayerColours.h" #include "utils.h" -#include "IHeightFinder.h" +#include "Water.h" using namespace Ogre; Modified: trunk/source/main/gameplay/autopilot.cpp =================================================================== --- trunk/source/main/gameplay/autopilot.cpp 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gameplay/autopilot.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -21,9 +21,8 @@ #include "BeamData.h" #include "IHeightFinder.h" -#include "IWater.h" #include "SoundScriptManager.h" -#include "IHeightFinder.h" +#include "Water.h" using namespace Ogre; Modified: trunk/source/main/gameplay/autopilot.h =================================================================== --- trunk/source/main/gameplay/autopilot.h 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gameplay/autopilot.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -17,41 +17,16 @@ 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 AUTOPILOT_H__ -#define AUTOPILOT_H__ +#ifndef __AutoPilot_H_ +#define __AutoPilot_H_ #include "RoRPrerequisites.h" #include "TerrainObjectManager.h" class Autopilot { -private: - int mode_heading; - int mode_alt; - bool mode_ias; - bool mode_gpws; - int alt; - int vs; - int ias; - node_t *ref_l; - node_t *ref_r; - node_t *ref_b; - node_t *ref_c; - float ref_span; - float last_elevator; - float last_aileron; - float last_rudder; - float last_gpws_height; - float last_pullup_height; - float lastradiov; - float lastradioh; - float lastradiorwh; - float lastradiorwd; - float last_closest_hdist; - - int trucknum; +public: -public: enum {HEADING_NONE, HEADING_FIXED, HEADING_WLV, HEADING_NAV}; enum {ALT_NONE, ALT_FIXED, ALT_VS}; enum {LOCALIZER_VERTICAL, LOCALIZER_HORIZONTAL, LOCALIZER_NDB, LOCALIZER_VOR}; @@ -80,7 +55,34 @@ void gpws_update(float spawnheight); void getRadioFix(TerrainObjectManager::localizer_t *localizers, int free_localizer, float *vdev, float *hdev); + + +private: + + int mode_heading; + int mode_alt; + bool mode_ias; + bool mode_gpws; + int alt; + int vs; + int ias; + node_t *ref_l; + node_t *ref_r; + node_t *ref_b; + node_t *ref_c; + float ref_span; + float last_elevator; + float last_aileron; + float last_rudder; + float last_gpws_height; + float last_pullup_height; + float lastradiov; + float lastradioh; + float lastradiorwh; + float lastradiorwd; + float last_closest_hdist; + + int trucknum; }; - -#endif // AUTOPILOT_H__ +#endif // __AutoPilot_H_ Deleted: trunk/source/main/gui/MapControl.cpp =================================================================== --- trunk/source/main/gui/MapControl.cpp 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gui/MapControl.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -1,179 +0,0 @@ -/* -This source file is part of Rigs of Rods -Copyright 2005-2012 Pierre-Michel Ricordel -Copyright 2007-2012 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/>. -*/ -#ifdef USE_MYGUI - -#include "MapControl.h" - -#include "BeamData.h" -#include "MapEntity.h" -#include "Ogre.h" - -using namespace Ogre; - -MapControl::MapControl(float mapsizex, float mapsizey, float mapsizez) : - mMapSize(Vector3(mapsizex, mapsizey, mapsizez)) - , mAlpha(1.0f) - , mScale(1.0f) - , mX(0) - , mY(0) -{ - initialiseByAttributes(this); - setVisibility(false); -} - -MapEntity *MapControl::createMapEntity(String type) -{ - MapEntity *entity = new MapEntity(this, type, mMapTexture); - mMapEntities.insert(entity); - return entity; -} - -MapEntity *MapControl::createNamedMapEntity(String name, String type) -{ - MapEntity *entity = createMapEntity(type); - mNamedEntities[name] = entity; - return entity; -} - -void MapControl::deleteMapEntity(MapEntity *entity) -{ - mMapEntities.erase(entity); -} - -MapEntity *MapControl::getEntityByName(String name) -{ - if (mNamedEntities.find(name) != mNamedEntities.end()) - { - return mNamedEntities[name]; - } - return NULL; -} - -bool MapControl::getVisibility() -{ - return mMainWidget->getVisible(); -} - -void MapControl::setAlpha(float value) -{ - mAlpha = value; - mMainWidget->setAlpha(value); -} - -void MapControl::setEntitiesVisibility(bool value) -{ - for (std::set<MapEntity *>::iterator it = mMapEntities.begin(); it != mMapEntities.end(); it++) - { - (*it)->setVisibility(value); - } -} - -void MapControl::setMapTexture(String name) -{ - mMapTexture->setImageTexture(name); -} - -void MapControl::setPosition(int x, int y, float size, Ogre::RenderWindow *rw) -{ - int realx, realy, realw, realh; - - mScale = size; - mX = x; - mY = y; - - updateRenderMetrics(rw); - - realw = realh = size * std::min(rWinWidth, rWinHeight); - - if (x == -1) - { - realx = 0; - } else if (x == 0) - { - realx = (rWinWidth - realw) / 2; - } else if (x == 1) - { - realx = rWinWidth - realw; - } - - if (y == -1) - { - realy = 0; - } else if (y == 0) - { - realy = (rWinHeight - realh) / 2; - } else if (y == 1) - { - realy = rWinHeight - realh; - } - - mMainWidget->setCoord(realx, realy, realw, realh); - - updateEntityPositions(); -} - -void MapControl::setVisibility(bool value) -{ - mMainWidget->setVisible(value); -} - -void MapControl::setWorldSize(float width, float length, float height) -{ - mMapSize = Vector3(width, length, height); -} - -void MapControl::windowResized(Ogre::RenderWindow *rw) -{ - setPosition(mX, mY, mScale, rw); -} - -String MapControl::getTypeByDriveable(int driveable) -{ - switch (driveable) - { - case NOT_DRIVEABLE: - return "load"; - case TRUCK: - return "truck"; - case AIRPLANE: - return "airplane"; - case BOAT: - return "boat"; - case MACHINE: - return "machine"; - default: - return "unknown"; - } -} - -void MapControl::updateEntityPositions() -{ - for (std::set<MapEntity *>::iterator it = mMapEntities.begin(); it != mMapEntities.end(); it++) - { - (*it)->update(); - } -} - -void MapControl::updateRenderMetrics(RenderWindow* win) -{ - win->getMetrics(rWinWidth, rWinHeight, rWinDepth, rWinLeft, rWinTop); -} - -#endif // USE_MYGUI Deleted: trunk/source/main/gui/MapControl.h =================================================================== --- trunk/source/main/gui/MapControl.h 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gui/MapControl.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -1,82 +0,0 @@ -/* -This source file is part of Rigs of Rods -Copyright 2005-2012 Pierre-Michel Ricordel -Copyright 2007-2012 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/>. -*/ -#ifdef USE_MYGUI - -#ifndef __MAP_CONTROL_H_ -#define __MAP_CONTROL_H_ - -#include "RoRPrerequisites.h" - -#include "mygui/BaseLayout.h" - -ATTRIBUTE_CLASS_LAYOUT(MapControl, "MapControl.layout"); - -class MapControl : public wraps::BaseLayout -{ -public: - - MapControl(float mapsizex, float mapsizey, float mapsizez); - - MapEntity *createMapEntity(Ogre::String type); - MapEntity *createNamedMapEntity(Ogre::String name, Ogre::String type); - - void deleteMapEntity(MapEntity *ent); - - MapEntity *getEntityByName(Ogre::String name); - Ogre::Vector3 getMapSize() { return mMapSize; }; - bool getVisibility(); - float getAlpha() { return mAlpha; } - float getWindowScale() { return mScale; } - - void setAlpha(float value); - void setEntitiesVisibility(bool value); - void setMapTexture(Ogre::String name); - void setPosition(int x, int y, float size, Ogre::RenderWindow *rw); - void setVisibility(bool value); - void setWorldSize(float width, float length, float height); - - void windowResized(Ogre::RenderWindow *rw); - - static Ogre::String getTypeByDriveable(int driveable); - -protected: - - float mAlpha, mScale; - int mX, mY; - - Ogre::Vector3 mMapSize; - - ATTRIBUTE_FIELD_WIDGET_NAME(MapControl, mMapTexture, "mMapTexture"); - MyGUI::StaticImage* mMapTexture; - - std::map<Ogre::String, MapEntity *> mNamedEntities; - std::set<MapEntity *> mMapEntities; - - void updateEntityPositions(); - - int rWinLeft, rWinTop; - unsigned int rWinWidth, rWinHeight, rWinDepth; - - void updateRenderMetrics(Ogre::RenderWindow* win); -}; - -#endif // __MAP_CONTROL_H_ - -#endif // USE_MYGUI Deleted: trunk/source/main/gui/MapEntity.cpp =================================================================== --- trunk/source/main/gui/MapEntity.cpp 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gui/MapEntity.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -1,220 +0,0 @@ -/* -This source file is part of Rigs of Rods -Copyright 2005-2012 Pierre-Michel Ricordel -Copyright 2007-2012 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/>. -*/ -#ifdef USE_MYGUI - -#include "Beam.h" -#include "MapEntity.h" -#include "MapControl.h" -#include "Ogre.h" - -using namespace Ogre; - -String MapEntity::entityStates[MaxEntityStates] = {"activated", "deactivated", "sleeping", "networked"}; - -MapEntity::MapEntity(MapControl *ctrl, String type, MyGUI::StaticImagePtr parent) : - mMapControl(ctrl) - , mType(type) - , mParent(parent) - , mRotation(0) - , mState(Sleeping) - , mX(0) - , mZ(0) -{ - initialiseByAttributes(this, parent); - - if (mIcon) - mIconRotating = mIcon->getSubWidgetMain()->castType<MyGUI::RotatingSkin>(false); - else - mIconRotating = nullptr; - - init(); -} - -void MapEntity::init() -{ - // check if static only icon - String imageFile = "icon_" + mType + ".dds"; - String group = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME; - - if (ResourceGroupManager::getSingleton().resourceExists(group, imageFile)) - { - //LOG("static map icon found: " + imageFile); - mIsStatic = true; - } else - { - LOG("static map icon not found: " + imageFile); - mIsStatic = false; - } - - setVisibility(false); - - updateIcon(); - update(); -} - -void MapEntity::setPosition(Vector3 pos) -{ - setPosition(pos.x, pos.z); -} - -void MapEntity::setPosition(float x, float z) -{ - bool needUpdate = false; - - if (fabs(x - mX) > 0.00001f || fabs(z - mZ) > 0.00001f) - { - needUpdate = true; - } - - mX = x; - mZ = z; - - if (needUpdate) - { - update(); - } -} - -void MapEntity::setRotation(Quaternion q) -{ - mRotation = q.getYaw().valueRadians() - Math::HALF_PI; - if (mIconRotating) mIconRotating->setAngle(-mRotation); -} - -void MapEntity::setRotation(Radian _r) -{ - mRotation = _r.valueRadians(); - if (mIconRotating) mIconRotating->setAngle(-mRotation); -} - -bool MapEntity::getVisibility() -{ - return mMainWidget->getVisible(); -} - -void MapEntity::setVisibility(bool value) -{ - mMainWidget->setVisible(value); -} - -void MapEntity::setState(int truckstate) -{ - if (mIsStatic) return; - - EntityStates mapstate = Sleeping; - - switch (truckstate) - { - case ACTIVATED: - mapstate = Activated; - break; - case DESACTIVATED: - case MAYSLEEP: - case GOSLEEP: - mapstate = Deactivated; - break; - case SLEEPING: - mapstate = Sleeping; - break; - case NETWORKED: - mapstate = Networked; - break; - default: - mapstate = Sleeping; - } - - if (mState != mapstate) - { - mState = mapstate; - update(); - } -} - -int MapEntity::getState() -{ - return mState; -} - -void MapEntity::update() -{ - float wscale = mMapControl->getWindowScale(); - - mCaption->setVisible(wscale > 0.5f); - - Vector3 mapSize = mMapControl->getMapSize(); - mMainWidget->setPosition( - mX / mapSize.x * mParent->getWidth() - mMainWidget->getWidth() / 2, - mZ / mapSize.z * mParent->getHeight() - mMainWidget->getHeight() / 2 - ); - mIcon->setCoord( - mMainWidget->getWidth() / 2 - mIconSize.width * wscale / 2, - mMainWidget->getHeight() / 2 - mIconSize.height * wscale / 2, - mIconSize.width * wscale, - mIconSize.height * wscale - ); - mIcon->setVisible(true); -} - -void MapEntity::setDescription(String s) -{ - mDescription = s; - mCaption->setCaption(mDescription); -} - -String MapEntity::getDescription() -{ - return mDescription; -} - -void MapEntity::updateIcon() -{ - // check if static only icon - String imageFile = "icon_" + mType + "_" + entityStates[mState] + ".dds"; - - if (mIsStatic) - { - imageFile = "icon_" + mType + ".dds"; - } - - // set image texture to load it into memory, so TextureManager::getByName will have it loaded if files exist - mIcon->setImageTexture(imageFile); - - TexturePtr texture = (TexturePtr)(TextureManager::getSingleton().getByName(imageFile)); - if (texture.isNull()) - { - imageFile = "icon_missing.dds"; - texture = (TexturePtr)(TextureManager::getSingleton().getByName(imageFile)); - } - - if (!texture.isNull()) - { - mIconSize.width = (int)texture->getWidth(); - mIconSize.height = (int)texture->getHeight(); - mIcon->setSize(mIconSize); - } - - if (mIconRotating) - { - mIconRotating->setCenter(MyGUI::IntPoint(mIcon->getWidth()/2, mIcon->getHeight()/2)); - mIconRotating->setAngle(mRotation); - } -} - -#endif // USE_MYGUI Deleted: trunk/source/main/gui/MapEntity.h =================================================================== --- trunk/source/main/gui/MapEntity.h 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gui/MapEntity.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -1,81 +0,0 @@ -/* -This source file is part of Rigs of Rods -Copyright 2005-2012 Pierre-Michel Ricordel -Copyright 2007-2012 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/>. -*/ -#ifdef USE_MYGUI - -#ifndef __MAP_ENTITY_H_ -#define __MAP_ENTITY_H_ - -#include "RoRPrerequisites.h" - -#include "mygui/BaseLayout.h" - -ATTRIBUTE_CLASS_LAYOUT(MapEntity, "MapEntity.layout"); - -class MapEntity : public wraps::BaseLayout -{ -public: - - MapEntity(MapControl *ctrl, Ogre::String type, MyGUI::StaticImagePtr parent); - - Ogre::String getDescription(); - bool getVisibility(); - int getState(); - - void setDescription(Ogre::String s); - void setPosition(Ogre::Vector3 pos); - void setPosition(float x, float z); - void setRotation(Ogre::Quaternion q); - void setRotation(Ogre::Radian r); - void setState(int state); - void setVisibility(bool value); - - void update(); - -private: - - MyGUI::StaticImagePtr mParent; - - ATTRIBUTE_FIELD_WIDGET_NAME(MapEntity, mCaption, "mCaption"); - MyGUI::StaticText *mCaption; - - ATTRIBUTE_FIELD_WIDGET_NAME(MapEntity, mIcon, "mIcon"); - MyGUI::StaticImage *mIcon; - MyGUI::RotatingSkin *mIconRotating; - - enum EntityStates {Activated, Deactivated, Sleeping, Networked, MaxEntityStates}; - - EntityStates mState; - MapControl *mMapControl; - MyGUI::IntSize mIconSize; - Ogre::Real mRotation; - Ogre::Real mX, mZ; - Ogre::String mDescription; - Ogre::String mType; - bool mIsStatic; - - void init(); - void updateIcon(); - - static Ogre::String entityStates[MaxEntityStates]; -}; - -#endif // __MAP_ENTITY_H_ - -#endif // USE_MYGUI Deleted: trunk/source/main/gui/MapTextureCreator.cpp =================================================================== --- trunk/source/main/gui/MapTextureCreator.cpp 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gui/MapTextureCreator.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -1,165 +0,0 @@ -/* -This source file is part of Rigs of Rods -Copyright 2005-2012 Pierre-Michel Ricordel -Copyright 2007-2012 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 "MapTextureCreator.h" - -#include "BeamFactory.h" -#include "ResourceBuffer.h" -#include "TerrainManager.h" - -using namespace Ogre; - -int MapTextureCreator::mCounter = 0; - -MapTextureCreator::MapTextureCreator() : - mCamera(NULL) - , mMapCenter(Vector3::ZERO) - , mMapZoom(0.0f) - , mMaterial(NULL) - , mRttTex(NULL) - , mStatics(NULL) - , mTextureUnitState(NULL) - , mViewport(NULL) -{ - mCounter++; - init(); -} - -bool MapTextureCreator::init() -{ - TexturePtr texture = TextureManager::getSingleton().createManual("MapRttTex" + TOSTRING(mCounter), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, 2048, 2048, TU_RENDERTARGET, PF_R8G8B8, TU_RENDERTARGET, new ResourceBuffer()); - - if ( texture.isNull() ) return false;; - - mRttTex = texture->getBuffer()->getRenderTarget(); - - if ( !mRttTex ) return false; - - mRttTex->setAutoUpdated(false); - - mCamera = gEnv->ogreSceneManager->createCamera("MapRenderCam" + TOSTRING(mCounter)); - - mViewport = mRttTex->addViewport(mCamera); - mViewport->setBackgroundColour(ColourValue::Black); - mViewport->setOverlaysEnabled(false); - - mMaterial = MaterialManager::getSingleton().create("MapRttMat" + TOSTRING(mCounter), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); - - if ( mMaterial.isNull() ) return false; - - mTextureUnitState = mMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("MapRttTex" + TOSTRING(mCounter)); - - mRttTex->addListener(this); - - mCamera->setFixedYawAxis(false); - mCamera->setProjectionType(PT_ORTHOGRAPHIC); - mCamera->setNearClipDistance(1.0f); - - return true; -} - -void MapTextureCreator::setMapZoom(Real zoomValue) -{ - mMapZoom = std::max(0.0f, zoomValue); - mMapZoom = std::min(zoomValue, 1.0f); -} - -void MapTextureCreator::setMapZoomRelative(Real zoomDelta) -{ - setMapZoom(mMapZoom + zoomDelta * mMapZoom / 100.0f); -} - -void MapTextureCreator::setMapCenter(Vector3 position) -{ - mMapCenter = position; - mMapCenter.y = 0.0f; -} - -void MapTextureCreator::setStaticGeometry(StaticGeometry *staticGeometry) -{ - mStatics = staticGeometry; -} - -void MapTextureCreator::update() -{ - if ( !mRttTex ) return; - - Vector3 mapSize = gEnv->terrainManager->getMax(); - float orthoWindowWidth = mapSize.x - (mapSize.x - 20.0f) * mMapZoom; - float orthoWindowHeight = mapSize.z - (mapSize.z - 20.0f) * mMapZoom; - - mCamera->setFarClipDistance(mapSize.y + 3.0f); - mCamera->setOrthoWindow(orthoWindowWidth, orthoWindowHeight); - mCamera->setPosition(mMapCenter + Vector3(0.0f, mapSize.y + 2.0f, 0.0f)); - mCamera->lookAt(mMapCenter); - - preRenderTargetUpdate(); - - mRttTex->update(); - - postRenderTargetUpdate(); -} - -String MapTextureCreator::getMaterialName() -{ - return "MapRttMat" + TOSTRING(mCounter); -} - -String MapTextureCreator::getRTName() -{ - return "MapRttTex" + TOSTRING(mCounter); -} - -void MapTextureCreator::preRenderTargetUpdate() -{ - Beam **trucks = BeamFactory::getSingleton().getTrucks(); - - float f = 20.0f + 30.0f * mMapZoom; - - for (int i=0; i < BeamFactory::getSingleton().getTruckCount(); i++) - { - if ( trucks[i] ) - { - trucks[i]->preMapLabelRenderUpdate(true, f); - } - } - - if ( mStatics ) - { - mStatics->setRenderingDistance(0); - } -} - -void MapTextureCreator::postRenderTargetUpdate() -{ - Beam **trucks = BeamFactory::getSingleton().getTrucks(); - - for (int i=0; i < BeamFactory::getSingleton().getTruckCount(); i++) - { - if ( trucks[i] ) - { - trucks[i]->preMapLabelRenderUpdate(false); - } - } - - if ( mStatics ) - { - mStatics->setRenderingDistance(1000); - } -} Deleted: trunk/source/main/gui/MapTextureCreator.h =================================================================== --- trunk/source/main/gui/MapTextureCreator.h 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/gui/MapTextureCreator.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -1,62 +0,0 @@ -/* -This source file is part of Rigs of Rods -Copyright 2005-2012 Pierre-Michel Ricordel -Copyright 2007-2012 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 __MapTextureCreator_H_ -#define __MapTextureCreator_H_ - -#include "RoRPrerequisites.h" - -#include "Ogre.h" - -class MapTextureCreator : public Ogre::RenderTargetListener -{ -public: - - MapTextureCreator(); - - Ogre::String getMaterialName(); - Ogre::String getRTName(); - - void setMapCenter(Ogre::Vector3 position); - void setMapZoom(Ogre::Real zoomValue); - void setMapZoomRelative(Ogre::Real zoomDelta); - void setStaticGeometry(Ogre::StaticGeometry *staticGeometry); - - void update(); - -protected: - - bool init(); - - void preRenderTargetUpdate(); - void postRenderTargetUpdate(); - - Ogre::Camera *mCamera; - Ogre::MaterialPtr mMaterial; - Ogre::Real mMapZoom; - Ogre::RenderTarget *mRttTex; - Ogre::StaticGeometry *mStatics; - Ogre::TextureUnitState *mTextureUnitState; - Ogre::Vector3 mMapCenter; - Ogre::Viewport *mViewport; - - static int mCounter; -}; - -#endif // __MapTextureCreator_H_ Modified: trunk/source/main/terrain/TerrainGeometryManager.cpp =================================================================== --- trunk/source/main/terrain/TerrainGeometryManager.cpp 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/terrain/TerrainGeometryManager.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -19,20 +19,16 @@ */ #include "TerrainGeometryManager.h" -#include "BeamFactory.h" -#include "CameraManager.h" -#include "RoRFrameListener.h" #include "SkyManager.h" +#include "TerrainManager.h" using namespace Ogre; TerrainGeometryManager::TerrainGeometryManager(TerrainManager *terrainManager) : - mSceneMgr(0) - , terrainManager(terrainManager) + terrainManager(terrainManager) , disableCaching(false) , mTerrainsImported(false) { - mSceneMgr = gEnv->ogreSceneManager; gEnv->heightFinder = this; } @@ -87,9 +83,9 @@ pageMaxY = PARSEINT(terrainConfig.getSetting("Pages_Y")); - Vector3 mTerrainPos(mapsizex*0.5f, 0, mapsizez * 0.5f); + Vector3 mTerrainPos(mapsizex / 2.0f, 0.0f, mapsizez / 2.0f); - mTerrainGroup = OGRE_NEW TerrainGroup(mSceneMgr, Terrain::ALIGN_X_Z, terrainSize, worldSize); + mTerrainGroup = OGRE_NEW TerrainGroup(gEnv->ogreSceneManager, Terrain::ALIGN_X_Z, terrainSize, worldSize); mTerrainGroup->setFilenameConvention(baseName, filenameSuffix); mTerrainGroup->setOrigin(mTerrainPos); mTerrainGroup->setResourceGroup("cache"); @@ -131,7 +127,7 @@ { OGRE_NEW TerrainGlobalOptions(); - Light *light = SkyManager::getSingleton().getMainLight(); + Light *light = gEnv->terrainManager->getSkyManager()->getMainLight(); TerrainGlobalOptions *terrainOptions = TerrainGlobalOptions::getSingletonPtr(); // Configure global terrainOptions->setMaxPixelError(PARSEINT(terrainConfig.getSetting("MaxPixelError"))); @@ -142,7 +138,7 @@ terrainOptions->setLightMapDirection(light->getDerivedDirection()); terrainOptions->setCompositeMapDiffuse(light->getDiffuseColour()); } - terrainOptions->setCompositeMapAmbient(mSceneMgr->getAmbientLight()); + terrainOptions->setCompositeMapAmbient(gEnv->ogreSceneManager->getAmbientLight()); // Configure default import settings for if we use imported image Ogre::Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings(); Modified: trunk/source/main/terrain/TerrainGeometryManager.h =================================================================== --- trunk/source/main/terrain/TerrainGeometryManager.h 2012-05-26 21:53:51 UTC (rev 2713) +++ trunk/source/main/terrain/TerrainGeometryManager.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -17,11 +17,13 @@ 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 TerrainGeometryManager_H__ -#define TerrainGeometryManager_H__ +#ifndef __TerrainGeometryManager_H_ +#define __TerrainGeometryManager_H_ #include "RoRPrerequisites.h" +#include "IHeightFinder.h" + #include <OgreTerrain.h> #include <OgreTerrainMaterialGeneratorA.h> #include <OgreTerrainPaging.h> @@ -30,8 +32,6 @@ #include <OgreConfigFile.h> -#include "IHeightFinder.h" - // this class handles all interactions with the Ogre Terrain system class TerrainGeometryManager : public IHeightFinder { @@ -59,15 +59,16 @@ } protected: + + Ogre::ConfigFile terrainConfig; + Ogre::String baseName; + TerrainManager *terrainManager; + TerrainObjectManager *objectManager; bool disableCaching; bool mTerrainsImported; - TerrainManager *terrainManager; int mapsizex, mapsizey, mapsizez, pageSize, terrainSize, worldSize; - Ogre::String baseName; - Ogre::ConfigFile terrainConfig; int pageMinX, pageMaxX, pageMinY, pageMaxY; int terrainLayers; - TerrainObjectManager *objectManager; // terrain engine specific Ogre::TerrainGroup *mTerrainGroup; @@ -82,13 +83,12 @@ std::vector<blendLayerInfo_t> blendInfo; - void initTerrain(); bool loadTerrainConfig(Ogre::String filename); void configureTerrainDefaults(); void defineTerrain(int x, int y, bool flat=false); + void getTerrainImage(int x, int y, Ogre::Image& img); void initBlendMaps( Ogre::Terrain* t ); - void getTerrainImage(int x, int y, Ogre::Image& img); + void initTerrain(); }; -#endif // TerrainGeometryManager_H__ - +#endif // __TerrainGeometryManager_H_ Added: trunk/source/main/terrain/map/MapControl.cpp =================================================================== --- trunk/source/main/terrain/map/MapControl.cpp (rev 0) +++ trunk/source/main/terrain/map/MapControl.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -0,0 +1,179 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2012 Pierre-Michel Ricordel +Copyright 2007-2012 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/>. +*/ +#ifdef USE_MYGUI + +#include "MapControl.h" + +#include "BeamData.h" +#include "MapEntity.h" +#include "Ogre.h" + +using namespace Ogre; + +MapControl::MapControl(float mapsizex, float mapsizey, float mapsizez) : + mMapSize(Vector3(mapsizex, mapsizey, mapsizez)) + , mAlpha(1.0f) + , mScale(1.0f) + , mX(0) + , mY(0) +{ + initialiseByAttributes(this); + setVisibility(false); +} + +MapEntity *MapControl::createMapEntity(String type) +{ + MapEntity *entity = new MapEntity(this, type, mMapTexture); + mMapEntities.insert(entity); + return entity; +} + +MapEntity *MapControl::createNamedMapEntity(String name, String type) +{ + MapEntity *entity = createMapEntity(type); + mNamedEntities[name] = entity; + return entity; +} + +void MapControl::deleteMapEntity(MapEntity *entity) +{ + mMapEntities.erase(entity); +} + +MapEntity *MapControl::getEntityByName(String name) +{ + if (mNamedEntities.find(name) != mNamedEntities.end()) + { + return mNamedEntities[name]; + } + return NULL; +} + +bool MapControl::getVisibility() +{ + return mMainWidget->getVisible(); +} + +void MapControl::setAlpha(float value) +{ + mAlpha = value; + mMainWidget->setAlpha(value); +} + +void MapControl::setEntitiesVisibility(bool value) +{ + for (std::set<MapEntity *>::iterator it = mMapEntities.begin(); it != mMapEntities.end(); it++) + { + (*it)->setVisibility(value); + } +} + +void MapControl::setMapTexture(String name) +{ + mMapTexture->setImageTexture(name); +} + +void MapControl::setPosition(int x, int y, float size, Ogre::RenderWindow *rw) +{ + int realx, realy, realw, realh; + + mScale = size; + mX = x; + mY = y; + + updateRenderMetrics(rw); + + realw = realh = size * std::min(rWinWidth, rWinHeight); + + if (x == -1) + { + realx = 0; + } else if (x == 0) + { + realx = (rWinWidth - realw) / 2; + } else if (x == 1) + { + realx = rWinWidth - realw; + } + + if (y == -1) + { + realy = 0; + } else if (y == 0) + { + realy = (rWinHeight - realh) / 2; + } else if (y == 1) + { + realy = rWinHeight - realh; + } + + mMainWidget->setCoord(realx, realy, realw, realh); + + updateEntityPositions(); +} + +void MapControl::setVisibility(bool value) +{ + mMainWidget->setVisible(value); +} + +void MapControl::setWorldSize(float width, float length, float height) +{ + mMapSize = Vector3(width, length, height); +} + +void MapControl::windowResized(Ogre::RenderWindow *rw) +{ + setPosition(mX, mY, mScale, rw); +} + +String MapControl::getTypeByDriveable(int driveable) +{ + switch (driveable) + { + case NOT_DRIVEABLE: + return "load"; + case TRUCK: + return "truck"; + case AIRPLANE: + return "airplane"; + case BOAT: + return "boat"; + case MACHINE: + return "machine"; + default: + return "unknown"; + } +} + +void MapControl::updateEntityPositions() +{ + for (std::set<MapEntity *>::iterator it = mMapEntities.begin(); it != mMapEntities.end(); it++) + { + (*it)->update(); + } +} + +void MapControl::updateRenderMetrics(RenderWindow* win) +{ + win->getMetrics(rWinWidth, rWinHeight, rWinDepth, rWinLeft, rWinTop); +} + +#endif // USE_MYGUI Added: trunk/source/main/terrain/map/MapControl.h =================================================================== --- trunk/source/main/terrain/map/MapControl.h (rev 0) +++ trunk/source/main/terrain/map/MapControl.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -0,0 +1,82 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2012 Pierre-Michel Ricordel +Copyright 2007-2012 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/>. +*/ +#ifdef USE_MYGUI + +#ifndef __MAP_CONTROL_H_ +#define __MAP_CONTROL_H_ + +#include "RoRPrerequisites.h" + +#include "mygui/BaseLayout.h" + +ATTRIBUTE_CLASS_LAYOUT(MapControl, "MapControl.layout"); + +class MapControl : public wraps::BaseLayout +{ +public: + + MapControl(float mapsizex, float mapsizey, float mapsizez); + + MapEntity *createMapEntity(Ogre::String type); + MapEntity *createNamedMapEntity(Ogre::String name, Ogre::String type); + + void deleteMapEntity(MapEntity *ent); + + MapEntity *getEntityByName(Ogre::String name); + Ogre::Vector3 getMapSize() { return mMapSize; }; + bool getVisibility(); + float getAlpha() { return mAlpha; } + float getWindowScale() { return mScale; } + + void setAlpha(float value); + void setEntitiesVisibility(bool value); + void setMapTexture(Ogre::String name); + void setPosition(int x, int y, float size, Ogre::RenderWindow *rw); + void setVisibility(bool value); + void setWorldSize(float width, float length, float height); + + void windowResized(Ogre::RenderWindow *rw); + + static Ogre::String getTypeByDriveable(int driveable); + +protected: + + float mAlpha, mScale; + int mX, mY; + + Ogre::Vector3 mMapSize; + + ATTRIBUTE_FIELD_WIDGET_NAME(MapControl, mMapTexture, "mMapTexture"); + MyGUI::StaticImage* mMapTexture; + + std::map<Ogre::String, MapEntity *> mNamedEntities; + std::set<MapEntity *> mMapEntities; + + void updateEntityPositions(); + + int rWinLeft, rWinTop; + unsigned int rWinWidth, rWinHeight, rWinDepth; + + void updateRenderMetrics(Ogre::RenderWindow* win); +}; + +#endif // __MAP_CONTROL_H_ + +#endif // USE_MYGUI Added: trunk/source/main/terrain/map/MapEntity.cpp =================================================================== --- trunk/source/main/terrain/map/MapEntity.cpp (rev 0) +++ trunk/source/main/terrain/map/MapEntity.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -0,0 +1,220 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2012 Pierre-Michel Ricordel +Copyright 2007-2012 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/>. +*/ +#ifdef USE_MYGUI + +#include "Beam.h" +#include "MapEntity.h" +#include "MapControl.h" +#include "Ogre.h" + +using namespace Ogre; + +String MapEntity::entityStates[MaxEntityStates] = {"activated", "deactivated", "sleeping", "networked"}; + +MapEntity::MapEntity(MapControl *ctrl, String type, MyGUI::StaticImagePtr parent) : + mMapControl(ctrl) + , mType(type) + , mParent(parent) + , mRotation(0) + , mState(Sleeping) + , mX(0) + , mZ(0) +{ + initialiseByAttributes(this, parent); + + if (mIcon) + mIconRotating = mIcon->getSubWidgetMain()->castType<MyGUI::RotatingSkin>(false); + else + mIconRotating = nullptr; + + init(); +} + +void MapEntity::init() +{ + // check if static only icon + String imageFile = "icon_" + mType + ".dds"; + String group = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME; + + if (ResourceGroupManager::getSingleton().resourceExists(group, imageFile)) + { + //LOG("static map icon found: " + imageFile); + mIsStatic = true; + } else + { + LOG("static map icon not found: " + imageFile); + mIsStatic = false; + } + + setVisibility(false); + + updateIcon(); + update(); +} + +void MapEntity::setPosition(Vector3 pos) +{ + setPosition(pos.x, pos.z); +} + +void MapEntity::setPosition(float x, float z) +{ + bool needUpdate = false; + + if (fabs(x - mX) > 0.00001f || fabs(z - mZ) > 0.00001f) + { + needUpdate = true; + } + + mX = x; + mZ = z; + + if (needUpdate) + { + update(); + } +} + +void MapEntity::setRotation(Quaternion q) +{ + mRotation = q.getYaw().valueRadians() - Math::HALF_PI; + if (mIconRotating) mIconRotating->setAngle(-mRotation); +} + +void MapEntity::setRotation(Radian _r) +{ + mRotation = _r.valueRadians(); + if (mIconRotating) mIconRotating->setAngle(-mRotation); +} + +bool MapEntity::getVisibility() +{ + return mMainWidget->getVisible(); +} + +void MapEntity::setVisibility(bool value) +{ + mMainWidget->setVisible(value); +} + +void MapEntity::setState(int truckstate) +{ + if (mIsStatic) return; + + EntityStates mapstate = Sleeping; + + switch (truckstate) + { + case ACTIVATED: + mapstate = Activated; + break; + case DESACTIVATED: + case MAYSLEEP: + case GOSLEEP: + mapstate = Deactivated; + break; + case SLEEPING: + mapstate = Sleeping; + break; + case NETWORKED: + mapstate = Networked; + break; + default: + mapstate = Sleeping; + } + + if (mState != mapstate) + { + mState = mapstate; + update(); + } +} + +int MapEntity::getState() +{ + return mState; +} + +void MapEntity::update() +{ + float wscale = mMapControl->getWindowScale(); + + mCaption->setVisible(wscale > 0.5f); + + Vector3 mapSize = mMapControl->getMapSize(); + mMainWidget->setPosition( + mX / mapSize.x * mParent->getWidth() - mMainWidget->getWidth() / 2, + mZ / mapSize.z * mParent->getHeight() - mMainWidget->getHeight() / 2 + ); + mIcon->setCoord( + mMainWidget->getWidth() / 2 - mIconSize.width * wscale / 2, + mMainWidget->getHeight() / 2 - mIconSize.height * wscale / 2, + mIconSize.width * wscale, + mIconSize.height * wscale + ); + mIcon->setVisible(true); +} + +void MapEntity::setDescription(String s) +{ + mDescription = s; + mCaption->setCaption(mDescription); +} + +String MapEntity::getDescription() +{ + return mDescription; +} + +void MapEntity::updateIcon() +{ + // check if static only icon + String imageFile = "icon_" + mType + "_" + entityStates[mState] + ".dds"; + + if (mIsStatic) + { + imageFile = "icon_" + mType + ".dds"; + } + + // set image texture to load it into memory, so TextureManager::getByName will have it loaded if files exist + mIcon->setImageTexture(imageFile); + + TexturePtr texture = (TexturePtr)(TextureManager::getSingleton().getByName(imageFile)); + if (texture.isNull()) + { + imageFile = "icon_missing.dds"; + texture = (TexturePtr)(TextureManager::getSingleton().getByName(imageFile)); + } + + if (!texture.isNull()) + { + mIconSize.width = (int)texture->getWidth(); + mIconSize.height = (int)texture->getHeight(); + mIcon->setSize(mIconSize); + } + + if (mIconRotating) + { + mIconRotating->setCenter(MyGUI::IntPoint(mIcon->getWidth()/2, mIcon->getHeight()/2)); + mIconRotating->setAngle(mRotation); + } +} + +#endif // USE_MYGUI Added: trunk/source/main/terrain/map/MapEntity.h =================================================================== --- trunk/source/main/terrain/map/MapEntity.h (rev 0) +++ trunk/source/main/terrain/map/MapEntity.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -0,0 +1,81 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2012 Pierre-Michel Ricordel +Copyright 2007-2012 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/>. +*/ +#ifdef USE_MYGUI + +#ifndef __MAP_ENTITY_H_ +#define __MAP_ENTITY_H_ + +#include "RoRPrerequisites.h" + +#include "mygui/BaseLayout.h" + +ATTRIBUTE_CLASS_LAYOUT(MapEntity, "MapEntity.layout"); + +class MapEntity : public wraps::BaseLayout +{ +public: + + MapEntity(MapControl *ctrl, Ogre::String type, MyGUI::StaticImagePtr parent); + + Ogre::String getDescription(); + bool getVisibility(); + int getState(); + + void setDescription(Ogre::String s); + void setPosition(Ogre::Vector3 pos); + void setPosition(float x, float z); + void setRotation(Ogre::Quaternion q); + void setRotation(Ogre::Radian r); + void setState(int state); + void setVisibility(bool value); + + void update(); + +private: + + MyGUI::StaticImagePtr mParent; + + ATTRIBUTE_FIELD_WIDGET_NAME(MapEntity, mCaption, "mCaption"); + MyGUI::StaticText *mCaption; + + ATTRIBUTE_FIELD_WIDGET_NAME(MapEntity, mIcon, "mIcon"); + MyGUI::StaticImage *mIcon; + MyGUI::RotatingSkin *mIconRotating; + + enum EntityStates {Activated, Deactivated, Sleeping, Networked, MaxEntityStates}; + + EntityStates mState; + MapControl *mMapControl; + MyGUI::IntSize mIconSize; + Ogre::Real mRotation; + Ogre::Real mX, mZ; + Ogre::String mDescription; + Ogre::String mType; + bool mIsStatic; + + void init(); + void updateIcon(); + + static Ogre::String entityStates[MaxEntityStates]; +}; + +#endif // __MAP_ENTITY_H_ + +#endif // USE_MYGUI Added: trunk/source/main/terrain/map/MapTextureCreator.cpp =================================================================== --- trunk/source/main/terrain/map/MapTextureCreator.cpp (rev 0) +++ trunk/source/main/terrain/map/MapTextureCreator.cpp 2012-05-26 22:03:20 UTC (rev 2714) @@ -0,0 +1,165 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2012 Pierre-Michel Ricordel +Copyright 2007-2012 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 "MapTextureCreator.h" + +#include "BeamFactory.h" +#include "ResourceBuffer.h" +#include "TerrainManager.h" + +using namespace Ogre; + +int MapTextureCreator::mCounter = 0; + +MapTextureCreator::MapTextureCreator() : + mCamera(NULL) + , mMapCenter(Vector3::ZERO) + , mMapZoom(0.0f) + , mMaterial(NULL) + , mRttTex(NULL) + , mStatics(NULL) + , mTextureUnitState(NULL) + , mViewport(NULL) +{ + mCounter++; + init(); +} + +bool MapTextureCreator::init() +{ + TexturePtr texture = TextureManager::getSingleton().createManual("MapRttTex" + TOSTRING(mCounter), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, 2048, 2048, TU_RENDERTARGET, PF_R8G8B8, TU_RENDERTARGET, new ResourceBuffer()); + + if ( texture.isNull() ) return false;; + + mRttTex = texture->getBuffer()->getRenderTarget(); + + if ( !mRttTex ) return false; + + mRttTex->setAutoUpdated(false); + + mCamera = gEnv->ogreSceneManager->createCamera("MapRenderCam" + TOSTRING(mCounter)); + + mViewport = mRttTex->addViewport(mCamera); + mViewport->setBackgroundColour(ColourValue::Black); + mViewport->setOverlaysEnabled(false); + + mMaterial = MaterialManager::getSingleton().create("MapRttMat" + TOSTRING(mCounter), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); + + if ( mMaterial.isNull() ) return false; + + mTextureUnitState = mMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("MapRttTex" + TOSTRING(mCounter)); + + mRttTex->addListener(this); + + mCamera->setFixedYawAxis(false); + mCamera->setProjectionType(PT_ORTHOGRAPHIC); + mCamera->setNearClipDistance(1.0f); + + return true; +} + +void MapTextureCreator::setMapZoom(Real zoomValue) +{ + mMapZoom = std::max(0.0f, zoomValue); + mMapZoom = std::min(zoomValue, 1.0f); +} + +void MapTextureCreator::setMapZoomRelative(Real zoomDelta) +{ + setMapZoom(mMapZoom + zoomDelta * mMapZoom / 100.0f); +} + +void MapTextureCreator::setMapCenter(Vector3 position) +{ + mMapCenter = position; + mMapCenter.y = 0.0f; +} + +void MapTextureCreator::setStaticGeometry(StaticGeometry *staticGeometry) +{ + mStatics = staticGeometry; +} + +void MapTextureCreator::update() +{ + if ( !mRttTex ) return; + + Vector3 mapSize = gEnv->terrainManager->getMax(); + float orthoWindowWidth = mapSize.x - (mapSize.x - 20.0f) * mMapZoom; + float orthoWindowHeight = mapSize.z - (mapSize.z - 20.0f) * mMapZoom; + + mCamera->setFarClipDistance(mapSize.y + 3.0f); + mCamera->setOrthoWindow(orthoWindowWidth, orthoWindowHeight); + mCamera->setPosition(mMapCenter + Vector3(0.0f, mapSize.y + 2.0f, 0.0f)); + mCamera->lookAt(mMapCenter); + + preRenderTargetUpdate(); + + mRttTex->update(); + + postRenderTargetUpdate(); +} + +String MapTextureCreator::getMaterialName() +{ + return "MapRttMat" + TOSTRING(mCounter); +} + +String MapTextureCreator::getRTName() +{ + return "MapRttTex" + TOSTRING(mCounter); +} + +void MapTextureCreator::preRenderTargetUpdate() +{ + Beam **trucks = BeamFactory::getSingleton().getTrucks(); + + float f = 20.0f + 30.0f * mMapZoom; + + for (int i=0; i < BeamFactory::getSingleton().getTruckCount(); i++) + { + if ( trucks[i] ) + { + trucks[i]->preMapLabelRenderUpdate(true, f); + } + } + + if ( mStatics ) + { + mStatics->setRenderingDistance(0); + } +} + +void MapTextureCreator::postRenderTargetUpdate() +{ + Beam **trucks = BeamFactory::getSingleton().getTrucks(); + + for (int i=0; i < BeamFactory::getSingleton().getTruckCount(); i++) + { + if ( trucks[i] ) + { + trucks[i]->preMapLabelRenderUpdate(false); + } + } + + if ( mStatics ) + { + mStatics->setRenderingDistance(1000); + } +} Added: trunk/source/main/terrain/map/MapTextureCreator.h =================================================================== --- trunk/source/main/terrain/map/MapTextureCreator.h (rev 0) +++ trunk/source/main/terrain/map/MapTextureCreator.h 2012-05-26 22:03:20 UTC (rev 2714) @@ -0,0 +1,62 @@ +/* +This source file is part of Rigs of Rods +Copyright 2005-2012 Pierre-Michel Ricordel +Copyright 2007-2012 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 __MapTextureCreator_H_ +#define __MapTextureCreator_H_ + +#include "RoRPrerequisites.h" + +#include "Ogre.h" + +class MapTextureCreator : public Ogre::RenderTargetListener +{ +public: + + MapTextureCreator(); + + Ogre::String getMaterialName(); + Ogre::String getRTName(); + + void setMapCenter(Ogre::Vector3 position); + void setMapZoom(Ogre::Real zoomValue); + void setMapZoomRelative(Ogre::Real zoomDelta); + void setStaticGeometry(Ogre::StaticGeometry *staticGeometry); + + void update(); + +protected: + + bool init(); + + void preRenderTargetUpdate(); + void postRenderTargetUpdate(); + + Ogre::Camera *mCamera; + Ogre::MaterialPtr mMaterial; + Ogre::Real mMapZoom; + Ogre::RenderTarget *mRttTex; + Ogre::StaticGeometry *mStatics; + Ogre::TextureUnitState *mTextureUnitState; + Ogre::Vector3 mMapCenter; + Ogre::Viewport *mViewport; + + static int mCounter; +}; + +#endif // __MapTextureCreator_H_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel