Revision: 1683
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1683&view=rev
Author:   rorthomas
Date:     2011-02-17 00:33:04 +0000 (Thu, 17 Feb 2011)

Log Message:
-----------
skin system rewrite, not ready yet

Modified Paths:
--------------
    trunk/source/main/gameplay/CacheSystem.cpp
    trunk/source/main/gameplay/CacheSystem.h
    trunk/source/main/gameplay/skin.cpp
    trunk/source/main/gameplay/skin.h
    trunk/source/main/gameplay/skinmanager.cpp
    trunk/source/main/gameplay/skinmanager.h
    trunk/source/main/gui/SelectorWindow.cpp
    trunk/source/main/main_sim/RigsOfRods.cpp
    trunk/source/main/main_sim/RigsOfRods.h
    trunk/source/main/physics/BeamData.h
    trunk/source/main/physics/input_output/BeamLoadTruck.cpp
    trunk/source/main/utils/MeshObject.h

Modified: trunk/source/main/gameplay/CacheSystem.cpp
===================================================================
--- trunk/source/main/gameplay/CacheSystem.cpp  2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/gameplay/CacheSystem.cpp  2011-02-17 00:33:04 UTC (rev 
1683)
@@ -22,7 +22,6 @@
 #include "CacheSystem.h"
 #include "sha1.h"
 #include "ImprovedConfigFile.h"
-#include "skinmanager.h"
 #include "Settings.h"
 #include "language.h"
 
@@ -64,8 +63,6 @@
        known_extensions.push_back("airplane");
        known_extensions.push_back("trailer");
        known_extensions.push_back("load");
-       // skins:
-       known_extensions.push_back("skin");
 
        if(SETTINGS.getSetting("streamCacheGenerationOnly") == "Yes")
        {
@@ -401,6 +398,18 @@
                // Set
                t.uniqueid = params[1];
        }
+       else if (attrib == "guid")
+       {
+               // Check params
+               if (params.size() != 2)
+               {
+                       logBadTruckAttrib(line, t);
+                       return;
+               }
+               // Set
+               t.guid = params[1];
+               StringUtil::trim(t.guid);
+       }
        else if (attrib == "version")
        {
                // Check params
@@ -561,12 +570,11 @@
        LogManager::getSingleton().logMessage("CacheSystem::loadCache2");
 
        Cache_Entry t;
-       Skin *pSkin;
        int mode = 0;
        while( !stream->eof() )
        {
                line = stream->getLine();
-               if(StringUtil::startsWith(line, "shaone=") || 
StringUtil::startsWith(line, "modcount=") || StringUtil::startsWith(line, 
"cacheformat=") || StringUtil::startsWith(line, "skincount="))
+               if(StringUtil::startsWith(line, "shaone=") || 
StringUtil::startsWith(line, "modcount=") || StringUtil::startsWith(line, 
"cacheformat="))
                        // ignore here
                        continue;
 
@@ -590,27 +598,6 @@
                                        // Skip to and over next {
                                        stream->skipLine("{");
                                }
-                               if(line.substr(0,4) == "skin")
-                               {
-                                       String sname = "skin";
-                                       if(line.size() > 7)
-                                       {
-                                               sname = line.substr(5);
-                                               StringUtil::trim(sname);
-                                       }
-                                       // "skin" + 
StringConverter::toString(SkinManager::getSingleton().getSkinCount())
-                                       try
-                                       {
-                                               pSkin = (Skin 
*)SkinManager::getSingleton().create(sname, 
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME).getPointer();
-                                               
pSkin->_notifyOrigin(stream->getName());
-                                               // Skip to and over next {
-                                               stream->skipLine("{");
-                                               mode = 2;
-                                       } catch(...)
-                                       {
-                                               continue;
-                                       }
-                               }
                        } else if(mode == 1)
                        {
                                // Already in mod
@@ -625,19 +612,6 @@
                                {
                                        parseModAttribute(line, t);
                                }
-                       } else if(mode == 2)
-                       {
-                               // skin
-                               if (line == "}")
-                               {
-                                       // Finished
-                                       pSkin = 0;
-                                       mode = 0;
-                               }
-                               else
-                               {
-                                       
SkinManager::getSingleton().parseAttribute(line, pSkin);
-                               }
                        }
                }
        }
