Add newline at end of files to reduce gcc warnings
This commit is contained in:
parent
eaf17afc10
commit
579aefab58
74
include/MaterialMap.h
Normal file
74
include/MaterialMap.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#ifndef __MATERIALMAP_H__
|
||||||
|
#define __MATERIALMAP_H__
|
||||||
|
|
||||||
|
#include <OgreResourceManager.h>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class MaterialMap : public Ogre::Resource
|
||||||
|
{
|
||||||
|
String mMaterials[256];
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// must implement these from the Ogre::Resource interface
|
||||||
|
void loadImpl ();
|
||||||
|
void unloadImpl ();
|
||||||
|
size_t calculateSize () const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MaterialMap (Ogre::ResourceManager *creator, const Ogre::String &name,
|
||||||
|
Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual = false,
|
||||||
|
Ogre::ManualResourceLoader *loader = 0);
|
||||||
|
|
||||||
|
virtual ~MaterialMap ();
|
||||||
|
|
||||||
|
void clearMaterials();
|
||||||
|
String getMaterialAtIndex(uchar uIndex);
|
||||||
|
void setMaterialAtIndex(uchar uIndex, const String& materialName);
|
||||||
|
|
||||||
|
/*void setString (const Ogre::String &str);
|
||||||
|
const Ogre::String &getString () const;*/
|
||||||
|
};
|
||||||
|
|
||||||
|
class MaterialMapPtr : public Ogre::SharedPtr<MaterialMap>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MaterialMapPtr () : Ogre::SharedPtr<MaterialMap> () {}
|
||||||
|
explicit MaterialMapPtr (MaterialMap *rep) : Ogre::SharedPtr<MaterialMap> (rep) {}
|
||||||
|
MaterialMapPtr (const MaterialMapPtr &r) : Ogre::SharedPtr<MaterialMap> (r) {}
|
||||||
|
MaterialMapPtr (const Ogre::ResourcePtr &r) : Ogre::SharedPtr<MaterialMap> ()
|
||||||
|
{
|
||||||
|
// lock & copy other mutex pointer
|
||||||
|
OGRE_LOCK_MUTEX (*r.OGRE_AUTO_MUTEX_NAME)
|
||||||
|
OGRE_COPY_AUTO_SHARED_MUTEX (r.OGRE_AUTO_MUTEX_NAME)
|
||||||
|
pRep = static_cast<MaterialMap*> (r.getPointer ());
|
||||||
|
pUseCount = r.useCountPointer ();
|
||||||
|
if (pUseCount)
|
||||||
|
{
|
||||||
|
++ (*pUseCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Operator used to convert a ResourcePtr to a TextFilePtr
|
||||||
|
MaterialMapPtr& operator=(const Ogre::ResourcePtr& r)
|
||||||
|
{
|
||||||
|
if (pRep == static_cast<MaterialMap*> (r.getPointer ()))
|
||||||
|
return *this;
|
||||||
|
release ();
|
||||||
|
// lock & copy other mutex pointer
|
||||||
|
OGRE_LOCK_MUTEX (*r.OGRE_AUTO_MUTEX_NAME)
|
||||||
|
OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
|
||||||
|
pRep = static_cast<MaterialMap*> (r.getPointer());
|
||||||
|
pUseCount = r.useCountPointer ();
|
||||||
|
if (pUseCount)
|
||||||
|
{
|
||||||
|
++ (*pUseCount);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
31
include/MaterialMapManager.h
Normal file
31
include/MaterialMapManager.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef __MATERIALMAPMANAGER_H__
|
||||||
|
#define __MATERIALMAPMANAGER_H__
|
||||||
|
|
||||||
|
#include <OgreResourceManager.h>
|
||||||
|
#include "MaterialMap.h"
|
||||||
|
#include "TypeDef.h"
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class VOXEL_SCENE_MANAGER_API MaterialMapManager : public Ogre::ResourceManager, public Ogre::Singleton<MaterialMapManager>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// must implement this from ResourceManager's interface
|
||||||
|
Ogre::Resource *createImpl(const Ogre::String &name, Ogre::ResourceHandle handle,
|
||||||
|
const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader,
|
||||||
|
const Ogre::NameValuePairList *createParams);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MaterialMapManager ();
|
||||||
|
virtual ~MaterialMapManager ();
|
||||||
|
|
||||||
|
virtual MaterialMapPtr load (const Ogre::String &name, const Ogre::String &group);
|
||||||
|
|
||||||
|
static MaterialMapManager &getSingleton ();
|
||||||
|
static MaterialMapManager *getSingletonPtr ();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
26
include/MaterialMapSerializer.h
Normal file
26
include/MaterialMapSerializer.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef __MATERIALMAPSERIALIZER_H__
|
||||||
|
#define __MATERIALMAPSERIALIZER_H__
|
||||||
|
|
||||||
|
#include <OgreSerializer.h>
|
||||||
|
#include <OgreString.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class MaterialMap; // forward declaration
|
||||||
|
|
||||||
|
class MaterialMapSerializer : public Ogre::Serializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MaterialMapSerializer ();
|
||||||
|
virtual ~MaterialMapSerializer ();
|
||||||
|
|
||||||
|
void importMaterialMap (Ogre::DataStreamPtr &stream, MaterialMap *pDest);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void tokenize(const String& str, std::vector<String>& tokens, const String& delimiters = " ");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -32,4 +32,4 @@ namespace Ogre
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __SurfacePatch_H__ */
|
#endif /* __SurfacePatch_H__ */
|
||||||
|
@ -26,4 +26,4 @@ namespace Ogre
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __SurfacePatchRenderable_H__ */
|
#endif /* __SurfacePatchRenderable_H__ */
|
||||||
|
30
include/VolumeManager.h
Normal file
30
include/VolumeManager.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef __VOLUMEMANAGER_H__
|
||||||
|
#define __VOLUMEMANAGER_H__
|
||||||
|
|
||||||
|
#include <OgreResourceManager.h>
|
||||||
|
#include "Volume.h"
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class VOXEL_SCENE_MANAGER_API VolumeManager : public Ogre::ResourceManager, public Ogre::Singleton<VolumeManager>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// must implement this from ResourceManager's interface
|
||||||
|
Ogre::Resource *createImpl(const Ogre::String &name, Ogre::ResourceHandle handle,
|
||||||
|
const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader,
|
||||||
|
const Ogre::NameValuePairList *createParams);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
VolumeManager ();
|
||||||
|
virtual ~VolumeManager ();
|
||||||
|
|
||||||
|
virtual VolumePtr load (const Ogre::String &name, const Ogre::String &group);
|
||||||
|
|
||||||
|
static VolumeManager &getSingleton ();
|
||||||
|
static VolumeManager *getSingletonPtr ();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
21
include/VolumeSerializer.h
Normal file
21
include/VolumeSerializer.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef __VOLUMESERIALIZER_H__
|
||||||
|
#define __VOLUMESERIALIZER_H__
|
||||||
|
|
||||||
|
#include <OgreSerializer.h>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Volume; // forward declaration
|
||||||
|
|
||||||
|
class VolumeSerializer : public Ogre::Serializer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VolumeSerializer ();
|
||||||
|
virtual ~VolumeSerializer ();
|
||||||
|
|
||||||
|
//void exportVolume (const Volume *pText, const Ogre::String &fileName);
|
||||||
|
void importVolume (Ogre::DataStreamPtr &stream, Volume *pDest);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
86
source/MaterialMap.cpp
Normal file
86
source/MaterialMap.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#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;
|
||||||
|
}*/
|
||||||
|
}
|
55
source/MaterialMapManager.cpp
Normal file
55
source/MaterialMapManager.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
}
|
61
source/MaterialMapSerializer.cpp
Normal file
61
source/MaterialMapSerializer.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -126,4 +126,4 @@ namespace Ogre
|
|||||||
/*vertexData = m_vecVertexData;
|
/*vertexData = m_vecVertexData;
|
||||||
indexData = m_vecIndexData;*/
|
indexData = m_vecIndexData;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,4 +147,4 @@ namespace Ogre
|
|||||||
{
|
{
|
||||||
return Vector3::ZERO;
|
return Vector3::ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,4 @@ namespace Ogre
|
|||||||
,v2(v2ToSet)
|
,v2(v2ToSet)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,4 +48,4 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
59
source/VolumeManager.cpp
Normal file
59
source/VolumeManager.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#include "VolumeManager.h"
|
||||||
|
|
||||||
|
#include "OgreLogManager.h" //FIXME - shouldn't realy need this in this class?'
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
template<> VolumeManager *Ogre::Singleton<VolumeManager>::ms_Singleton = 0;
|
||||||
|
|
||||||
|
VolumeManager *VolumeManager::getSingletonPtr ()
|
||||||
|
{
|
||||||
|
return ms_Singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeManager &VolumeManager::getSingleton ()
|
||||||
|
{
|
||||||
|
assert (ms_Singleton);
|
||||||
|
return (*ms_Singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeManager::VolumeManager ()
|
||||||
|
{
|
||||||
|
mResourceType = "Volume";
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeManager::~VolumeManager()
|
||||||
|
{
|
||||||
|
// and this is how we unregister it
|
||||||
|
Ogre::ResourceGroupManager::getSingleton ()._unregisterResourceManager (mResourceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumePtr VolumeManager::load (const Ogre::String &name, const Ogre::String &group)
|
||||||
|
{
|
||||||
|
Ogre::LogManager::getSingleton().logMessage("DAVID - calling getByName");
|
||||||
|
VolumePtr textf = getByName (name);
|
||||||
|
Ogre::LogManager::getSingleton().logMessage("DAVID - done getByName");
|
||||||
|
|
||||||
|
if (textf.isNull ())
|
||||||
|
{
|
||||||
|
textf = create (name, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
textf->load ();
|
||||||
|
|
||||||
|
return textf;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ogre::Resource *VolumeManager::createImpl (const Ogre::String &name, Ogre::ResourceHandle handle,
|
||||||
|
const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader,
|
||||||
|
const Ogre::NameValuePairList *createParams)
|
||||||
|
{
|
||||||
|
return new Volume (this, name, handle, group, isManual, loader);
|
||||||
|
}
|
||||||
|
}
|
@ -81,4 +81,4 @@ namespace Ogre
|
|||||||
/*vol.load(stream->getName());*/
|
/*vol.load(stream->getName());*/
|
||||||
//pDest->setVolume(vol);
|
//pDest->setVolume(vol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user