Started removing OgreVector3 from main library.
This commit is contained in:
@ -23,6 +23,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
|
|
||||||
#include <OgreVector3.h>
|
#include <OgreVector3.h>
|
||||||
|
|
||||||
|
#include "Vector.hpp"
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
template <typename Type> class IntegralVector3
|
template <typename Type> class IntegralVector3
|
||||||
@ -66,9 +68,9 @@ namespace Ogre
|
|||||||
return false; //They are equal
|
return false; //They are equal
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 toOgreVector3(void) const
|
Vector3DFloat toVector3DFloat(void) const
|
||||||
{
|
{
|
||||||
return Vector3(Real(x), Real(y), Real(z));
|
return Vector3DFloat(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type x;
|
Type x;
|
||||||
|
@ -32,6 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
#include "SurfaceVertex.h"
|
#include "SurfaceVertex.h"
|
||||||
#include "RegionGeometry.h"
|
#include "RegionGeometry.h"
|
||||||
|
|
||||||
|
#include "Vector.hpp"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
@ -64,13 +66,13 @@ namespace Ogre
|
|||||||
std::list<RegionGeometry> getChangedRegionGeometry(void);
|
std::list<RegionGeometry> getChangedRegionGeometry(void);
|
||||||
|
|
||||||
void setAllUpToDateFlagsTo(bool newUpToDateValue);
|
void setAllUpToDateFlagsTo(bool newUpToDateValue);
|
||||||
void createSphereAt(Vector3 centre, Real radius, boost::uint8_t value, bool painting);
|
void createSphereAt(Vector3DFloat centre, Real radius, boost::uint8_t value, bool painting);
|
||||||
|
|
||||||
void generateLevelVolume(void);
|
void generateLevelVolume(void);
|
||||||
|
|
||||||
void generateMeshDataForRegion(boost::uint16_t regionX,boost:: uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const;
|
void generateMeshDataForRegion(boost::uint16_t regionX,boost:: uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const;
|
||||||
|
|
||||||
bool containsPoint(Vector3 pos, float boundary);
|
bool containsPoint(Vector3DFloat pos, float boundary);
|
||||||
bool containsPoint(IntVector3 pos, boost::uint16_t boundary);
|
bool containsPoint(IntVector3 pos, boost::uint16_t boundary);
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ namespace Ogre
|
|||||||
//SurfacePatchRenderable* m_singleMaterialSurfaces[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
//SurfacePatchRenderable* m_singleMaterialSurfaces[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
//SurfacePatchRenderable* m_multiMaterialSurfaces[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
//SurfacePatchRenderable* m_multiMaterialSurfaces[OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS][OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
|
|
||||||
Vector3 computeNormal(const Vector3& position, NormalGenerationMethod normalGenerationMethod) const;
|
Vector3DFloat computeNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void markVoxelChanged(boost::uint16_t x, boost::uint16_t y, boost::uint16_t z);
|
void markVoxelChanged(boost::uint16_t x, boost::uint16_t y, boost::uint16_t z);
|
||||||
|
@ -34,7 +34,7 @@ namespace Ogre
|
|||||||
public:
|
public:
|
||||||
SurfaceVertex();
|
SurfaceVertex();
|
||||||
SurfaceVertex(UIntVector3 positionToSet, float materialToSet, float alphaToSet);
|
SurfaceVertex(UIntVector3 positionToSet, float materialToSet, float alphaToSet);
|
||||||
SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet);
|
SurfaceVertex(UIntVector3 positionToSet, Vector3DFloat normalToSet);
|
||||||
|
|
||||||
friend bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs);
|
friend bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs);
|
||||||
friend bool operator < (const SurfaceVertex& lhs, const SurfaceVertex& rhs);
|
friend bool operator < (const SurfaceVertex& lhs, const SurfaceVertex& rhs);
|
||||||
@ -42,19 +42,19 @@ namespace Ogre
|
|||||||
float getAlpha(void) const;
|
float getAlpha(void) const;
|
||||||
const SurfaceEdgeIterator& getEdge(void) const;
|
const SurfaceEdgeIterator& getEdge(void) const;
|
||||||
float getMaterial(void) const;
|
float getMaterial(void) const;
|
||||||
const Vector3& getNormal(void) const;
|
const Vector3DFloat& getNormal(void) const;
|
||||||
const UIntVector3& getPosition(void) const;
|
const UIntVector3& getPosition(void) const;
|
||||||
|
|
||||||
void setAlpha(float alphaToSet);
|
void setAlpha(float alphaToSet);
|
||||||
void setEdge(const SurfaceEdgeIterator& edgeToSet);
|
void setEdge(const SurfaceEdgeIterator& edgeToSet);
|
||||||
void setMaterial(float materialToSet);
|
void setMaterial(float materialToSet);
|
||||||
void setNormal(const Vector3& normalToSet);
|
void setNormal(const Vector3DFloat& normalToSet);
|
||||||
|
|
||||||
std::string toString(void) const;
|
std::string toString(void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UIntVector3 position;
|
UIntVector3 position;
|
||||||
Vector3 normal;
|
Vector3DFloat normal;
|
||||||
float material;
|
float material;
|
||||||
float alpha;
|
float alpha;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace Ogre
|
|||||||
|
|
||||||
Block* getBlock(boost::uint16_t index);
|
Block* getBlock(boost::uint16_t index);
|
||||||
|
|
||||||
bool containsPoint(Vector3 pos, float boundary);
|
bool containsPoint(Vector3DFloat pos, float boundary);
|
||||||
bool containsPoint(IntVector3 pos, boost::uint16_t boundary);
|
bool containsPoint(IntVector3 pos, boost::uint16_t boundary);
|
||||||
|
|
||||||
bool loadFromFile(const std::string& sFilename);
|
bool loadFromFile(const std::string& sFilename);
|
||||||
|
@ -42,9 +42,9 @@ namespace Ogre
|
|||||||
float getAveragedVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, boost::uint16_t size) const;
|
float getAveragedVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, boost::uint16_t size) const;
|
||||||
|
|
||||||
//FIXME - this shouldn't return float vector
|
//FIXME - this shouldn't return float vector
|
||||||
Vector3 getCentralDifferenceGradient(void) const;
|
Vector3DFloat getCentralDifferenceGradient(void) const;
|
||||||
Vector3 getAveragedCentralDifferenceGradient(void) const;
|
Vector3DFloat getAveragedCentralDifferenceGradient(void) const;
|
||||||
Vector3 getSobelGradient(void) const;
|
Vector3DFloat getSobelGradient(void) const;
|
||||||
|
|
||||||
boost::uint16_t getPosX(void);
|
boost::uint16_t getPosX(void);
|
||||||
boost::uint16_t getPosY(void);
|
boost::uint16_t getPosY(void);
|
||||||
|
@ -96,15 +96,15 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyVoxSceneManager::createSphereAt(Vector3 centre, Real radius, uint8_t value, bool painting)
|
void PolyVoxSceneManager::createSphereAt(Vector3DFloat centre, Real radius, uint8_t value, bool painting)
|
||||||
{
|
{
|
||||||
int firstX = static_cast<int>(std::floor(centre.x - radius));
|
int firstX = static_cast<int>(std::floor(centre.x() - radius));
|
||||||
int firstY = static_cast<int>(std::floor(centre.y - radius));
|
int firstY = static_cast<int>(std::floor(centre.y() - radius));
|
||||||
int firstZ = static_cast<int>(std::floor(centre.z - radius));
|
int firstZ = static_cast<int>(std::floor(centre.z() - radius));
|
||||||
|
|
||||||
int lastX = static_cast<int>(std::ceil(centre.x + radius));
|
int lastX = static_cast<int>(std::ceil(centre.x() + radius));
|
||||||
int lastY = static_cast<int>(std::ceil(centre.y + radius));
|
int lastY = static_cast<int>(std::ceil(centre.y() + radius));
|
||||||
int lastZ = static_cast<int>(std::ceil(centre.z + radius));
|
int lastZ = static_cast<int>(std::ceil(centre.z() + radius));
|
||||||
|
|
||||||
Real radiusSquared = radius * radius;
|
Real radiusSquared = radius * radius;
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ namespace Ogre
|
|||||||
while(volIter.isValidForRegion())
|
while(volIter.isValidForRegion())
|
||||||
{
|
{
|
||||||
//if((volIter.getPosX()*volIter.getPosX()+volIter.getPosY()*volIter.getPosY()+volIter.getPosZ()*volIter.getPosZ()) < radiusSquared)
|
//if((volIter.getPosX()*volIter.getPosX()+volIter.getPosY()*volIter.getPosY()+volIter.getPosZ()*volIter.getPosZ()) < radiusSquared)
|
||||||
if((centre - Vector3(volIter.getPosX(),volIter.getPosY(),volIter.getPosZ())).squaredLength() <= radiusSquared)
|
if((centre - Vector3DFloat(volIter.getPosX(),volIter.getPosY(),volIter.getPosZ())).lengthSquared() <= radiusSquared)
|
||||||
{
|
{
|
||||||
if(painting)
|
if(painting)
|
||||||
{
|
{
|
||||||
@ -186,18 +186,18 @@ namespace Ogre
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Rooms
|
//Rooms
|
||||||
Vector3 centre(128,128,128);
|
Vector3DFloat centre(128,128,128);
|
||||||
Vector3 v3dSize(192,96,128);
|
Vector3DFloat v3dSize(192,96,128);
|
||||||
|
|
||||||
uint16_t uHalfX = static_cast<uint16_t>(v3dSize.x / 2);
|
uint16_t uHalfX = static_cast<uint16_t>(v3dSize.x() / 2);
|
||||||
uint16_t uHalfY = static_cast<uint16_t>(v3dSize.y / 2);
|
uint16_t uHalfY = static_cast<uint16_t>(v3dSize.y() / 2);
|
||||||
uint16_t uHalfZ = static_cast<uint16_t>(v3dSize.z / 2);
|
uint16_t uHalfZ = static_cast<uint16_t>(v3dSize.z() / 2);
|
||||||
|
|
||||||
for(uint16_t z = static_cast<uint16_t>(centre.z) - uHalfZ; z < static_cast<uint16_t>(centre.z) + uHalfZ; z++)
|
for(uint16_t z = static_cast<uint16_t>(centre.z()) - uHalfZ; z < static_cast<uint16_t>(centre.z()) + uHalfZ; z++)
|
||||||
{
|
{
|
||||||
for(uint16_t y = static_cast<uint16_t>(centre.y) - uHalfY; y < static_cast<uint16_t>(centre.y) + uHalfY; y++)
|
for(uint16_t y = static_cast<uint16_t>(centre.y()) - uHalfY; y < static_cast<uint16_t>(centre.y()) + uHalfY; y++)
|
||||||
{
|
{
|
||||||
for(uint16_t x = static_cast<uint16_t>(centre.x) - uHalfX; x < static_cast<uint16_t>(centre.x) + uHalfX; x++)
|
for(uint16_t x = static_cast<uint16_t>(centre.x()) - uHalfX; x < static_cast<uint16_t>(centre.x()) + uHalfX; x++)
|
||||||
{
|
{
|
||||||
volIter.setVoxelAt(x,y,z,0);
|
volIter.setVoxelAt(x,y,z,0);
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ namespace Ogre
|
|||||||
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->m_vecVertices.begin();
|
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->m_vecVertices.begin();
|
||||||
while(iterSurfaceVertex != singleMaterialPatch->m_vecVertices.end())
|
while(iterSurfaceVertex != singleMaterialPatch->m_vecVertices.end())
|
||||||
{
|
{
|
||||||
Vector3 tempNormal = computeNormal((iterSurfaceVertex->getPosition() + offset).toOgreVector3()/2.0f, CENTRAL_DIFFERENCE);
|
Vector3DFloat tempNormal = computeNormal((iterSurfaceVertex->getPosition() + offset).toVector3DFloat()/2.0f, CENTRAL_DIFFERENCE);
|
||||||
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);
|
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);
|
||||||
++iterSurfaceVertex;
|
++iterSurfaceVertex;
|
||||||
}
|
}
|
||||||
@ -515,7 +515,7 @@ namespace Ogre
|
|||||||
iterSurfaceVertex = multiMaterialPatch->m_vecVertices.begin();
|
iterSurfaceVertex = multiMaterialPatch->m_vecVertices.begin();
|
||||||
while(iterSurfaceVertex != multiMaterialPatch->m_vecVertices.end())
|
while(iterSurfaceVertex != multiMaterialPatch->m_vecVertices.end())
|
||||||
{
|
{
|
||||||
Vector3 tempNormal = computeNormal((iterSurfaceVertex->getPosition() + offset).toOgreVector3()/2.0f, CENTRAL_DIFFERENCE);
|
Vector3DFloat tempNormal = computeNormal((iterSurfaceVertex->getPosition() + offset).toVector3DFloat()/2.0f, CENTRAL_DIFFERENCE);
|
||||||
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);
|
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);
|
||||||
++iterSurfaceVertex;
|
++iterSurfaceVertex;
|
||||||
}
|
}
|
||||||
@ -531,25 +531,25 @@ namespace Ogre
|
|||||||
//return singleMaterialPatch;
|
//return singleMaterialPatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 PolyVoxSceneManager::computeNormal(const Vector3& position, NormalGenerationMethod normalGenerationMethod) const
|
Vector3DFloat PolyVoxSceneManager::computeNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const
|
||||||
{
|
{
|
||||||
VolumeIterator volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
VolumeIterator volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
||||||
|
|
||||||
const float posX = position.x;
|
const float posX = position.x();
|
||||||
const float posY = position.y;
|
const float posY = position.y();
|
||||||
const float posZ = position.z;
|
const float posZ = position.z();
|
||||||
|
|
||||||
const uint16_t floorX = static_cast<uint16_t>(posX);
|
const uint16_t floorX = static_cast<uint16_t>(posX);
|
||||||
const uint16_t floorY = static_cast<uint16_t>(posY);
|
const uint16_t floorY = static_cast<uint16_t>(posY);
|
||||||
const uint16_t floorZ = static_cast<uint16_t>(posZ);
|
const uint16_t floorZ = static_cast<uint16_t>(posZ);
|
||||||
|
|
||||||
Vector3 result;
|
Vector3DFloat result;
|
||||||
|
|
||||||
|
|
||||||
if(normalGenerationMethod == SOBEL)
|
if(normalGenerationMethod == SOBEL)
|
||||||
{
|
{
|
||||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||||
const Vector3 gradFloor = volIter.getSobelGradient();
|
const Vector3DFloat gradFloor = volIter.getSobelGradient();
|
||||||
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
||||||
{
|
{
|
||||||
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||||
@ -562,9 +562,9 @@ namespace Ogre
|
|||||||
{
|
{
|
||||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
||||||
}
|
}
|
||||||
const Vector3 gradCeil = volIter.getSobelGradient();
|
const Vector3DFloat gradCeil = volIter.getSobelGradient();
|
||||||
result = ((gradFloor + gradCeil) * -1.0);
|
result = ((gradFloor + gradCeil) * -1.0);
|
||||||
if(result.squaredLength() < 0.0001)
|
if(result.lengthSquared() < 0.0001)
|
||||||
{
|
{
|
||||||
//Operation failed - fall back on simple gradient estimation
|
//Operation failed - fall back on simple gradient estimation
|
||||||
normalGenerationMethod = SIMPLE;
|
normalGenerationMethod = SIMPLE;
|
||||||
@ -573,7 +573,7 @@ namespace Ogre
|
|||||||
if(normalGenerationMethod == CENTRAL_DIFFERENCE)
|
if(normalGenerationMethod == CENTRAL_DIFFERENCE)
|
||||||
{
|
{
|
||||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||||
const Vector3 gradFloor = volIter.getCentralDifferenceGradient();
|
const Vector3DFloat gradFloor = volIter.getCentralDifferenceGradient();
|
||||||
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
||||||
{
|
{
|
||||||
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||||
@ -586,9 +586,9 @@ namespace Ogre
|
|||||||
{
|
{
|
||||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
||||||
}
|
}
|
||||||
const Vector3 gradCeil = volIter.getCentralDifferenceGradient();
|
const Vector3DFloat gradCeil = volIter.getCentralDifferenceGradient();
|
||||||
result = ((gradFloor + gradCeil) * -1.0);
|
result = ((gradFloor + gradCeil) * -1.0);
|
||||||
if(result.squaredLength() < 0.0001)
|
if(result.lengthSquared() < 0.0001)
|
||||||
{
|
{
|
||||||
//Operation failed - fall back on simple gradient estimation
|
//Operation failed - fall back on simple gradient estimation
|
||||||
normalGenerationMethod = SIMPLE;
|
normalGenerationMethod = SIMPLE;
|
||||||
@ -601,17 +601,17 @@ namespace Ogre
|
|||||||
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
||||||
{
|
{
|
||||||
uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0;
|
uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0;
|
||||||
result = Vector3(uFloor - uCeil,0.0,0.0);
|
result = Vector3DFloat(uFloor - uCeil,0.0,0.0);
|
||||||
}
|
}
|
||||||
else if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5
|
else if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5
|
||||||
{
|
{
|
||||||
uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0;
|
uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0;
|
||||||
result = Vector3(0.0,uFloor - uCeil,0.0);
|
result = Vector3DFloat(0.0,uFloor - uCeil,0.0);
|
||||||
}
|
}
|
||||||
else if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5
|
else if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5
|
||||||
{
|
{
|
||||||
uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0;
|
uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0;
|
||||||
result = Vector3(0.0, 0.0,uFloor - uCeil);
|
result = Vector3DFloat(0.0, 0.0,uFloor - uCeil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -701,7 +701,7 @@ namespace Ogre
|
|||||||
m_normalGenerationMethod = method;
|
m_normalGenerationMethod = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PolyVoxSceneManager::containsPoint(Vector3 pos, float boundary)
|
bool PolyVoxSceneManager::containsPoint(Vector3DFloat pos, float boundary)
|
||||||
{
|
{
|
||||||
return volumeData->containsPoint(pos, boundary);
|
return volumeData->containsPoint(pos, boundary);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace Ogre
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet)
|
SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, Vector3DFloat normalToSet)
|
||||||
:position(positionToSet)
|
:position(positionToSet)
|
||||||
,normal(normalToSet)
|
,normal(normalToSet)
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ namespace Ogre
|
|||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vector3& SurfaceVertex::getNormal(void) const
|
const Vector3DFloat& SurfaceVertex::getNormal(void) const
|
||||||
{
|
{
|
||||||
return normal;
|
return normal;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ namespace Ogre
|
|||||||
edge = edgeToSet;
|
edge = edgeToSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceVertex::setNormal(const Vector3& normalToSet)
|
void SurfaceVertex::setNormal(const Vector3DFloat& normalToSet)
|
||||||
{
|
{
|
||||||
normal = normalToSet;
|
normal = normalToSet;
|
||||||
normal.normalise();
|
normal.normalise();
|
||||||
@ -76,7 +76,7 @@ namespace Ogre
|
|||||||
std::string SurfaceVertex::toString(void) const
|
std::string SurfaceVertex::toString(void) const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "SurfaceVertex: Position = (" << position.x << "," << position.y << "," << position.z << "), Normal = " << StringConverter::toString(normal);
|
ss << "SurfaceVertex: Position = (" << position.x << "," << position.y << "," << position.z << "), Normal = " << normal;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,14 +138,14 @@ namespace Ogre
|
|||||||
return mBlocks[index];
|
return mBlocks[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Volume::containsPoint(Vector3 pos, float boundary)
|
bool Volume::containsPoint(Vector3DFloat pos, float boundary)
|
||||||
{
|
{
|
||||||
return (pos.x < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary)
|
return (pos.x() < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary)
|
||||||
&& (pos.y < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary)
|
&& (pos.y() < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary)
|
||||||
&& (pos.z < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary)
|
&& (pos.z() < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary)
|
||||||
&& (pos.x > boundary)
|
&& (pos.x() > boundary)
|
||||||
&& (pos.y > boundary)
|
&& (pos.y() > boundary)
|
||||||
&& (pos.z > boundary);
|
&& (pos.z() > boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Volume::containsPoint(IntVector3 pos, uint16_t boundary)
|
bool Volume::containsPoint(IntVector3 pos, uint16_t boundary)
|
||||||
|
@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
#include "Volume.h"
|
#include "Volume.h"
|
||||||
#include "VolumeIterator.h"
|
#include "VolumeIterator.h"
|
||||||
|
|
||||||
#include "OgreVector3.h"
|
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
@ -154,7 +152,7 @@ namespace Ogre
|
|||||||
block->setVoxelAt(xOffset,yOffset,zOffset, value);
|
block->setVoxelAt(xOffset,yOffset,zOffset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 VolumeIterator::getCentralDifferenceGradient(void) const
|
Vector3DFloat VolumeIterator::getCentralDifferenceGradient(void) const
|
||||||
{
|
{
|
||||||
//FIXME - should this test be here?
|
//FIXME - should this test be here?
|
||||||
if((mXPosInVolume < 1) || (mXPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2) ||
|
if((mXPosInVolume < 1) || (mXPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2) ||
|
||||||
@ -162,7 +160,7 @@ namespace Ogre
|
|||||||
(mZPosInVolume < 1) || (mZPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2))
|
(mZPosInVolume < 1) || (mZPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2))
|
||||||
{
|
{
|
||||||
//LogManager::getSingleton().logMessage("Out of range");
|
//LogManager::getSingleton().logMessage("Out of range");
|
||||||
return Vector3(0.0,0.0,0.0);
|
return Vector3DFloat(0.0,0.0,0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME - bitwise way of doing this?
|
//FIXME - bitwise way of doing this?
|
||||||
@ -175,10 +173,10 @@ namespace Ogre
|
|||||||
uint8_t voxel1nz = peekVoxel0px0py1nz() > 0 ? 1: 0;
|
uint8_t voxel1nz = peekVoxel0px0py1nz() > 0 ? 1: 0;
|
||||||
uint8_t voxel1pz = peekVoxel0px0py1pz() > 0 ? 1: 0;
|
uint8_t voxel1pz = peekVoxel0px0py1pz() > 0 ? 1: 0;
|
||||||
|
|
||||||
return Vector3(int(voxel1px) - int(voxel1nx),int(voxel1py) - int(voxel1ny),int(voxel1pz) - int(voxel1nz));
|
return Vector3DFloat(int(voxel1px) - int(voxel1nx),int(voxel1py) - int(voxel1ny),int(voxel1pz) - int(voxel1nz));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 VolumeIterator::getAveragedCentralDifferenceGradient(void) const
|
Vector3DFloat VolumeIterator::getAveragedCentralDifferenceGradient(void) const
|
||||||
{
|
{
|
||||||
//FIXME - should this test be here?
|
//FIXME - should this test be here?
|
||||||
if((mXPosInVolume < 2) || (mXPosInVolume > OGRE_VOLUME_SIDE_LENGTH-3) ||
|
if((mXPosInVolume < 2) || (mXPosInVolume > OGRE_VOLUME_SIDE_LENGTH-3) ||
|
||||||
@ -186,7 +184,7 @@ namespace Ogre
|
|||||||
(mZPosInVolume < 2) || (mZPosInVolume > OGRE_VOLUME_SIDE_LENGTH-3))
|
(mZPosInVolume < 2) || (mZPosInVolume > OGRE_VOLUME_SIDE_LENGTH-3))
|
||||||
{
|
{
|
||||||
//LogManager::getSingleton().logMessage("Out of range");
|
//LogManager::getSingleton().logMessage("Out of range");
|
||||||
return Vector3(0.0,0.0,0.0);
|
return Vector3DFloat(0.0,0.0,0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME - bitwise way of doing this?
|
//FIXME - bitwise way of doing this?
|
||||||
@ -199,10 +197,10 @@ namespace Ogre
|
|||||||
float voxel1nz = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume ,mZPosInVolume-1,2);
|
float voxel1nz = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume ,mZPosInVolume-1,2);
|
||||||
float voxel1pz = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume ,mZPosInVolume+1,2);
|
float voxel1pz = getAveragedVoxelAt(mXPosInVolume ,mYPosInVolume ,mZPosInVolume+1,2);
|
||||||
|
|
||||||
return Vector3(voxel1px - voxel1nx,voxel1py - voxel1ny,voxel1pz - voxel1nz);
|
return Vector3DFloat(voxel1px - voxel1nx,voxel1py - voxel1ny,voxel1pz - voxel1nz);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 VolumeIterator::getSobelGradient(void) const
|
Vector3DFloat VolumeIterator::getSobelGradient(void) const
|
||||||
{
|
{
|
||||||
//FIXME - should this test be here?
|
//FIXME - should this test be here?
|
||||||
if((mXPosInVolume < 1) || (mXPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2) ||
|
if((mXPosInVolume < 1) || (mXPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2) ||
|
||||||
@ -210,7 +208,7 @@ namespace Ogre
|
|||||||
(mZPosInVolume < 1) || (mZPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2))
|
(mZPosInVolume < 1) || (mZPosInVolume > OGRE_VOLUME_SIDE_LENGTH-2))
|
||||||
{
|
{
|
||||||
//LogManager::getSingleton().logMessage("Out of range");
|
//LogManager::getSingleton().logMessage("Out of range");
|
||||||
return Vector3(0.0,0.0,0.0);
|
return Vector3DFloat(0.0,0.0,0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
|
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
|
||||||
@ -290,7 +288,7 @@ namespace Ogre
|
|||||||
weights[0][2][2] * ( pVoxel1px1py1nz) + weights[2][2][2] *
|
weights[0][2][2] * ( pVoxel1px1py1nz) + weights[2][2][2] *
|
||||||
( pVoxel1px1py1pz));
|
( pVoxel1px1py1pz));
|
||||||
|
|
||||||
return Vector3(xGrad,yGrad,zGrad);
|
return Vector3DFloat(xGrad,yGrad,zGrad);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t VolumeIterator::getPosX(void)
|
uint16_t VolumeIterator::getPosX(void)
|
||||||
|
Reference in New Issue
Block a user