polyvox/source/SurfaceVertex.cpp
David Williams e180f67bae Started getting rid of IntegrealVector3.
Also added ForwardDeclarations.h
2008-02-10 21:58:35 +00:00

93 lines
2.1 KiB
C++

#include <sstream>
#include "Constants.h"
#include "SurfaceVertex.h"
#include "SurfaceTriangle.h"
#include "SurfaceEdge.h"
namespace PolyVox
{
SurfaceVertex::SurfaceVertex()
{
}
SurfaceVertex::SurfaceVertex(Vector3DUint32 positionToSet, float materialToSet, float alphaToSet)
:material(materialToSet)
,alpha(alphaToSet)
,position(positionToSet)
,m_uHash((position.x()*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y()*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z()))
{
}
SurfaceVertex::SurfaceVertex(Vector3DUint32 positionToSet, Vector3DFloat normalToSet)
:position(positionToSet)
,normal(normalToSet)
{
m_uHash = (position.x()*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y()*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z());
}
float SurfaceVertex::getAlpha(void) const
{
return alpha;
}
float SurfaceVertex::getMaterial(void) const
{
return material;
}
const SurfaceEdgeIterator& SurfaceVertex::getEdge(void) const
{
return edge;
}
const Vector3DFloat& SurfaceVertex::getNormal(void) const
{
return normal;
}
const Vector3DUint32& SurfaceVertex::getPosition(void) const
{
return position;
}
void SurfaceVertex::setAlpha(float alphaToSet)
{
alpha = alphaToSet;
}
void SurfaceVertex::setMaterial(float materialToSet)
{
material = materialToSet;
}
void SurfaceVertex::setEdge(const SurfaceEdgeIterator& edgeToSet)
{
edge = edgeToSet;
}
void SurfaceVertex::setNormal(const Vector3DFloat& normalToSet)
{
normal = normalToSet;
normal.normalise();
}
std::string SurfaceVertex::tostring(void) const
{
std::stringstream ss;
ss << "SurfaceVertex: Position = (" << position.x() << "," << position.y() << "," << position.z() << "), Normal = " << normal;
return ss.str();
}
bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs)
{
return (lhs.m_uHash == rhs.m_uHash);
}
bool operator < (const SurfaceVertex& lhs, const SurfaceVertex& rhs)
{
return (lhs.m_uHash < rhs.m_uHash);
}
}