Removed MaterialMap.

This commit is contained in:
David Williams
2008-01-29 21:04:13 +00:00
parent 7b8e035bd1
commit e5fbb59db2
9 changed files with 0 additions and 346 deletions

View File

@ -1,86 +0,0 @@
#include "MaterialMap.h"
#include "MaterialMapSerializer.h"
namespace Ogre
{
MaterialMap::MaterialMap (Ogre::ResourceManager* creator, const Ogre::String &name,
Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual,
Ogre::ManualResourceLoader *loader) :
Ogre::Resource (creator, name, handle, group, isManual, loader)
{
/* If you were storing a pointer to an object, then you would set that pointer to NULL here.
*/
clearMaterials();
/* For consistency with StringInterface, but we don't add any parameters here
That's because the Resource implementation of StringInterface is to
list all the options that need to be set before loading, of which
we have none as such. Full details can be set through scripts.
*/
createParamDictionary ("MaterialMap");
}
MaterialMap::~MaterialMap ()
{
unload ();
}
void MaterialMap::clearMaterials()
{
for(uint ct = 0; ct < 256; ++ct)
{
mMaterials[ct] = "";
}
}
// farm out to TextFileSerializer
void MaterialMap::loadImpl ()
{
/* If you were storing a pointer to an object, then you would create that object with 'new' here.
*/
MaterialMapSerializer serializer;
Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton ().openResource (mName, mGroup, true, this);
serializer.importMaterialMap (stream, this);
}
void MaterialMap::unloadImpl ()
{
/* If you were storing a pointer to an object, then you would check the pointer here,
and if it is not NULL, you would destruct the object and set its pointer to NULL again.
*/
//mString.clear ();
}
size_t MaterialMap::calculateSize () const
{
size_t uSumOfLengths = 0;
for(uint ct = 0; ct < 256; ++ct)
{
uSumOfLengths += mMaterials[ct].length();
}
return uSumOfLengths;
}
String MaterialMap::getMaterialAtIndex(uchar uIndex)
{
return mMaterials[uIndex];
}
void MaterialMap::setMaterialAtIndex(uchar uIndex, const String& materialName)
{
mMaterials[uIndex] = materialName;
}
/*void MaterialMap::setString (const Ogre::String &str)
{
mString = str;
}
const Ogre::String &MaterialMap::getString () const
{
return mString;
}*/
}

View File

@ -1,55 +0,0 @@
#include "MaterialMapManager.h"
namespace Ogre
{
template<> MaterialMapManager *Ogre::Singleton<MaterialMapManager>::ms_Singleton = 0;
MaterialMapManager *MaterialMapManager::getSingletonPtr ()
{
return ms_Singleton;
}
MaterialMapManager &MaterialMapManager::getSingleton ()
{
assert (ms_Singleton);
return (*ms_Singleton);
}
MaterialMapManager::MaterialMapManager ()
{
mResourceType = "MaterialMap";
// low, because it will likely reference other resources
mLoadOrder = 30.0f;
// this is how we register the ResourceManager with OGRE
Ogre::ResourceGroupManager::getSingleton ()._registerResourceManager (mResourceType, this);
}
MaterialMapManager::~MaterialMapManager()
{
// and this is how we unregister it
Ogre::ResourceGroupManager::getSingleton ()._unregisterResourceManager (mResourceType);
}
MaterialMapPtr MaterialMapManager::load (const Ogre::String &name, const Ogre::String &group)
{
MaterialMapPtr textf = getByName (name);
if (textf.isNull ())
{
textf = create (name, group);
}
textf->load ();
return textf;
}
Ogre::Resource *MaterialMapManager::createImpl (const Ogre::String &name, Ogre::ResourceHandle handle,
const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader,
const Ogre::NameValuePairList *createParams)
{
return new MaterialMap (this, name, handle, group, isManual, loader);
}
}

View File

@ -1,61 +0,0 @@
#include "MaterialMapSerializer.h"
#include "MaterialMap.h"
#include <OgreStringConverter.h>
using namespace std;
namespace Ogre
{
MaterialMapSerializer::MaterialMapSerializer ()
{
}
MaterialMapSerializer::~MaterialMapSerializer ()
{
}
void MaterialMapSerializer::importMaterialMap (Ogre::DataStreamPtr &stream, MaterialMap *pDest)
{
pDest->clearMaterials();
while(!stream->eof())
{
String line = stream->getLine();
vector<String> tokens;
tokenize(line, tokens, " =");
if(tokens.size() == 2)
{
//Get the index
String sIndex = tokens[0];
if(StringConverter::isNumber(sIndex))
{
int iIndex = StringConverter::parseInt(sIndex);
if((iIndex > 0) && (iIndex < 256))
{
pDest->setMaterialAtIndex(iIndex, tokens[1]);
}
}
}
}
}
void MaterialMapSerializer::tokenize(const String& str, vector<String>& tokens, const String& delimiters)
{
// Skip delimiters at beginning.
String::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
String::size_type pos = str.find_first_of(delimiters, lastPos);
while (String::npos != pos || String::npos != lastPos)
{
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
pos = str.find_first_of(delimiters, lastPos);
}
}
}

View File

@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
******************************************************************************/
#include "MarchingCubesTables.h"
#include "MaterialMapManager.h"
#include "SurfaceVertex.h"
#include "SurfaceEdge.h"
#include "IndexedSurfacePatch.h"
@ -63,8 +62,6 @@ namespace Ogre
volumeData->tidy();
//Load material map
materialMap = MaterialMapManager::getSingletonPtr()->load(filename + ".materialmap", "General");
setAllUpToDateFlagsTo(false);