Revision: 2380
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2380&view=rev
Author: rorthomas
Date: 2012-01-29 15:08:43 +0000 (Sun, 29 Jan 2012)
Log Message:
-----------
3d dashboards working
Modified Paths:
--------------
trunk/bin/resources/mygui.zip
trunk/source/main/gui/DashBoardManager.cpp
trunk/source/main/gui/DashBoardManager.h
trunk/source/main/gui/gui_manager.cpp
trunk/source/main/physics/Beam.cpp
trunk/source/main/physics/BeamData.h
trunk/source/main/physics/input_output/SerializedRig.cpp
Added Paths:
-----------
trunk/source/main/gui/RTTLayer.cpp
trunk/source/main/gui/RTTLayer.h
Modified: trunk/bin/resources/mygui.zip
===================================================================
(Binary files differ)
Modified: trunk/source/main/gui/DashBoardManager.cpp
===================================================================
--- trunk/source/main/gui/DashBoardManager.cpp 2012-01-28 20:48:12 UTC (rev
2379)
+++ trunk/source/main/gui/DashBoardManager.cpp 2012-01-29 15:08:43 UTC (rev
2380)
@@ -136,15 +136,15 @@
return -1;
}
-int DashBoardManager::loadDashBoard( Ogre::String filename )
+int DashBoardManager::loadDashBoard( Ogre::String filename, bool textureLayer )
{
if(free_dashboard >= MAX_DASH)
{
- LOG("maximum amount of dashboards ber truck reached, discarding
the rest: " + TOSTRING(MAX_DASH));
+ LOG("maximum amount of dashboards per truck reached, discarding
the rest: " + TOSTRING(MAX_DASH));
return 1;
}
- DashBoard *d = new DashBoard(this, filename);
+ DashBoard *d = new DashBoard(this, filename, textureLayer);
d->setVisible(true);
dashboards[free_dashboard] = d;
@@ -195,7 +195,7 @@
// DASHBOARD class below
-DashBoard::DashBoard(DashBoardManager *manager, Ogre::String filename) :
manager(manager), filename(filename), free_controls(0), visible(false),
mainWidget(0)
+DashBoard::DashBoard(DashBoardManager *manager, Ogre::String filename, bool
_textureLayer) : manager(manager), filename(filename), free_controls(0),
visible(false), mainWidget(0), textureLayer(_textureLayer)
{
// use 'this' class pointer to make layout unique
prefix = MyGUI::utility::toString(this, "_");
@@ -617,6 +617,9 @@
loadLayoutRecursive(*iter);
}
+ // if this thing should be rendered to texture, relocate the main
window to the RTT layer
+ if(textureLayer && mainWidget)
+ mainWidget->detachFromWidget("RTTLayer1");
}
void DashBoard::setVisible(bool v)
Modified: trunk/source/main/gui/DashBoardManager.h
===================================================================
--- trunk/source/main/gui/DashBoardManager.h 2012-01-28 20:48:12 UTC (rev
2379)
+++ trunk/source/main/gui/DashBoardManager.h 2012-01-29 15:08:43 UTC (rev
2380)
@@ -183,7 +183,7 @@
int getLinkIDForName(Ogre::String &str);
- int loadDashBoard(Ogre::String filename);
+ int loadDashBoard(Ogre::String filename, bool textureLayer);
void update(float &dt);
@@ -204,7 +204,7 @@
{
//friend class DashBoardManager;
public:
- DashBoard(DashBoardManager *manager, Ogre::String filename);
+ DashBoard(DashBoardManager *manager, Ogre::String filename, bool
textureLayer);
~DashBoard();
void setVisible(bool visible);
@@ -219,7 +219,7 @@
Ogre::String filename;
MyGUI::VectorWidgetPtr widgets;
MyGUI::WidgetPtr mainWidget;
- bool visible;
+ bool visible, textureLayer;
std::string prefix;
enum {ANIM_NONE, ANIM_ROTATE, ANIM_SCALE, ANIM_TEXT, ANIM_TEXT2,
ANIM_LAMP, ANIM_SERIES, ANIM_TRANSLATE };
@@ -255,7 +255,7 @@
bool lastState;
} layoutLink_t;
- void loadLayout(Ogre::String filename);
+ void loadLayout(Ogre::String filename );
void loadLayoutRecursive(MyGUI::WidgetPtr ptr);
layoutLink_t controls[MAX_CONTROLS];
int free_controls;
Added: trunk/source/main/gui/RTTLayer.cpp
===================================================================
--- trunk/source/main/gui/RTTLayer.cpp (rev 0)
+++ trunk/source/main/gui/RTTLayer.cpp 2012-01-29 15:08:43 UTC (rev 2380)
@@ -0,0 +1,100 @@
+// based on the MyGUI UnitTests
+
+#include "MyGUI_LayerItem.h"
+#include "RTTLayer.h"
+#include "MyGUI_Enumerator.h"
+#include "MyGUI_FactoryManager.h"
+#include "MyGUI_RenderManager.h"
+#include "MyGUI_Gui.h"
+#include "MyGUI_LayerNode.h"
+
+namespace MyGUI
+{
+
+ RTTLayer::RTTLayer() :
+ mTexture(nullptr),
+ mOutOfDate(false)
+ {
+ }
+
+ RTTLayer::~RTTLayer()
+ {
+ if (mTexture)
+ {
+
MyGUI::RenderManager::getInstance().destroyTexture(mTexture);
+ mTexture = nullptr;
+ }
+ }
+
+ void RTTLayer::deserialization(xml::ElementPtr _node, Version _version)
+ {
+ Base::deserialization(_node, _version);
+
+ MyGUI::xml::ElementEnumerator propert =
_node->getElementEnumerator();
+ while (propert.next("Property"))
+ {
+ const std::string& key = propert->findAttribute("key");
+ const std::string& value =
propert->findAttribute("value");
+ if (key == "TextureSize")
+
setTextureSize(utility::parseValue<IntSize>(value));
+ if (key == "TextureName")
+ setTextureName(value);
+ }
+ }
+
+ void RTTLayer::renderToTarget(IRenderTarget* _target, bool _update)
+ {
+ bool outOfDate = mOutOfDate || isOutOfDate();
+
+ if (outOfDate || _update)
+ {
+ MyGUI::IRenderTarget* target =
mTexture->getRenderTarget();
+ if (target != nullptr)
+ {
+ target->begin();
+
+ for (VectorILayerNode::iterator iter =
mChildItems.begin(); iter != mChildItems.end(); ++iter)
+ (*iter)->renderToTarget(target,
_update);
+
+ target->end();
+ }
+ }
+
+ mOutOfDate = false;
+ }
+
+ void RTTLayer::setTextureSize(const IntSize& _size)
+ {
+ if (mTextureSize == _size)
+ return;
+
+ mTextureSize = _size;
+ if (mTexture)
+ {
+
MyGUI::RenderManager::getInstance().destroyTexture(mTexture);
+ mTexture = nullptr;
+ }
+
+ MYGUI_ASSERT(mTextureSize.width * mTextureSize.height,
"RTTLayer texture size must have non-zero width and height");
+ std::string name = mTextureName.empty() ?
MyGUI::utility::toString((size_t)this, getClassTypeName()) : mTextureName;
+ mTexture =
MyGUI::RenderManager::getInstance().createTexture(name);
+ mTexture->createManual(mTextureSize.width, mTextureSize.height,
MyGUI::TextureUsage::RenderTarget, MyGUI::PixelFormat::R8G8B8A8);
+
+ mOutOfDate = true;
+ }
+
+ void RTTLayer::setTextureName(const std::string& _name)
+ {
+ mTextureName = _name;
+
+ if (mTexture != nullptr)
+ {
+ IntSize size = mTextureSize;
+ mTextureSize.clear();
+ setTextureSize(size);
+ }
+
+ mOutOfDate = true;
+ }
+
+} // namespace MyGUI
Added: trunk/source/main/gui/RTTLayer.h
===================================================================
--- trunk/source/main/gui/RTTLayer.h (rev 0)
+++ trunk/source/main/gui/RTTLayer.h 2012-01-29 15:08:43 UTC (rev 2380)
@@ -0,0 +1,37 @@
+// based on the MyGUI UnitTests
+
+#ifndef __MYGUI_RTT_LAYER_H__
+#define __MYGUI_RTT_LAYER_H__
+
+#include "MyGUI_Prerequest.h"
+#include "MyGUI_Types.h"
+#include "MyGUI_OverlappedLayer.h"
+
+namespace MyGUI
+{
+
+ class RTTLayer :
+ public OverlappedLayer
+ {
+ MYGUI_RTTI_DERIVED( RTTLayer )
+
+ public:
+ RTTLayer();
+ virtual ~RTTLayer();
+
+ virtual void deserialization(xml::ElementPtr _node, Version
_version);
+ virtual void renderToTarget(IRenderTarget* _target, bool
_update);
+
+ void setTextureSize(const IntSize& _size);
+ void setTextureName(const std::string& _name);
+
+ private:
+ MyGUI::ITexture* mTexture;
+ IntSize mTextureSize;
+ std::string mTextureName;
+ bool mOutOfDate;
+ };
+
+} // namespace MyGUI
+
+#endif // __MYGUI_RTT_LAYER_H__
Modified: trunk/source/main/gui/gui_manager.cpp
===================================================================
--- trunk/source/main/gui/gui_manager.cpp 2012-01-28 20:48:12 UTC (rev
2379)
+++ trunk/source/main/gui/gui_manager.cpp 2012-01-29 15:08:43 UTC (rev
2380)
@@ -26,6 +26,7 @@
#include "RoRWindowEventUtilities.h"
#include <MyGUI_OgrePlatform.h>
#include <MyGUI_LanguageManager.h>
+#include "RTTLayer.h"
#include "Console.h"
#include "BeamFactory.h"
@@ -93,8 +94,16 @@
mPlatform = new MyGUI::OgrePlatform();
mPlatform->initialise(mWindow, mSceneManager,
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, gui_logfilename);
// use cache resource group so preview images are working
mGUI = new MyGUI::Gui();
- mGUI->initialise(mResourceFileName);
+
+ // empty init
+ mGUI->initialise("");
+
+ // add layer factory
+
MyGUI::FactoryManager::getInstance().registerFactory<MyGUI::RTTLayer>("Layer");
+ // then load the actual config
+ MyGUI::ResourceManager::getInstance().load(mResourceFileName);
+
MyGUI::ResourceManager::getInstance().load(LanguageEngine::Instance().getMyGUIFontConfigFilename());
// move the mouse into the middle of the screen, assuming we start at
the top left corner (0,0)
@@ -201,4 +210,4 @@
return files->at(num).filename;
}
-#endif //MYGUI
\ No newline at end of file
+#endif //MYGUI
Modified: trunk/source/main/physics/Beam.cpp
===================================================================
--- trunk/source/main/physics/Beam.cpp 2012-01-28 20:48:12 UTC (rev 2379)
+++ trunk/source/main/physics/Beam.cpp 2012-01-29 15:08:43 UTC (rev 2380)
@@ -1208,6 +1208,12 @@
ssm->trigStop(trucknum, SS_TRIG_REVERSE_GEAR);
#endif //OPENAL
+#ifdef USE_MYGUI
+ updateDashBoards(tratio);
+ if(dash)
+ dash->update(tratio);
+#endif // USE_MYGUI
+
BES_GFX_STOP(BES_GFX_calcNetwork);
}
@@ -2044,7 +2050,8 @@
#ifdef USE_MYGUI
updateDashBoards(dt);
- dash->update(dt);
+ if(dash)
+ dash->update(dt);
#endif // USE_MYGUI
@@ -3501,7 +3508,8 @@
{
//going outside
#ifdef USE_MYGUI
- dash->setVisible(false);
+ if(dash)
+ dash->setVisible(false);
#endif // USE_MYGUI
// disable cabin light before going out
@@ -5511,16 +5519,25 @@
#ifdef USE_MYGUI
// now load any dashboards
- if(dashBoardLayout.empty())
+ if(dash)
{
- // load default for a truck
- if(driveable == TRUCK)
- dash->loadDashBoard("default_dashboard.layout");
- } else
- {
- dash->loadDashBoard(dashBoardLayout);
+ if(dashBoardLayouts.empty())
+ {
+ // load default for a truck
+ if(driveable == TRUCK)
+ {
+ dash->loadDashBoard("default_dashboard.layout",
false);
+ // TODO: load texture dashboard by default as
well
+ dash->loadDashBoard("default_dashboard.layout",
true);
+ }
+ } else
+ {
+ // load all dashs
+ for(int i=0; i < dashBoardLayouts.size(); i++)
+ dash->loadDashBoard(dashBoardLayouts[i].first,
dashBoardLayouts[i].second);
+ }
+ dash->setVisible(false);
}
- dash->setVisible(false);
#endif // USE_MYGUI
return res;
@@ -5618,6 +5635,7 @@
void Beam::updateDashBoards(float &dt)
{
#ifdef USE_MYGUI
+ if(!dash) return;
// some temp vars
Vector3 dir;
Modified: trunk/source/main/physics/BeamData.h
===================================================================
--- trunk/source/main/physics/BeamData.h 2012-01-28 20:48:12 UTC (rev
2379)
+++ trunk/source/main/physics/BeamData.h 2012-01-29 15:08:43 UTC (rev
2380)
@@ -1029,7 +1029,7 @@
float odometerTotal;
float odometerUser;
- Ogre::String dashBoardLayout;
+ std::vector<std::pair<Ogre::String, bool> > dashBoardLayouts;
Ogre::String beamHash;
};
Modified: trunk/source/main/physics/input_output/SerializedRig.cpp
===================================================================
--- trunk/source/main/physics/input_output/SerializedRig.cpp 2012-01-28
20:48:12 UTC (rev 2379)
+++ trunk/source/main/physics/input_output/SerializedRig.cpp 2012-01-29
15:08:43 UTC (rev 2380)
@@ -225,7 +225,7 @@
odometerTotal = 0;
odometerUser = 0;
- dashBoardLayout = String();
+ dashBoardLayouts.clear();
memset(default_node_options, 0, 49);
memset(texname, 0, 1023);
@@ -4189,8 +4189,12 @@
}
else if(!strncmp(keyword, "dashboard", 255) &&
strnlen(value, 255) > 0)
{
- dashBoardLayout = String(value);
+
dashBoardLayouts.push_back(std::pair<Ogre::String, bool>(String(value), false));
}
+ else if(!strncmp(keyword, "texturedashboard",
255) && strnlen(value, 255) > 0)
+ {
+
dashBoardLayouts.push_back(std::pair<Ogre::String, bool>(String(value), true));
+ }
}
else if (c.mode == BTS_MINIMASS)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel