1 #ifndef BLUB_PROCEDURAL_VOXEL_EDIT_SPHERE_HPP
2 #define BLUB_PROCEDURAL_VOXEL_EDIT_SPHERE_HPP
6 #include "blub/math/axisAlignedBox.hpp"
7 #include "blub/math/math.hpp"
8 #include "blub/math/sphere.hpp"
9 #include "blub/math/transform.hpp"
10 #include "blub/procedural/voxel/edit/base.hpp"
26 template <
class configType>
27 class sphere :
public base<configType>
31 typedef base<t_config> t_base;
32 typedef sharedPointer<sphere<t_config> > pointer;
40 static pointer
create(const ::blub::sphere& desc)
42 return pointer(
new sphere(desc));
72 aabb.
getMaximum()*trans.scale + trans.position);
85 const blub::real &radius(m_sphere.
getRadius());
86 if (squaredDist < (radius+1.)*(radius+1.))
88 if (squaredDist < (radius-1.)*(radius-1.))
94 const blub::real &result(blub::math::clamp<blub::real>((radius-blub::math::sqrt(squaredDist))*127., -127., 127.));
102 sphere(const ::blub::sphere& desc)
119 #endif // VOXEL_EDIT_SPHERE_HPP
real getRadius(void) const
Definition: sphere.hpp:23
Definition: customVertexInformation.cpp:193
void setInterpolationMax()
setInterpolationMax set interpolation to maximum.
Definition: data.hpp:129
bool calculateOneVoxel(const vector3 &pos, t_voxel *resultVoxel) const override
calculateOneVoxel calculates on voxel in getAxisAlignedBoundingBox().
Definition: sphere.hpp:82
const vector3 & getCenter(void) const
Definition: sphere.hpp:29
real squaredDistance(const vector3 &rhs) const
Definition: vector3.hpp:384
void setSphere(const ::blub::sphere &desc)
setSphere sets the describing sphere. Dont set it while caluculating voxel.
Definition: sphere.hpp:49
blub::axisAlignedBox getAxisAlignedBoundingBox(const blub::transform &trans) const override
getAxisAlignedBoundingBox returns the transformed aab that includes the sphere.
Definition: sphere.hpp:67
The sphere class creates an interpolated voxel-sphere.
Definition: predecl.hpp:79
static pointer create(const ::blub::sphere &desc)
creates an instance
Definition: sphere.hpp:40
void setInterpolation(const int8 &toSet)
setInterpolation sets interpolation
Definition: data.hpp:61
Definition: vector3.hpp:26
const ::blub::sphere & getSphere() const
getSphere
Definition: sphere.hpp:57
Definition: axisAlignedBox.hpp:20
The data class is the default voxel. Contains an 8-bit interpolation value. Replace/derive it and set...
Definition: data.hpp:27
const vector3 & getMinimum(void) const
Definition: axisAlignedBox.hpp:126
const vector3 & getMaximum(void) const
Definition: axisAlignedBox.hpp:141
Definition: deadlineTimer.hpp:10
Definition: customVertexInformation.cpp:177
Definition: sphere.hpp:10