16#ifndef MESHFACTORY_H_6014714286
17#define MESHFACTORY_H_6014714286
26#include <unordered_set>
59template<
typename VertexType >
63 template<
typename VectorType >
108template<
typename VertexType >
109template<
typename VectorType >
113 vertex.x = position.x();
114 vertex.y = position.y();
115 vertex.z = position.z();
116 vertex.setNormal(
normal );
117 vertex.setColor ( color );
122template<
typename VertexType >
125 return createBox( size.x(), size.y(), size.z() );
129template<
typename VertexType >
148 typedef typename MeshInstance::Vertex Vertex;
149 typedef typename MeshInstance:: Index Index;
178 return MeshInstance::create
185template<
typename VertexType >
209 typedef typename MeshInstance::Vertex Vertex;
210 typedef typename MeshInstance:: Index Index;
254 return MeshInstance::create
261template<
typename VertexType >
265 typedef typename MeshInstance::Vertex Vertex;
266 typedef typename MeshInstance:: Index Index;
275template<
typename VertexType >
278 return createFromSTL( std::fstream(
path, std::ios::in | std::ios::binary) );
281template<
typename VertexType >
285 stlStream.exceptions(std::istream::failbit | std::istream::badbit | std::istream::eofbit);
296 typedef typename MeshInstance::Vertex Vertex;
297 typedef typename MeshInstance::Index Index;
301 std::unique_ptr<Index[]> indices (
new Index [
indicesCount]);
302 std::unique_ptr<Vertex[]> vertices(
new Vertex [
indicesCount]);
334 for (
unsigned int j = 0;
j < 3;
j++)
339 stlStream.read(
reinterpret_cast<char*
>(&x), 4);
340 stlStream.read(
reinterpret_cast<char*
>(&y), 4);
341 stlStream.read(
reinterpret_cast<char*
>(&z), 4);
364 return MeshInstance::create
371template<
typename VertexType >
377 typedef typename MeshInstance::Vertex Vertex;
378 typedef typename MeshInstance:: Index Index;
379 Vertex vertices[
points.size() ];
380 Index indices[
points.size() ];
394 return MeshInstance::create
397 , indices,
points.size() );
Defines LibCarna::base::IndexBuffer.
#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::ManagedMesh.
Defines LibCarna::base::VertexAttributes.
Defines LibCarna::base::VertexBuffer.
Defines LibCarna::base::PVertex, LibCarna::base::PNVertex, LibCarna::base::VertexPosition,...
Represents an association.
AssociatedObjectType * get() const
Returns raw pointer to the referenced object.
static const unsigned int PRIMITIVE_TYPE_TRIANGLES
Draws triangles. Indicates that the indices make up the th triangle with .
static const unsigned int PRIMITIVE_TYPE_POINTS
Draws points. Indicates that each index makes up a single point.
static const unsigned int PRIMITIVE_TYPE_LINE_STRIP
Draws lines. Indicates that the indices make up a the th line segment with .
Creates simple predefined ManagedMesh instances.
static ManagedMesh< VertexType, uint16_t > & createBall(float radius, unsigned int degree=3)
Creates sphere with radius and a vertices number determined by degree. The ball is centered in .
static ManagedMesh< VertexType, uint16_t > & createLineStrip(const std::vector< math::Vector3f > &points)
Creates a line strip.
static ManagedMesh< VertexType, uint8_t > & createPoint()
Creates mesh that consists of a single point.
static ManagedMesh< VertexType, uint8_t > & createBox(float width, float height, float depth)
Creates box with width, height and depth. The box is centered in .
static ManagedMesh< VertexType, uint32_t > & createFromSTL(const std::string &path)
Creates mesh from an STL file.
Defines LibCarna::base::math namespace and LIBCARNA_FOR_VECTOR3UI.
Eigen::Matrix< float, 3, 1 > Vector3f
Defines vector.
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > Matrix4f
Defines matrix.
Eigen::Matrix< float, 4, 1 > Vector4f
Defines vector.
Matrix4f scaling4f(float x, float y, float z)
Creates scaling matrix for homogeneous coordinates.
Matrix4f basis4f(const Vector4f &x, const Vector4f &y, const Vector4f &z, const Vector4f &t=Vector4f(0, 0, 0, 0))
Creates basis embedded into a homogenous coordinates matrix.