@@ -981,6 +955,8 @@
                        t.hash = "none";
                if(t.uniqueid.empty())
                        t.uniqueid = "no-uid";
+               if(t.guid.empty())
+                       t.guid = "no-guid";
                if(t.fname_without_uid.empty())
                        t.fname_without_uid = "unkown";
                if(t.filecachename.empty())
@@ -999,6 +975,7 @@
                result += "\thash="+t.hash+"\n";
                result += 
"\tcategoryid="+StringConverter::toString(t.categoryid)+"\n";
                result += "\tuniqueid="+t.uniqueid+"\n";
+               result += "\tguid="+t.guid+"\n";
                result += 
"\tversion="+StringConverter::toString(t.version)+"\n";
                result += "\tfilecachename="+t.filecachename+"\n";
                //result += 
"\tnumauthors="+StringConverter::toString(t.authors.size())+"\n";
@@ -1106,17 +1083,6 @@
        return result;
 }
 
-Ogre::String CacheSystem::formatSkinEntry(int counter, Skin *skin)
-{
-       String result = "skin\n";
-       result += "{\n";
-       result += "\tname="+skin->name+"\n";
-       result += "\tthumbimg="+skin->thumbnail+"\n";
-       // todo: finish implementation ...
-       result += "}\n\n";
-       return result;
-}
-
 void CacheSystem::writeGeneratedCache()
 {
        String path = getCacheConfigFilename(true);
@@ -1127,7 +1093,6 @@
                return;
        fprintf(f, "shaone=%s\n", const_cast<char*>(currentSHA1.c_str()));
        fprintf(f, "modcount=%d\n", (int)entries.size());
-       fprintf(f, "skincount=%d\n", 
SkinManager::getSingleton().getSkinCount());
        fprintf(f, "cacheformat=%s\n", CACHE_FILE_FORMAT);
 
        // mods
@@ -1140,12 +1105,6 @@
                counter++;
        }
 
-
-       // skins
-       String skinString = "";
-       SkinManager::getSingleton().serialize(skinString);
-       fprintf(f, "%s", skinString.c_str());
-
        // close
        fclose(f);
        LogManager::getSingleton().logMessage("...done!");
@@ -1248,11 +1207,6 @@
 {
        LogManager::getSingleton().logMessage("Preparing to add " + filename);
 
-       if(ext == "skin")
-       {
-               skins_map[filename] = archiveDirectory;
-               return;
-       }
        //read first line
        Cache_Entry entry;
        if(!resourceExistsInAllGroups(filename))
@@ -1405,6 +1359,16 @@
                /* 52 = reserved for ignored section */
 
 
+               
+               if (!strncmp("guid", line, 4))
+               {
+                       char guid[128]="";
+                       int result = sscanf(line,"guid %s", guid);
+                       entry.guid = String(guid);
+                       StringUtil::trim(entry.guid);
+                       continue;
+               }
+
                if (!strcmp("commandlist",line))
                        continue;
                if (!strncmp("fileinfo", line, 8))
@@ -1748,24 +1712,7 @@
                                        
LogManager::getSingleton().logMessage("Error parsing File (Prop) " + 
String(fname) +" line " + StringConverter::toString(linecounter) + ". trying to 
continue ...");
                                        continue;
                                }
-                               /*
-                               // XXX TODO fix for skins at some point
-                               Entity *te=0;
-                               String propMats="";
-                               try
-                               {
-                                       if(smgr)
-                                       {
-                                               te = 
smgr->createEntity("CacheEntityMaterialTest", String(meshname));
-                                               if(!te) continue;
-                                               addMeshMaterials(entry, te);
-                                               smgr->destroyEntity(te);
-                                       }
-                               }catch(...)
-                               {
-                                       
LogManager::getSingleton().logMessage("error loading mesh: "+String(meshname));
-                               }
-                               */
+
                                entry.propscount++;
                                continue;
                        }
@@ -1986,24 +1933,6 @@
                                        
LogManager::getSingleton().logMessage("Error parsing File (Flexbodies) " + 
String(fname) +" line " + StringConverter::toString(linecounter) + ". trying to 
continue ...");
                                        continue;
                                }
