15#ifndef BUFFEREDNORMALMAP3D_H_6014714286
16#define BUFFEREDNORMALMAP3D_H_6014714286
61template<
typename BufferedVectorComponentType,
typename BufferType >
66 ( std::is_integral< BufferedVectorComponentType >::value
67 ,
"Only integral buffer vector component types allowed." );
114 const float range =
static_cast< float >(
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::max() )
115 -
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() ) );
117 const float fraction = ( x -
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() ) ) /
range;
136 const signed long range =
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::max() )
137 -
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() );
139 +
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() );
148 return ( *
this )( location.x(), location.y(), location.z() );
156 ,
unsigned int z )
const
159 const std::size_t index = 4 * ( x +
size.x() * y +
size.y() *
size.x() * z );
171 this->
setVoxel( location.x(), location.y(), location.z(),
normal );
179 const std::size_t index = 4 * ( x +
size.x() * y +
size.y() *
size.x() * z );
206 const std::unique_ptr< Association< BufferType > >
myBuffer;
214 ,
"No volume data buffer supplied!" );
218 ,
"Supplied volume data buffer is of size "
220 <<
" bytes but must be at least "
Defines LibCarna::base::Composition.
Defines LibCarna::base::LibCarnaException and LibCarna::base::AssertionFailure.
#define LIBCARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
#define LIBCARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Defines LibCarna::base::NormalMap3D.
Represents an association.
AssociatedObjectType * get() const
Returns raw pointer to the referenced object.
Implements NormalMap3D generically for a particular VoxelType.
void setVoxel(const math::Vector3ui &location, const math::Vector3f &normal)
Encodes normal and stores it at location.
BufferType Buffer
Holds the used buffer type.
static BufferedVectorComponentType encodeComponent(float actualVectorComponent)
Returns the buffered vector component corresponding to actualVectorComponent.
static float decodeComponent(BufferedVectorComponentType encodedVectorComponent)
Returns the actual normal vector component corresponding to encodedVectorComponent.
void setVoxel(unsigned int x, unsigned int y, unsigned int z, const math::Vector3f &normal)
math::Vector3f operator()(const math::Vector3ui &location) const
Decodes and tells the vector stored at location.
const BufferType & buffer() const
References the underlying buffer.
const std::unique_ptr< Association< BufferType > > myBuffer
Holds the buffer.
BufferedNormalMap3D(const math::Vector3ui &size)
BufferedVectorComponentType BufferedVectorComponent
Holds the type used to store the components of the normal vectors.
BufferType & buffer()
References the underlying buffer.
BufferedNormalMap3D(const math::Vector3ui &size, Association< BufferType > *buffer)
Instantiates.
Represents a composition, i.e. a strong reference. This basically is a std::unique_ptr that supports ...
Defines interface to mapping.
math::Vector3ui size
Holds the resolution.
Eigen::Matrix< float, 3, 1 > Vector3f
Defines vector.
Eigen::Matrix< unsigned int, 3, 1 > Vector3ui
Defines vector.
Defines LibCarna::base::text.