12#ifndef MESHFACTORY_H_6014714286
13#define MESHFACTORY_H_6014714286
22#include <unordered_set>
55template<
typename VertexType >
59 template<
typename VectorType >
104template<
typename VertexType >
105template<
typename VectorType >
109 vertex.x = position.x();
110 vertex.y = position.y();
111 vertex.z = position.z();
112 vertex.setNormal(
normal );
113 vertex.setColor ( color );
118template<
typename VertexType >
121 return createBox( size.x(), size.y(), size.z() );
125template<
typename VertexType >
144 typedef typename MeshInstance::Vertex Vertex;
145 typedef typename MeshInstance:: Index Index;
174 return MeshInstance::create
181template<
typename VertexType >
205 typedef typename MeshInstance::Vertex Vertex;
206 typedef typename MeshInstance:: Index Index;
250 return MeshInstance::create
257template<
typename VertexType >
261 typedef typename MeshInstance::Vertex Vertex;
262 typedef typename MeshInstance:: Index Index;
270template<
typename VertexType >
273 return createFromSTL( std::fstream(
path, std::ios::in | std::ios::binary) );
276template<
typename VertexType >
280 stlStream.exceptions(std::istream::failbit | std::istream::badbit | std::istream::eofbit);
291 typedef typename MeshInstance::Vertex Vertex;
292 typedef typename MeshInstance::Index Index;
296 std::unique_ptr<Index[]> indices (
new Index [
indicesCount]);
297 std::unique_ptr<Vertex[]> vertices(
new Vertex [
indicesCount]);
329 for (
unsigned int j = 0;
j < 3;
j++)
334 stlStream.read(
reinterpret_cast<char*
>(&x), 4);
335 stlStream.read(
reinterpret_cast<char*
>(&y), 4);
336 stlStream.read(
reinterpret_cast<char*
>(&z), 4);
359 return MeshInstance::create
#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::IndexBuffer.
Defines Carna::base::ManagedMesh.
Defines Carna::base::VertexAttributes.
Defines Carna::base::VertexBuffer.
Defines Carna::base::PVertex, Carna::base::PNVertex, Carna::base::VertexPosition, Carna::base::Vertex...
Represents an association.
AssociatedObjectType * get() const
Returns raw pointer to the referenced object.
static const unsigned int PRIMITIVE_TYPE_POINTS
Draws points. Indicates that each index makes up a single point.
static const unsigned int PRIMITIVE_TYPE_TRIANGLES
Draws triangles. Indicates that the indices make up the th triangle with .
Creates simple predefined ManagedMesh instances.
static ManagedMesh< VertexType, uint8_t > & createPoint()
Creates mesh that consists of a single point.
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, 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 Carna::base::math namespace and CARNA_FOR_VECTOR3UI.
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.
Eigen::Matrix< float, 4, 1 > Vector4f
Defines vector.
Eigen::Matrix< float, 3, 1 > Vector3f
Defines vector.
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > Matrix4f
Defines matrix.
Matrix4f scaling4f(float x, float y, float z)
Creates scaling matrix for homogeneous coordinates.