-                               /*
-                               // XXX TODO fix for skins at some point
-                               Entity *te=0;
-                               String propMats="";
-                               try
-                               {
-                                       if(smgr)
-                                       {
-                                               te = 
smgr->createEntity("CacheEntityMaterialTest", String(meshname));
-                                               if(!te) continue;
-                                               addMeshMaterials(entry, te);
-                                               smgr->destroyEntity(te);
-                                       }
-                               }catch(...)
-                               {
-                                       
LogManager::getSingleton().logMessage("error loading mesh: "+String(meshname));
-                               }
-                               */
                                entry.flexbodiescount++;
                                continue;
                        }
@@ -2125,12 +2054,6 @@
        return materials;
 }
 
-
-Ogre::String CacheSystem::getSkinSource(Ogre::String filename)
-{
-       return skins_map[filename];
-}
-
 int CacheSystem::getTimeStamp()
 {
        return (int)time(NULL); //this will overflow in 2038

Modified: trunk/source/main/gameplay/CacheSystem.h
===================================================================
--- trunk/source/main/gameplay/CacheSystem.h    2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/gameplay/CacheSystem.h    2011-02-17 00:33:04 UTC (rev 
1683)
@@ -60,6 +60,7 @@
        int addtimestamp;                                       // timestamp 
when this file was added to the cache
        
        Ogre::String uniqueid;                          // file's unique id
+       Ogre::String guid;                  // global unique id
        int version;                                            // file's 
version
        
        Ogre::String fext;                                      // file's 
extension
@@ -228,8 +229,6 @@
        //these location MUST include a path separator at the end!
        void setLocation(String cachepath, String configpath);
        
-       Ogre::String getSkinSource(Ogre::String filename);
-
        // this is for stats only, maybe protect it by getter later
        int changedFiles, newFiles, deletedFiles;
        bool fileExists(Ogre::String);
@@ -260,8 +259,6 @@
 
        int addUniqueString(std::set<Ogre::String> &list, Ogre::String str);
 
-       // map for skins and zips
-       std::map<Ogre::String, Ogre::String> skins_map;
 
        // parses all files loaded with a certain extension
        void parseFilesAllRG(Ogre::String ext);
@@ -301,7 +298,6 @@
        void generateCache(bool forcefull=false);
        Ogre::String formatEntry(int counter, Cache_Entry t);
        Ogre::String formatInnerEntry(int counter, Cache_Entry t);
-       Ogre::String formatSkinEntry(int counter, Skin *skin);
        void updateSingleTruckEntryCache(int number, Cache_Entry t);
        void parseModAttribute(const Ogre::String& line, Cache_Entry& t);
        void logBadTruckAttrib(const Ogre::String& line, Cache_Entry& t);

Modified: trunk/source/main/gameplay/skin.cpp
===================================================================
--- trunk/source/main/gameplay/skin.cpp 2011-02-16 18:11:26 UTC (rev 1682)
+++ trunk/source/main/gameplay/skin.cpp 2011-02-17 00:33:04 UTC (rev 1683)
@@ -27,47 +27,47 @@
 using namespace Ogre;
 
 Skin::Skin(ResourceManager* creator, const String& name, ResourceHandle 
handle, const String& group, bool isManual, ManualResourceLoader* loader) : 
-Ogre::Resource(creator, name, handle, group, isManual, loader), loaded(false)
+       Ogre::Resource(creator, name, handle, group, isManual, loader)
 {
        this->name = name;
        this->thumbnail = "";
        this->description = "";
        this->authorName = "";
        this->authorID = -1;
-       LogManager::getSingleton().logMessage("Skin::Skin("+name+")");
+       //LogManager::getSingleton().logMessage("Skin::Skin("+name+")");
 }
 
 Skin::~Skin()
 {
-       LogManager::getSingleton().logMessage("Skin::~Skin("+name+")");
+       //LogManager::getSingleton().logMessage("Skin::~Skin("+name+")");
 }
 
 void Skin::loadImpl()
 {
-       LogManager::getSingleton().logMessage("Skin::loadImpl("+name+")");
+       //LogManager::getSingleton().logMessage("Skin::loadImpl("+name+")");
 }
 
 void Skin::unloadImpl()
 {
-       LogManager::getSingleton().logMessage("Skin::unloadImpl("+name+")");
+       //LogManager::getSingleton().logMessage("Skin::unloadImpl("+name+")");
 }
 
 size_t Skin::calculateSize() const
 {
-       LogManager::getSingleton().logMessage("Skin::calculateSize("+name+")");
+       
//LogManager::getSingleton().logMessage("Skin::calculateSize("+name+")");
        return 0;
 }
 
 int Skin::addMaterialReplace(Ogre::String from, Ogre::String to)
 {
-       
LogManager::getSingleton().logMessage("Skin::addMaterialReplace("+from+","+to+")");
+       
//LogManager::getSingleton().logMessage("Skin::addMaterialReplace("+from+","+to+")");
        replaceMaterials[from] = to;
        return 0;
 }
 
 int Skin::hasReplacementForMaterial(Ogre::String material)
 {
-       
LogManager::getSingleton().logMessage("Skin::hasReplacementForMaterial("+material+")
 = " + StringConverter::toString((int)replaceMaterials.count(material)));
+       
//LogManager::getSingleton().logMessage("Skin::hasReplacementForMaterial("+material+")
 = " + StringConverter::toString((int)replaceMaterials.count(material)));
        int res = (int)replaceMaterials.count(material);
        if(!res)
                return 
(int)replaceMaterials.count(CACHE.stripUIDfromString(material));
@@ -76,7 +76,7 @@
 
 Ogre::String Skin::getReplacementForMaterial(Ogre::String material)
 {
-       
LogManager::getSingleton().logMessage("Skin::getReplacementForMaterial("+material+")
 = " + replaceMaterials[material]);
+       
//LogManager::getSingleton().logMessage("Skin::getReplacementForMaterial("+material+")
 = " + replaceMaterials[material]);
        String res = replaceMaterials[material];
        if(res.empty())
                return replaceMaterials[CACHE.stripUIDfromString(material)];
@@ -91,7 +91,6 @@
        if(this->authorID != -1)       dst += "\tAuthorID=" + 
StringConverter::toString(this->authorID) + "\n";
        if(!this->authorName.empty())  dst += "\tAuthorName=" + 
this->authorName + "\n";
        if(!this->description.empty()) dst += "\tDescription=" + 
this->description + "\n";
-       if(!this->sourcetype.empty())  dst += "\tSourceType=" + 
this->sourcetype + "\n";
 
        for(it = replaceMaterials.begin(); it != replaceMaterials.end(); it++)
                dst += "\tReplaceMaterial=" + it->first + " " + it->second + 
"\n";
@@ -115,7 +114,7 @@
                        
if(this->hasReplacementForMaterial(sm->getMaterialName()))
                        {
                                String newMat = 
this->getReplacementForMaterial(sm->getMaterialName());
-                               LogManager::getSingleton().logMessage("Skin: 
replaced mesh material " + sm->getMaterialName() + " with new new material " + 
newMat + " on entity " + e->getName());
+                               //LogManager::getSingleton().logMessage("Skin: 
replaced mesh material " + sm->getMaterialName() + " with new new material " + 
newMat + " on entity " + e->getName());
                                sm->setMaterialName(newMat);
                        }
                }
@@ -127,7 +126,7 @@
                if(this->hasReplacementForMaterial(subent->getMaterialName()))
                {
                        String newMat = 
this->getReplacementForMaterial(subent->getMaterialName());
-                       LogManager::getSingleton().logMessage("Skin: replaced 
mesh material " + subent->getMaterialName() + " with new new material " + 
newMat + " on entity " + e->getName());
+                       //LogManager::getSingleton().logMessage("Skin: replaced 
mesh material " + subent->getMaterialName() + " with new new material " + 
newMat + " on entity " + e->getName());
                        subent->setMaterialName(newMat);
                }
        }

Modified: trunk/source/main/gameplay/skin.h
===================================================================
--- trunk/source/main/gameplay/skin.h   2011-02-16 18:11:26 UTC (rev 1682)
+++ trunk/source/main/gameplay/skin.h   2011-02-17 00:33:04 UTC (rev 1683)
@@ -41,12 +41,8 @@
        Ogre::String thumbnail;
        Ogre::String description;
        Ogre::String authorName;
-       Ogre::String skintype;
-       Ogre::String source;
-       Ogre::String sourcetype;
-       Ogre::String origin;
+       Ogre::String guid;
        int authorID;
-       bool loaded;
 
        int addMaterialReplace(Ogre::String from, Ogre::String to);
        int hasReplacementForMaterial(Ogre::String material);

Modified: trunk/source/main/gameplay/skinmanager.cpp
===================================================================
--- trunk/source/main/gameplay/skinmanager.cpp  2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/gameplay/skinmanager.cpp  2011-02-17 00:33:04 UTC (rev 
1683)
@@ -163,100 +163,69 @@
        else if (attrib == "description"        && params.size() >= 2) 
pSkin->description = joinString(params);
        else if (attrib == "authorname"         && params.size() >= 2) 
pSkin->authorName = joinString(params);
        else if (attrib == "authorid"           && params.size() == 2) 
pSkin->authorID = StringConverter::parseInt(params[1]);
-       else if (attrib == "skintype"           && params.size() >= 2) 
pSkin->skintype = joinString(params);
+       else if (attrib == "guid"               && params.size() >= 2) { 
pSkin->guid = joinString(params); StringUtil::trim(pSkin->guid); }
        else if (attrib == "name"               && params.size() >= 2)
        {
                pSkin->name = joinString(params);
                StringUtil::trim(pSkin->name);
        }
-       else if (attrib == "origin"             && params.size() >= 2) 
pSkin->origin = joinString(params);
-       else if (attrib == "source"             && params.size() >= 2) 
pSkin->source = joinString(params);
-       else if (attrib == "sourcetype"         && params.size() == 2) 
pSkin->sourcetype = params[1];
 }
 
 //---------------------------------------------------------------------
 void SkinManager::logBadAttrib(const String& line, Skin *pSkin)
 {
-       LogManager::getSingleton().logMessage("Bad attribute line: " + line +
-               " in skin " + pSkin->getName());
+       LogManager::getSingleton().logMessage("Bad attribute line: " + line + " 
in skin " + pSkin->getName());
 
 }
 
-int SkinManager::getMaterialAlternatives(Ogre::String materialName, 
std::vector<Skin *> &skinVector)
+bool SkinManager::hasSkinForGUID(Ogre::String guid)
 {
        Ogre::ResourceManager::ResourceMapIterator it = 
SkinManager::getSingleton().getResourceIterator();
        while (it.hasMoreElements())
        {
                Skin *skin = (Skin *)it.getNext().getPointer();
 
-               if (skin->hasReplacementForMaterial(materialName))
-               {
-                       skinVector.push_back(skin);
-               }
+               if (skin->guid == guid)
+                       return true;
        }
-       return 0; // no errors
+       return false;
 }
 
 
-int SkinManager::getUsableSkins(Cache_Entry *e, std::vector<Skin *> &skins)
+int SkinManager::getMaterialAlternatives(Ogre::String materialName, 
std::vector<Skin *> &skinVector)
 {
        Ogre::ResourceManager::ResourceMapIterator it = 
SkinManager::getSingleton().getResourceIterator();
        while (it.hasMoreElements())
        {
                Skin *skin = (Skin *)it.getNext().getPointer();
-               std::set < Ogre::String >::iterator mit;
-               for(mit = e->materials.begin(); mit != e->materials.end(); 
mit++)
+
+               if (skin->hasReplacementForMaterial(materialName))
                {
-                       if(skin->hasReplacementForMaterial(*mit))
-                       {
-                               bool found=false;
-                               for(std::vector<Skin *>::iterator sit = 
skins.begin(); sit != skins.end(); sit++)
-                               {
-                                       if(*sit == skin) // operator== 
implemented
-                                       {
-                                               found=true;
-                                               break;
-                                       }
-                               }
-                               if(found)
-                                       // already in there
-                                       continue;
-                               skins.push_back(skin);
-                       }
+                       skinVector.push_back(skin);
                }
        }
        return 0; // no errors
 }
 
-int SkinManager::getSkinCount()
-{
-       return (int)mResourcesByHandle.size();
-}
 
-int SkinManager::serialize(Ogre::String &dst)
+int SkinManager::getUsableSkins(String guid, std::vector<Skin *> &skins)
 {
-       ResourceManager::ResourceHandleMap::iterator it;
-       for(it = mResourcesByHandle.begin(); it != mResourcesByHandle.end(); 
it++)
+       Ogre::ResourceManager::ResourceMapIterator it = 
SkinManager::getSingleton().getResourceIterator();
+       while (it.hasMoreElements())
        {
+               Skin *skin = (Skin *)it.getNext().getPointer();
 
-               String source = CACHE.getSkinSource(it->second->getOrigin());
-               if(!source.size()) continue;
-
-               std::string::size_type loc = source.find(".zip", 0);
-               if( loc != std::string::npos )
-                       ((Skin *)(it->second.getPointer()))->sourcetype = "Zip";
-               else
-                       ((Skin *)(it->second.getPointer()))->sourcetype = 
"FileSystem";
-
-               dst += "skin " + ((Skin *)(it->second.getPointer()))->name + 
"\n{\n";
-               int sres = ((Skin *)(it->second.getPointer()))->serialize(dst);
-               dst += "\torigin=" + it->second->getOrigin() + "\n";
-               dst += "\tsource=" + source + "\n";
-               dst += "}\n\n";
+               if (skin->guid == guid)
+                       skins.push_back(skin);
        }
        return 0;
 }
 
+int SkinManager::getSkinCount()
+{
+       return (int)mResourcesByHandle.size();
+}
+
 int SkinManager::clear()
 {
        mResourcesByHandle.clear();

Modified: trunk/source/main/gameplay/skinmanager.h
===================================================================
--- trunk/source/main/gameplay/skinmanager.h    2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/gameplay/skinmanager.h    2011-02-17 00:33:04 UTC (rev 
1683)
@@ -40,7 +40,8 @@
        static SkinManager* getSingletonPtr(void);
 
        int getMaterialAlternatives(Ogre::String materialName, std::vector<Skin 
*> &skin);
-       int getUsableSkins(Cache_Entry *e, std::vector<Skin *> &skins);
+       int getUsableSkins(Ogre::String guid, std::vector<Skin *> &skins);
+       bool hasSkinForGUID(Ogre::String guid);
 
        int getSkinCount();
        int serialize(Ogre::String &dst);

Modified: trunk/source/main/gui/SelectorWindow.cpp
===================================================================
--- trunk/source/main/gui/SelectorWindow.cpp    2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/gui/SelectorWindow.cpp    2011-02-17 00:33:04 UTC (rev 
1683)
@@ -150,9 +150,15 @@
        }
 
        // select key
-       else if(_key == MyGUI::KeyCode::Return && mSelectedTruck)
+       else if(mLoaderType != LT_SKIN && _key == MyGUI::KeyCode::Return && 
mSelectedTruck)
+       {
                selectionDone();
 
+       } else if(mLoaderType == LT_SKIN && _key == MyGUI::KeyCode::Return && 
mSelectedSkin)
+       {
+               selectionDone();
+       }
+
 }
 
 void SelectorWindow::eventMouseButtonClickOkButton(MyGUI::WidgetPtr _sender)
