Introduced VolumeResourcePtr as a wrapper around Volume.
This commit is contained in:
@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "Volume.h"
|
||||
#include "SurfaceVertex.h"
|
||||
#include "RegionGeometry.h"
|
||||
#include "VolumeResource.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
@ -100,7 +101,8 @@ namespace Ogre
|
||||
|
||||
NormalGenerationMethod m_normalGenerationMethod;
|
||||
|
||||
VolumePtr volumeData;
|
||||
VolumeResourcePtr volumeResource;
|
||||
Volume* volumeData;
|
||||
|
||||
bool m_bHaveGeneratedMeshes;
|
||||
|
||||
|
68
include/Volume.h
Normal file
68
include/Volume.h
Normal file
@ -0,0 +1,68 @@
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#ifndef __Volume_H__
|
||||
#define __Volume_H__
|
||||
|
||||
#include "OgrePrerequisites.h"
|
||||
#include "OgreSharedPtr.h"
|
||||
|
||||
#include "Block.h"
|
||||
#include "Constants.h"
|
||||
#include "TypeDef.h"
|
||||
#include "IntegralVector3.h"
|
||||
|
||||
#include <OgreResourceManager.h>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class VOXEL_SCENE_MANAGER_API Volume
|
||||
{
|
||||
//Make VolumeIterator a friend
|
||||
friend class VolumeIterator;
|
||||
friend class VolumeResource;
|
||||
|
||||
//Volume interface
|
||||
public:
|
||||
Volume();
|
||||
Volume(const Volume& rhs);
|
||||
~Volume();
|
||||
|
||||
Volume& operator=(const Volume& rhs);
|
||||
|
||||
//uchar getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const;
|
||||
//void setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value);
|
||||
|
||||
bool containsPoint(Vector3 pos, float boundary);
|
||||
bool containsPoint(IntVector3 pos, uint boundary);
|
||||
|
||||
bool loadFromFile(const std::string& sFilename);
|
||||
bool saveToFile(const std::string& sFilename);
|
||||
|
||||
void regionGrow(uint xStart, uint yStart, uint zStart, uchar value);
|
||||
void tidy(void);
|
||||
|
||||
private:
|
||||
static SharedPtr<Block> mHomogeneousBlocks[256];
|
||||
SharedPtr<Block> mBlocks[OGRE_NO_OF_BLOCKS_IN_VOLUME];
|
||||
};
|
||||
|
||||
VOXEL_SCENE_MANAGER_API Volume createDilatedCopy(Volume& volInput, uchar value);
|
||||
}
|
||||
|
||||
#endif
|
@ -2,7 +2,7 @@
|
||||
#define __VOLUMEMANAGER_H__
|
||||
|
||||
#include <OgreResourceManager.h>
|
||||
#include "Volume.h"
|
||||
#include "VolumeResource.h"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
@ -20,7 +20,7 @@ namespace Ogre
|
||||
VolumeManager ();
|
||||
virtual ~VolumeManager ();
|
||||
|
||||
virtual VolumePtr load (const Ogre::String &name, const Ogre::String &group);
|
||||
virtual VolumeResourcePtr load (const Ogre::String &name, const Ogre::String &group);
|
||||
|
||||
static VolumeManager &getSingleton ();
|
||||
static VolumeManager *getSingletonPtr ();
|
||||
|
92
include/VolumeResource.h
Normal file
92
include/VolumeResource.h
Normal file
@ -0,0 +1,92 @@
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#ifndef __VolumeResource_H__
|
||||
#define __VolumeResource_H__
|
||||
|
||||
#include "OgrePrerequisites.h"
|
||||
#include "OgreSharedPtr.h"
|
||||
|
||||
#include "Block.h"
|
||||
#include "Constants.h"
|
||||
#include "TypeDef.h"
|
||||
#include "IntegralVector3.h"
|
||||
#include "Volume.h"
|
||||
|
||||
#include <OgreResourceManager.h>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class VOXEL_SCENE_MANAGER_API VolumeResource : public Ogre::Resource
|
||||
{
|
||||
public:
|
||||
VolumeResource (Ogre::ResourceManager *creator, const Ogre::String &name,
|
||||
Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual = false,
|
||||
Ogre::ManualResourceLoader *loader = 0);
|
||||
~VolumeResource();
|
||||
|
||||
Volume* volume;
|
||||
|
||||
protected:
|
||||
|
||||
// must implement these from the Ogre::Resource interface
|
||||
void loadImpl ();
|
||||
void unloadImpl ();
|
||||
size_t calculateSize () const;
|
||||
};
|
||||
|
||||
class VolumeResourcePtr : public Ogre::SharedPtr<VolumeResource>
|
||||
{
|
||||
public:
|
||||
VolumeResourcePtr () : Ogre::SharedPtr<VolumeResource> () {}
|
||||
explicit VolumeResourcePtr (VolumeResource *rep) : Ogre::SharedPtr<VolumeResource> (rep) {}
|
||||
VolumeResourcePtr (const VolumeResourcePtr &r) : Ogre::SharedPtr<VolumeResource> (r) {}
|
||||
VolumeResourcePtr (const Ogre::ResourcePtr &r) : Ogre::SharedPtr<VolumeResource> ()
|
||||
{
|
||||
// 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<VolumeResource*> (r.getPointer ());
|
||||
pUseCount = r.useCountPointer ();
|
||||
if (pUseCount)
|
||||
{
|
||||
++ (*pUseCount);
|
||||
}
|
||||
}
|
||||
|
||||
/// Operator used to convert a ResourcePtr to a VolumeResourcePtr
|
||||
VolumeResourcePtr& operator=(const Ogre::ResourcePtr& r)
|
||||
{
|
||||
if (pRep == static_cast<VolumeResource*> (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<VolumeResource*> (r.getPointer());
|
||||
pUseCount = r.useCountPointer ();
|
||||
if (pUseCount)
|
||||
{
|
||||
++ (*pUseCount);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user