dynamically extruding mesh

I need to extrude a plane a straight line between 2 known points, but the points are subject to change and the boundary of the plane needs to be bounded to these points where ever they might end up.

the extruding plane should only consist of 4 vertices forming a rectangle plane that can stretch out.

Where might I find literature on dynamic extrusion, I know its possible in unity but I cant find much about it.

Well, that's all just some simple math. Actually you want to create a procedural mesh that contains 4 vertices and 2 triangles that form your rectangle.

You need of course some more input parameters besides your two points. The direction you want to "extrude" your plane and the length. Oh and if it's important in which direction your plane should face you need that information as well. Maybe you want a two-sided plane? Then you need either a shader that doesn't cull the backfaces or setup the plane with 4 triangles (two for each side).

You don't need to recreate the mesh all the time, create it at start and just modify the vertices,

No language specified so i created the example in C#. Here's a unitypackage with two ways of doing what you want. I would recommend the second way, because it's the more versatile version and it doesn't require to change the actual mesh data.

The first way have another little disadvantage. The object with the mesh should not be moved or rotated because the vertices are placed in local space. As long as you don't move the GameObject its local space will match the world space. Well, you could fix tat problem by transforming the point coordinates into the local space but that's even more complicated :D

PlaneExtrude.unitypackage

edit placed the unitypackage in my public dropbox folder so downloading is simpler :wink:

You would modify a Mesh http://unity3d.com/support/documentation/ScriptReference/Mesh.html

The plane may use 4 vertices, but they will define 2 triangles, not one rectangle.

allo Bunny83,
i just downloaded and experimented with your planeExtrude examples by changing the float ExtrudeDir to Vector3.down, the end result has no change. i thought it should draw in the opposite direction.

please advise.

thanks.