# extrusion

This topic is 2165 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hello.
I have some 2d shapes that I would like to extrude for a depth, and the result  must be a  3d solid.
The 2d shape is a bidimensional set of 2d vertexes.
How i can  create the 3d vertexes , the triangles and indexes of the triangles ?

Thanks.

##### Share on other sites

You want to extrude all the vertices along a vector. You may as well index the 2N vertices with 0...N-1 the unextruded vertices, and N...2N-1 the extruded ones. Then vertex K will extrude along the vector to meet vertex K + N.

It sounds like you just have a 2D array of vertices though... presumably they form some sort of shape? Need more details about that because you need to:

Triangulate the vertices (before you extrude them).

Identify vertices which will form the "skirt" of the extrusion (i.e. the new faces created along the perimeter). These will be edges of the triangles which are unique to a triangle (interior edges are shared by 2 triangles - draw a diagram to verify this for yourself), and create quads out of these.

EDIT: The triangulation of the extruded face will be the same as the non-extruded face but you will have to flip 2 vertices afterwards (i.e. change the polygon winding order from clockwise to anticlockwise or vice versa) if you want the top and bottom faces to point in opposite directions, which is normally the case (usually the stationary face is flipped so it points the opposite direction).

##### Share on other sites

thanks.

It sounds like you just have a 2D array of vertices though... presumably they form some sort of shape?

yes I have an array of 2d points that form a sort of shape: rectangle, circle and generic closed 2d shape without openings

But i'm not understand all what you mean with Triangulate the vertices.
I would to create empty meshes with only external edge, i think to a series of quad (created by 4 vertices)created by two triangles , or ,better a triangle strip if is possible.

by.

##### Share on other sites

I mean triangulate the vertices of the extruding face (sounds like you already have this though). The skirt part is easy (just join vertex k to vertex k + n). Once you know which vertices are on the edge of the extruded shape (they are not an edge for other any other triangle in the shape), you can walk the edges (each edge connects to 2 other edges on the boundary, so they form a closed loop) and build a quad strip/triangle strip with the vertices in the edge and the opposite vertices.

Drawing a diagram and numbering the vertices should help you to visualise what you need to do.

thanks.

##### Share on other sites

You may also use tesselation hardware to extrude a 2d shape, along a line or even a spline. The mesh is defined by lines forming the shape edges.

The vertex shader is practically a pass through. The hull shader is set to work on quads and you may use what ever function to define the tesselation of the extrusion. You'll probably only need to tesselate along the extrusion.

The domain shader is where you'll do the required transforms to get the final position of the vertex. As the domain shader gets the uv coordinates on the quad patch, you'll be able to calculate the interpolated position. You may calculate the position using catmull rom splines if required, or just interpolate 2 matrices defining the starting and ending position of the extrusion.

The advantage on using the tesselation hardware is that only static mesh is the shape and that you don't need to create any geometry on the CPU. You may manipulate the extrusion just by defining a set of world matrices.

Of course, this method requires a separate drawing call for the extrusion caps.

Best regards!

##### Share on other sites

thanks Crossbones, but now , for me your solution is too complex.
I must study more , i don't know very well the tessellation and the hull shader.

by.

• 21
• 11
• 9
• 17
• 13