12 #ifndef MESHFACTORY_H_6014714286
13 #define MESHFACTORY_H_6014714286
48 template<
typename VertexType >
52 template<
typename VectorType >
53 static VertexType vertex(
const VectorType& );
75 template<
typename VertexType >
76 template<
typename VectorType >
87 template<
typename VertexType >
90 return createBox( size.x(), size.y(), size.z() );
94 template<
typename VertexType >
109 const std::size_t verticesCount = 6 * 4;
110 const std::size_t indicesCount = 6 * 2 * 3;
113 typedef typename MeshInstance::Vertex Vertex;
114 typedef typename MeshInstance:: Index Index;
115 Vertex vertices[ verticesCount ];
116 Index indices[ indicesCount ];
123 for(
unsigned int faceIndex = 0; faceIndex < 6; ++faceIndex )
125 const math::Matrix4f transform = baseTransform * transforms[ faceIndex ];
126 vertices[ ++lastVertex ] = vertex( transform *
math::Vector4f( -1, -1, 1, 1 ) );
127 vertices[ ++lastVertex ] = vertex( transform *
math::Vector4f( +1, -1, 1, 1 ) );
128 vertices[ ++lastVertex ] = vertex( transform *
math::Vector4f( +1, +1, 1, 1 ) );
129 vertices[ ++lastVertex ] = vertex( transform *
math::Vector4f( -1, +1, 1, 1 ) );
131 indices[ ++lastIndex ] = lastVertex - 3;
132 indices[ ++lastIndex ] = lastVertex - 2;
133 indices[ ++lastIndex ] = lastVertex;
135 indices[ ++lastIndex ] = lastVertex;
136 indices[ ++lastIndex ] = lastVertex - 2;
137 indices[ ++lastIndex ] = lastVertex - 1;
140 return MeshInstance::create
142 , vertices, verticesCount
143 , indices, indicesCount );
147 template<
typename VertexType >
151 typedef typename MeshInstance::Vertex Vertex;
152 typedef typename MeshInstance:: Index Index;
166 #endif // MESHFACTORY_H_6014714286
Defines Carna::base::math namespace and CARNA_FOR_VECTOR3UI.
Matrix4f scaling4f(float x, float y, float z)
Creates scaling matrix for homogeneous coordinates.
static const unsigned int PRIMITIVE_TYPE_POINTS
Draws points. Indicates that each index makes up 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 .
Eigen::Matrix< float, 4, 1 > Vector4f
Defines vector.
Defines Carna::base::VertexAttributes.
static const unsigned int PRIMITIVE_TYPE_TRIANGLES
Draws triangles. Indicates that the indices make up the th triangle with .
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, 3, 1 > Vector3f
Defines vector.
Defines Carna::base::IndexBuffer.
Creates simple predefined ManagedMesh instances.
Defines Carna::base::ManagedMesh.
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > Matrix4f
Defines matrix.
Defines Carna::base::VertexBase.
Implements MeshBase class for particular VertexType and IndexType.
static ManagedMesh< VertexType, uint8_t > & createPoint()
Creates mesh that consists of a single point.
Defines Carna::base::VertexBuffer.