42 Log::error(
"Extrusion::extrude(): no silhouette defined.\n");
47 Log::error(
"Extrusion::extrude() needs at least a non empty positionPath().\n");
52 Log::error(
"Extrusion::extrude(): scalingPath() must have the same number of control points as positionPath().\n");
57 Log::error(
"Extrusion::extrude(): rotationPath() must have the same number of control points as positionPath().\n");
62 Log::error(
"Extrusion::extrude(): colorPath() must have the same number of control points as positionPath().\n");
70 std::vector<fvec3> verts;
71 verts.resize(
silhouette().size() * segments );
76 std::vector<vl::fvec3> projected_sil;
84 std::vector<fvec3> plane_normals;
86 for(
unsigned i=1; i<plane_normals.size()-1; ++i)
100 const fvec3& P = projected_sil[j];
102 const fvec3& N = plane_normals [i];
103 float d =
dot(N,orig);
104 float t =
dot(V,N) ? (d-
dot(P,N))/
dot(V,N) : 0 ;
106 verts.at(j+
silhouette().size()*(i-1)) = projected_sil[j] = P + V*t;
145 for(
int iseg=0; iseg<segments-1; ++iseg)
147 for(
int iquad=0; iquad<prof_count; ++iquad)
158 size_t tess_bottom_count = 0;
159 size_t tess_top_count = 0;
163 int start = int(verts.size());
167 tessellator.contourVerts().push_back((
dvec3)verts[i]);
169 tessellator.tessellate();
170 for(
unsigned i=0; i<tessellator.tessellatedTris().size(); ++i)
171 verts.push_back(tessellator.tessellatedTris()[i]);
172 if (tessellator.tessellatedTris().size())
174 tess_bottom_count = tessellator.tessellatedTris().size();
178 int start = int(verts.size());
182 tessellator.contourVerts().push_back((
dvec3)verts[verts.size()-i-1-tess_bottom_count]);
184 tessellator.tessellate();
185 for(
unsigned i=0; i<tessellator.tessellatedTris().size(); ++i)
186 verts.push_back(tessellator.tessellatedTris()[i]);
187 if (tessellator.tessellatedTris().size())
189 tess_top_count = tessellator.tessellatedTris().size();
202 for(
int iseg=0; iseg<segments; ++iseg)
204 for(
unsigned j=0; j<
silhouette().size(); ++j, ++offs)
209 for(
unsigned j=0; j<tess_bottom_count; ++j, ++offs)
214 for(
unsigned j=0; j<tess_top_count; ++j, ++offs)
Tessellates a complex polygon defined by a set of outlines into a set of triangles that can be render...
const Vector3 & normalize(T_Scalar *len=NULL)
Vector3< float > fvec3
A 3 components vector with float precision.
const std::vector< vl::fvec4 > & colorPath() const
The color to be applied to the extrusion.
ESilhouetteMode silhouetteMode() const
Wether the silhouette is considered closed, i.e. a line-loop, or open.
const ArrayAbstract * vertexArray() const
Conventional vertex array.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
void setVertexArray(ArrayAbstract *data)
Conventional vertex array.
void setColorArray(const fvec4 &color)
Fills the color array with the given color.
The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.
Visualization Library main namespace.
float dot(float a, float b)
const std::vector< float > & rotationPath() const
The rotation to be applied along the extrusion.
bool smooth() const
If true the normals of the geometry are smoothed.
vl::ref< vl::Geometry > extrude()
Performs the actual extrusion.
void initFrom(const std::vector< T_VectorType > &vector)
Implements the OpenGL Shading Language convenience functions for scalar and vector operations...
const std::vector< int > & contours() const
The contours that specify the complex polygon to be tessellated.
void convertDrawCallToDrawArrays()
Converts all the DrawCall objects bound to a Geometry into DrawArrays.
void computeNormals(bool verbose=false)
Computes the normals in a "smooth" way, i.e.
bool fillBottom() const
Whether a set of triangles should be generated to fill the beginning of the extrusion (default is tru...
arr_type * indexBuffer()
The BufferObject containing the indices used to render.
static Matrix4 & getRotation(Matrix4 &out, float degrees, float x, float y, float z)
T_VectorType & at(size_t i)
virtual size_t size() const =0
Returns the number of elements of an array.
bool fillTop() const
Whether a set of triangles should be generated to fill the ending of the extrusion (default is true)...
const std::vector< vl::fvec2 > & silhouette() const
Returns the silhouette to be extruded.
const std::vector< vl::fvec3 > & positionPath() const
The path along which the silhouette is extruded.
The ref<> class is used to reference-count an Object.
const std::vector< float > & scalingPath() const
The scaling to be applied along the extrusion.
Wraps the OpenGL function glDrawArrays().
Collection< DrawCall > & drawCalls()
Returns the list of DrawCall objects bound to a Geometry.