@@ -422,23 +428,7 @@
                entryID -= 1; // remove default skin :)
                Skin *skin = mCurrentSkins[entryID];
 
-               // check if loaded
-               if(!skin->loaded && skin->sourcetype == "FileSystem")
-               {
-                       try
-                       {
-                               
ResourceGroupManager::getSingleton().addResourceLocation(skin->source, 
"FileSystem", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-                               
ResourceGroupManager::getSingleton().initialiseResourceGroup(ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-                       }catch(...)
-                       {
-                       }
-                       skin->loaded = true;
-               } else if(!skin->loaded && skin->sourcetype == "Zip")
-               {
-                       CACHE.loadSingleZip(skin->source, -1, false, false);
-                       skin->loaded=true;
-               }
-
+               // we assume its already loaded
                // set selected skin as current
                mSelectedSkin = skin;
 
@@ -477,7 +467,7 @@
                CACHE.checkResourceLoaded(*mSelectedTruck);
 
                this->mCurrentSkins.clear();
-               int res = 
SkinManager::getSingleton().getUsableSkins(mSelectedTruck, this->mCurrentSkins);
+               int res = 
SkinManager::getSingleton().getUsableSkins(mSelectedTruck->guid, 
this->mCurrentSkins);
                if(!res && this->mCurrentSkins.size()>0)
                {
                        // show skin selection dialog!
@@ -633,6 +623,7 @@
        else
                mMainWidget->castType<MyGUI::Window>()->setVisibleSmooth(true);
        if (type != LT_SKIN) mSelectedTruck = nullptr; // when in skin, we 
still need the info
+
        mLoaderType = type;
        mSelectionDone = false;
        getData();

Modified: trunk/source/main/main_sim/RigsOfRods.cpp
===================================================================
--- trunk/source/main/main_sim/RigsOfRods.cpp   2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/main_sim/RigsOfRods.cpp   2011-02-17 00:33:04 UTC (rev 
1683)
@@ -345,8 +345,13 @@
        //main synced streams
        
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("Streams
 Path"), "FileSystem", "Streams");
        exploreStreams(); //this will explore subdirs and register them as 
Packs dirs
-       //cache, flat
+
+
        
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"packs", "FileSystem", "Packs", true);
+       
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"mods", "FileSystem", "Packs", true);
+       explorePacks(); //this will explore subdirs and register them as Packs 
dirs
+
+
        //user vehicles, to be processed later by the cache system
        
ResourceGroupManager::getSingleton().addResourceLocation(SETTINGS.getSetting("User
 Path")+"vehicles", "FileSystem", "VehicleFolders");
        exploreVehicles(); //this will add subdirs contents into General
@@ -505,6 +510,25 @@
        }
 }
 
+void RigsOfRods::explorePacks()
+{
+       String dirsep="/";
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
+       dirsep="\\";
+#endif
+       // load all skins
+       ResourceGroupManager& rgm = ResourceGroupManager::getSingleton();
+       
+       FileInfoListPtr files = rgm.findResourceFileInfo("Packs", "*.skinzip");
+       FileInfoList::iterator iterFiles = files->begin();
+       for (; iterFiles!= files->end(); ++iterFiles)
+       {
+               // always load skin zips
+               String fullpath=iterFiles->archive->getName()+dirsep;
+               rgm.addResourceLocation(fullpath+iterFiles->filename, "Zip", 
"Cache", false);
+       }
+}
+
 void RigsOfRods::exploreVehicles()
 {
        String dirsep="/";
@@ -520,9 +544,10 @@
                if ((*iterFiles).filename==String(".svn")) continue;
                //trying to get the full path
                String fullpath=(*iterFiles).archive->getName()+dirsep;
-               rgm.addResourceLocation(fullpath+(*iterFiles).filename, 
"FileSystem", "VehicleFolders");
+               // new: recursive
+               rgm.addResourceLocation(fullpath+(*iterFiles).filename, 
"FileSystem", "VehicleFolders", true);
                //add textures/temp for unpacked ddx support
-               
rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"textures"+dirsep+"temp",
 "FileSystem", "VehicleFolders");
+               
//rgm.addResourceLocation(fullpath+(*iterFiles).filename+dirsep+"textures"+dirsep+"temp",
 "FileSystem", "VehicleFolders", true);
        }
        LogManager::getSingleton().logMessage("initialiseResourceGroups: 
VehicleFolders");
        try

Modified: trunk/source/main/main_sim/RigsOfRods.h
===================================================================
--- trunk/source/main/main_sim/RigsOfRods.h     2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/main_sim/RigsOfRods.h     2011-02-17 00:33:04 UTC (rev 
1683)
@@ -106,6 +106,7 @@
        void exploreStreams();
        void exploreTerrains();
        void exploreVehicles();
+       void explorePacks();
 };
 
 #endif //RIGSOFRODS_H__

