12#ifndef BUFFEREDNORMALMAP3D_H_6014714286
13#define BUFFEREDNORMALMAP3D_H_6014714286
58template<
typename BufferedVectorComponentType,
typename BufferType >
63 ( std::is_integral< BufferedVectorComponentType >::value
64 ,
"Only integral buffer vector component types allowed." );
111 const float range =
static_cast< float >(
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::max() )
112 -
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() ) );
114 const float fraction = ( x -
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() ) ) /
range;
133 const signed long range =
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::max() )
134 -
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() );
136 +
static_cast< signed long >( std::numeric_limits< BufferedVectorComponentType >::min() );
145 return ( *
this )( location.x(), location.y(), location.z() );
153 ,
unsigned int z )
const
156 const std::size_t index = 4 * ( x +
size.x() * y +
size.y() *
size.x() * z );
168 this->
setVoxel( location.x(), location.y(), location.z(),
normal );
176 const std::size_t index = 4 * ( x +
size.x() * y +
size.y() *
size.x() * z );
203 const std::unique_ptr< Association< BufferType > >
myBuffer;
211 ,
"No volume data buffer supplied!" );
215 ,
"Supplied volume data buffer is of size "
217 <<
" bytes but must be at least "
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
#define CARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Defines Carna::base::Composition.
Defines Carna::base::NormalMap3D.
Represents an association.
AssociatedObjectType * get() const
Returns raw pointer to the referenced object.
Implements NormalMap3D generically for a particular VoxelType.
static float decodeComponent(BufferedVectorComponentType encodedVectorComponent)
Returns the actual normal vector component corresponding to encodedVectorComponent.
static BufferedVectorComponentType encodeComponent(float actualVectorComponent)
Returns the buffered vector component corresponding to actualVectorComponent.
BufferedVectorComponentType BufferedVectorComponent
Holds the type used to store the components of the normal vectors.
BufferType & buffer()
References the underlying buffer.
const BufferType & buffer() const
References the underlying buffer.
const std::unique_ptr< Association< BufferType > > myBuffer
Holds the buffer.
void setVoxel(const math::Vector3ui &location, const math::Vector3f &normal)
Encodes normal and stores it at location.
math::Vector3f operator()(const math::Vector3ui &location) const
Decodes and tells the vector stored at location.
BufferedNormalMap3D(const math::Vector3ui &size)
void setVoxel(unsigned int x, unsigned int y, unsigned int z, const math::Vector3f &normal)
BufferedNormalMap3D(const math::Vector3ui &size, Association< BufferType > *buffer)
Instantiates.
BufferType Buffer
Holds the used buffer type.
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 Carna::base::text.