Renamed to PolyVox
This commit is contained in:
61
CMakeLists.txt
Normal file
61
CMakeLists.txt
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
PROJECT(PolyVoxSceneManager)
|
||||||
|
|
||||||
|
#Projects source files
|
||||||
|
SET(SRC_FILES
|
||||||
|
source/Block.cpp
|
||||||
|
source/MarchingCubesTables.cpp
|
||||||
|
source/MaterialMap.cpp
|
||||||
|
source/MaterialMapManager.cpp
|
||||||
|
source/MaterialMapSerializer.cpp
|
||||||
|
source/PolyVoxSceneManager.cpp
|
||||||
|
source/Volume.cpp
|
||||||
|
source/VolumeIterator.cpp
|
||||||
|
source/VolumeManager.cpp
|
||||||
|
source/VolumeSerializer.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
#Projects headers files
|
||||||
|
SET(INC_FILES
|
||||||
|
include/Block.h
|
||||||
|
include/Constants.h
|
||||||
|
include/IntegralVector3.h
|
||||||
|
include/MarchingCubesTables.h
|
||||||
|
include/MaterialMap.h
|
||||||
|
include/MaterialMapManager.h
|
||||||
|
include/MaterialMapSerializer.h
|
||||||
|
include/PolyVoxSceneManager.h
|
||||||
|
include/Triangle.h
|
||||||
|
include/TypeDef.h
|
||||||
|
include/Vertex.h
|
||||||
|
include/Volume.h
|
||||||
|
include/VolumeIterator.h
|
||||||
|
include/VolumeManager.h
|
||||||
|
include/VolumeSerializer.h
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DVOXEL_SCENE_MANAGER_EXPORT) #Export symbols in the .dll
|
||||||
|
|
||||||
|
#Appends "_d" to the generated library when in debug mode
|
||||||
|
SET(CMAKE_DEBUG_POSTFIX "_d")
|
||||||
|
|
||||||
|
#"Sources" and "Headers" are the group names in Visual Studio.
|
||||||
|
#They may have other uses too...
|
||||||
|
SOURCE_GROUP("Sources" FILES ${SRC_FILES})
|
||||||
|
SOURCE_GROUP("Headers" FILES ${INC_FILES})
|
||||||
|
|
||||||
|
#Tell CMake the paths
|
||||||
|
LINK_DIRECTORIES(${OGRE_LIB_DIR})
|
||||||
|
INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
#Build
|
||||||
|
ADD_LIBRARY(PolyVoxSceneManager SHARED ${SRC_FILES} ${INC_FILES})
|
||||||
|
TARGET_LINK_LIBRARIES(PolyVoxSceneManager ${OGRE_LIBRARIES})
|
||||||
|
|
||||||
|
#Install
|
||||||
|
INSTALL(TARGETS PolyVoxSceneManager
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(DIRECTORY materials/ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/materials PATTERN "*.svn*" EXCLUDE)
|
122
include/PolyVoxSceneManager.h
Normal file
122
include/PolyVoxSceneManager.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
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 __PolyVoxSceneManager_H__
|
||||||
|
#define __PolyVoxSceneManager_H__
|
||||||
|
|
||||||
|
#include "OgrePrerequisites.h"
|
||||||
|
#include "OgreSceneManager.h"
|
||||||
|
|
||||||
|
#include "Constants.h"
|
||||||
|
#include "MaterialMap.h"
|
||||||
|
#include "Triangle.h"
|
||||||
|
#include "TypeDef.h"
|
||||||
|
#include "Volume.h"
|
||||||
|
#include "Vertex.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
enum NormalGenerationMethod
|
||||||
|
{
|
||||||
|
SIMPLE,
|
||||||
|
CENTRAL_DIFFERENCE,
|
||||||
|
SOBEL
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Factory for default scene manager
|
||||||
|
class VOXEL_SCENE_MANAGER_API PolyVoxSceneManagerFactory : public SceneManagerFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Factory type name
|
||||||
|
static const String FACTORY_TYPE_NAME;
|
||||||
|
SceneManager* createInstance(const String& instanceName);
|
||||||
|
void destroyInstance(SceneManager* instance);
|
||||||
|
protected:
|
||||||
|
void initMetaData(void) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Voxel scene manager
|
||||||
|
class VOXEL_SCENE_MANAGER_API PolyVoxSceneManager : public SceneManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Constructors, etc
|
||||||
|
PolyVoxSceneManager(const String& name);
|
||||||
|
~PolyVoxSceneManager();
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
uchar getMaterialIndexAt(uint uX, uint uY, uint uZ);
|
||||||
|
const String& getTypeName(void) const;
|
||||||
|
uint getSideLength(void);
|
||||||
|
|
||||||
|
|
||||||
|
//Setters
|
||||||
|
//void setMaterialNameForIndex(uchar uIndex, std::string sMaterialName);
|
||||||
|
void setNormalGenerationMethod(NormalGenerationMethod method);
|
||||||
|
void _findVisibleObjects(Camera* cam, VisibleObjectsBoundsInfo * visibleBounds, bool onlyShadowCasters);
|
||||||
|
|
||||||
|
void setAllUpToDateFalse(void);
|
||||||
|
void createSphereAt(Vector3 centre, Real radius, uchar value, bool painting);
|
||||||
|
|
||||||
|
bool loadScene(const String& filename);
|
||||||
|
bool saveScene(const String& filename);
|
||||||
|
|
||||||
|
void generateLevelVolume(void);
|
||||||
|
|
||||||
|
void generateMeshDataForRegion(uint regionX, uint regionY, uint regionZ, std::vector<Vertex>& vertexData, std::vector< std::vector<Triangle> >& indexData) const;
|
||||||
|
void mergeVertices5(std::vector<Vertex>& vertexData, std::vector< std::vector<Triangle> >& indexData) const;
|
||||||
|
bool verticesArePlanar3(uint uCurrentVertex, std::set<uint> setConnectedVertices, std::vector<Vertex>& vertexData) const;
|
||||||
|
|
||||||
|
void doRegionGrowing(uint xStart, uint yStart, uint zStart, uchar value);
|
||||||
|
|
||||||
|
bool containsPoint(Vector3 pos, float boundary);
|
||||||
|
bool containsPoint(IntVector3 pos, uint boundary);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SceneNode* sceneNodes[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
|
std::map<uchar,ManualObject*> m_mapManualObjects[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
|
bool manualObjectUpToDate[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
|
bool regionIsHomogenous[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
|
|
||||||
|
void igniteVoxel(UIntVector3 voxelToIgnite);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void markVoxelChanged(uint x, uint y, uint z);
|
||||||
|
void markRegionChanged(uint firstX, uint firstY, uint firstZ, uint lastX, uint lastY, uint lastZ);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint fileNo;
|
||||||
|
|
||||||
|
bool useNormalSmoothing;
|
||||||
|
uint normalSmoothingFilterSize;
|
||||||
|
|
||||||
|
NormalGenerationMethod m_normalGenerationMethod;
|
||||||
|
|
||||||
|
VolumePtr volumeData;
|
||||||
|
MaterialMapPtr materialMap;
|
||||||
|
|
||||||
|
std::queue<UIntVector3> m_queueVoxelsToBurn;
|
||||||
|
|
||||||
|
//std::string m_aMaterialNames[256];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
1278
source/PolyVoxSceneManager.cpp
Normal file
1278
source/PolyVoxSceneManager.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user