Modified: trunk/source/main/physics/BeamData.h
===================================================================
--- trunk/source/main/physics/BeamData.h        2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/physics/BeamData.h        2011-02-17 00:33:04 UTC (rev 
1683)
@@ -686,6 +686,8 @@
        FlexBody *flexbodies[MAX_FLEXBODIES];
        int free_flexbody;
 
+
+       char guid[128];
 };
 
 // some non-beam structs

Modified: trunk/source/main/physics/input_output/BeamLoadTruck.cpp
===================================================================
--- trunk/source/main/physics/input_output/BeamLoadTruck.cpp    2011-02-16 
18:11:26 UTC (rev 1682)
+++ trunk/source/main/physics/input_output/BeamLoadTruck.cpp    2011-02-17 
00:33:04 UTC (rev 1683)
@@ -605,6 +605,17 @@
                        }
                        continue;
                }
+               
+               if (!strncmp("guid", line, 4))
+               {
+                       int result = sscanf(line,"guid %s", guid);
+                       if (result < 1 || result == EOF)
+                       {
+                               LogManager::getSingleton().logMessage("Error 
parsing File (guid) " + String(fname) +" line " + 
StringConverter::toString(linecounter) + ". trying to continue ...");
+                               continue;
+                       }
+               }
+
                if (!strncmp("set_beam_defaults", line, 17))
                {
                        char default_beam_material2[256]="";
@@ -2289,18 +2300,16 @@
                                // create the meshs scenenode
                                props[free_prop].wheel = 
manager->getRootSceneNode()->createChildSceneNode();
                                // now create the mesh
-                               MeshObject *mo = new MeshObject(manager, 
diwmeshname, "", props[free_prop].wheel, enable_background_loading);
+                               MeshObject *mo = new MeshObject(manager, 
diwmeshname, "", props[free_prop].wheel, usedSkin, enable_background_loading);
                                mo->setSimpleMaterialColour(ColourValue(0, 0.5, 
0.5));
-                               mo->setSkin(usedSkin);
                                
mo->setMaterialFunctionMapper(materialFunctionMapper);
                        }
 
                        // create the meshs scenenode
                        props[free_prop].snode = 
