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;
141 for(
unsigned int i = 0; i <
silhouettes().size(); ++i)
143 int previousSilhouetteSize = (i == 0) ? 0 :
silhouettes().at(i - 1);
148 for(
size_t iseg=0; iseg<segments-1; ++iseg)
150 for(
int iquad=0; iquad<prof_count; ++iquad)
152 de->
indexBuffer()->
at((iquad)*4+iseg*4*prof_count + 3) = (iseg + 0) * (GLuint)
silhouette().size() + iquad + previousSilhouetteSize;
155 de->
indexBuffer()->
at((iquad)*4+iseg*4*prof_count + 0) = (iseg + 1) * (GLuint)
silhouette().size() + iquad + previousSilhouetteSize;
162 size_t tess_bottom_count = 0;
163 size_t tess_top_count = 0;
167 size_t start = verts.size();
183 size_t start = verts.size();
187 for(
unsigned i=0; i <
silhouette().size(); ++i)
188 tessellator.
contourVerts().push_back((
dvec3)verts[verts.size()-i-1-tess_bottom_count]);
199 if(compatibilityProfile)
208 if(compatibilityProfile)
214 for(
size_t iseg=0; iseg<segments; ++iseg)
216 for(
unsigned j=0; j<
silhouette().size(); ++j, ++offs)
221 for(
unsigned j=0; j<tess_bottom_count; ++j, ++offs)
226 for(
unsigned j=0; j<tess_top_count; ++j, ++offs)
const std::vector< fvec3 > & tessellatedTris() const
A set of triangles representing the tessellated polygon.
const std::vector< vl::fvec3 > & positionPath() const
The path along which the silhouette is extruded.
const std::vector< float > & scalingPath() const
The scaling to be applied along the extrusion.
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.
bool fillBottom() const
Whether a set of triangles should be generated to fill the beginning of the extrusion (default is tru...
bool smooth() const
If true the normals of the geometry are smoothed.
const ArrayAbstract * vertexArray() const
Conventional vertex array.
const std::vector< vl::fvec4 > & colorPath() const
The color to be applied to the extrusion.
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< dvec3 > & contourVerts() const
The contours that specify the complex polygon to be tessellated.
const std::vector< vl::fvec2 > & silhouette() const
Returns the silhouette to be extruded.
void initFrom(const std::vector< T_VectorType > &vector)
vl::ref< vl::Geometry > extrude(bool compatibilityProfile=true)
Performs the actual extrusion.
ESilhouetteMode silhouetteMode() const
Wether the silhouette is considered closed, i.e. a line-loop, or open.
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.
arr_type * indexBuffer()
The BufferObject containing the indices used to render.
const std::vector< unsigned int > & silhouettes() const
Return the number of points in each silhouette.
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.
void setWindingRule(ETessellationWinding rule)
See gluTessProperty documentation (GLU_TESS_WINDING_RULE)
The ref<> class is used to reference-count an Object.
bool fillTop() const
Whether a set of triangles should be generated to fill the ending of the extrusion (default is true)...
Wraps the OpenGL function glDrawArrays().
const std::vector< float > & rotationPath() const
The rotation to be applied along the extrusion.
bool tessellate(bool append_tessellated_tris=false)
Collection< DrawCall > & drawCalls()
Returns the list of DrawCall objects bound to a Geometry.
void setVertexAttribArray(int attrib_location, const ArrayAbstract *info)
Binds a generic vertex attribute.