diff --git a/include/Block.h b/include/Block.h new file mode 100644 index 00000000..5cb1d594 --- /dev/null +++ b/include/Block.h @@ -0,0 +1,56 @@ +/****************************************************************************** +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 __Block_H__ +#define __Block_H__ + +#include "OgrePrerequisites.h" + +#include "Constants.h" + +#include "TypeDef.h" + +namespace Ogre +{ + + class VOXEL_SCENE_MANAGER_API Block + { + //Make VolumeIterator a friend + friend class VolumeIterator; + + //Block interface + public: + Block(); + Block(const Block& rhs); + ~Block(); + + Block& operator=(const Block& rhs); + + bool isHomogeneous(void); + + 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); + + void fillWithValue(const uchar value); + + private: + uchar mData[OGRE_NO_OF_VOXELS_IN_BLOCK]; + }; +} + +#endif diff --git a/include/PolyVoxSceneManager.h b/include/PolyVoxSceneManager.h index 71afb071..d7a9b606 100644 --- a/include/PolyVoxSceneManager.h +++ b/include/PolyVoxSceneManager.h @@ -69,8 +69,6 @@ namespace Ogre void generateMeshDataForRegion(uint regionX, uint regionY, uint regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const; - void doRegionGrowing(uint xStart, uint yStart, uint zStart, uchar value); - bool containsPoint(Vector3 pos, float boundary); bool containsPoint(IntVector3 pos, uint boundary); diff --git a/include/Volume.h b/include/Volume.h index ba9bb00f..44fdf756 100644 --- a/include/Volume.h +++ b/include/Volume.h @@ -27,15 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "TypeDef.h" #include "IntegralVector3.h" -#include - namespace Ogre { class VOXEL_SCENE_MANAGER_API Volume { //Make VolumeIterator a friend friend class VolumeIterator; - friend class VolumeResource; //Volume interface public: @@ -45,8 +42,7 @@ namespace Ogre 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); + SharedPtr getBlock(uint index); bool containsPoint(Vector3 pos, float boundary); bool containsPoint(IntVector3 pos, uint boundary); @@ -61,8 +57,6 @@ namespace Ogre static SharedPtr mHomogeneousBlocks[256]; SharedPtr mBlocks[OGRE_NO_OF_BLOCKS_IN_VOLUME]; }; - - VOXEL_SCENE_MANAGER_API Volume createDilatedCopy(Volume& volInput, uchar value); } #endif diff --git a/source/PolyVoxSceneManager.cpp b/source/PolyVoxSceneManager.cpp index 0e1e09af..1cd81e0d 100644 --- a/source/PolyVoxSceneManager.cpp +++ b/source/PolyVoxSceneManager.cpp @@ -688,13 +688,6 @@ namespace Ogre } } - void PolyVoxSceneManager::doRegionGrowing(uint xStart, uint yStart, uint zStart, uchar value) - { - volumeData->regionGrow(xStart,yStart,zStart,value); - //FIXME - keep track of what has changed... - markRegionChanged(0,0,0,OGRE_VOLUME_SIDE_LENGTH-1,OGRE_VOLUME_SIDE_LENGTH-1,OGRE_VOLUME_SIDE_LENGTH-1); - } - uint PolyVoxSceneManager::getSideLength(void) { return OGRE_VOLUME_SIDE_LENGTH; diff --git a/source/Volume.cpp b/source/Volume.cpp index abeaed7e..60638324 100644 --- a/source/Volume.cpp +++ b/source/Volume.cpp @@ -129,7 +129,10 @@ namespace Ogre block->setVoxelAt(xOffset,yOffset,zOffset, value); }*/ - + SharedPtr Volume::getBlock(uint index) + { + return mBlocks[index]; + } bool Volume::containsPoint(Vector3 pos, float boundary) { @@ -332,61 +335,4 @@ namespace Ogre } } } - - Volume createDilatedCopy(Volume& volInput, uchar value) - { - Volume volResult = volInput; - - VolumeIterator iterResult(volResult); - VolumeIterator iterInput(volInput); - - //FIXME - use looping over region thing... - for(uint z = 1; z < OGRE_VOLUME_SIDE_LENGTH-1; z++) - { - //std::cout << "z = " << z << std::endl; - for(uint y = 1; y < OGRE_VOLUME_SIDE_LENGTH-1; y++) - { - for(uint x = 1; x < OGRE_VOLUME_SIDE_LENGTH-1; x++) - { - iterInput.setPosition(x,y,z); - if - ( - (iterInput.peekVoxel1nx1ny1nz() == value) || - (iterInput.peekVoxel1nx1ny0pz() == value) || - (iterInput.peekVoxel1nx1ny1pz() == value) || - (iterInput.peekVoxel1nx0py1nz() == value) || - (iterInput.peekVoxel1nx0py0pz() == value) || - (iterInput.peekVoxel1nx0py1pz() == value) || - (iterInput.peekVoxel1nx1py1nz() == value) || - (iterInput.peekVoxel1nx1py0pz() == value) || - (iterInput.peekVoxel1nx1py1pz() == value) || - - (iterInput.peekVoxel0px1ny1nz() == value) || - (iterInput.peekVoxel0px1ny0pz() == value) || - (iterInput.peekVoxel0px1ny1pz() == value) || - (iterInput.peekVoxel0px0py1nz() == value) || - //(iterInput.peekVoxel0px0py0pz() == value) || - (iterInput.peekVoxel0px0py1pz() == value) || - (iterInput.peekVoxel0px1py1nz() == value) || - (iterInput.peekVoxel0px1py0pz() == value) || - (iterInput.peekVoxel0px1py1pz() == value) || - - (iterInput.peekVoxel1px1ny1nz() == value) || - (iterInput.peekVoxel1px1ny0pz() == value) || - (iterInput.peekVoxel1px1ny1pz() == value) || - (iterInput.peekVoxel1px0py1nz() == value) || - (iterInput.peekVoxel1px0py0pz() == value) || - (iterInput.peekVoxel1px0py1pz() == value) || - (iterInput.peekVoxel1px1py1nz() == value) || - (iterInput.peekVoxel1px1py0pz() == value) || - (iterInput.peekVoxel1px1py1pz() == value) - ) - { - iterResult.setVoxelAt(x,y,z,value); - } - } - } - } - return volResult; - } }