manager->getRootSceneNode()->createChildSceneNode();
                        // now create the mesh
-                       props[free_prop].mo = new MeshObject(manager, meshname, 
"", props[free_prop].snode, enable_background_loading);
+                       props[free_prop].mo = new MeshObject(manager, meshname, 
"", props[free_prop].snode, usedSkin, enable_background_loading);
                        
props[free_prop].mo->setSimpleMaterialColour(ColourValue(1, 1, 0));
-                       props[free_prop].mo->setSkin(usedSkin);
                        
props[free_prop].mo->setMaterialFunctionMapper(materialFunctionMapper);
                        props[free_prop].mo->setCastShadows(shadowmode!=0);
 

Modified: trunk/source/main/utils/MeshObject.h
===================================================================
--- trunk/source/main/utils/MeshObject.h        2011-02-16 18:11:26 UTC (rev 
1682)
+++ trunk/source/main/utils/MeshObject.h        2011-02-17 00:33:04 UTC (rev 
1683)
@@ -33,7 +33,7 @@
 class MeshObject : public Ogre::ResourceBackgroundQueue::Listener, public 
Ogre::Resource::Listener
 {
 public:
-       MeshObject(Ogre::SceneManager *smgr, Ogre::String meshName, 
Ogre::String entityName, Ogre::SceneNode *sceneNode=0, bool 
backgroundLoading=false)
+       MeshObject(Ogre::SceneManager *smgr, Ogre::String meshName, 
Ogre::String entityName, Ogre::SceneNode *sceneNode=0, Skin *s=0, bool 
backgroundLoading=false)
                : smgr(smgr)
                , meshName(meshName)
                , entityName(entityName)
@@ -43,7 +43,7 @@
                , loaded(false)
                , enableSimpleMaterial(false)
                , materialName()
-               , skin(0)
+               , skin(s)
                , castshadows(true)
                , mfm(0)
                , enabled(true)
@@ -73,18 +73,6 @@
                }
        }
 
-       void setSkin(Skin *s)
-       {
-               if(!s) return;
-               skin = s;
-               if(loaded && ent)
-               {
-                       // already loaded, so do it afterwards manually
-                       skin->replaceMeshMaterials(ent);
-               }
-
-       }
-
        void setMaterialFunctionMapper(MaterialFunctionMapper *m)
        {
                if(!m) return;


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

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to