- Home /
How do i Achieve mesh Extrusion?
Hello i'm having a lot of trouble with mesh extrusion, iv'e gone to the mesh API and the procedural geometry tutorial with Joachim Holmér, but i still do not understand it so if any of you guys know any good e-books or tutorials on achieving Extrusion please tell me.
Answer by tanoshimi · Jul 13, 2016 at 06:26 AM
Have you tried studying the source code of https://www.assetstore.unity3d.com/en/#!/content/5141 ?
Yes i have had a look at that but i don't understand it, i'm looking for tutorials so i can understand it.
Answer by nostroma · Nov 11, 2016 at 12:39 PM
Here you have a simple example, this code is added to a Unity plane primitive mesh:
srcMesh = (GetComponent < MeshFilter> ()).sharedMesh;
precomEdges = MeshExtrusion.BuildManifoldEdges (srcMesh);
Matrix4x4[] sections = new Matrix4x4[3];
sections[0]=transform.worldToLocalMatrix* Matrix4x4.TRS(transform.position,Quaternion.identity,Vector3.one);
sections[1]=transform.worldToLocalMatrix*Matrix4x4.TRS (transform.position+4f*Vector3.up, Quaternion.identity, Vector3.one);
sections[2]=transform.worldToLocalMatrix*Matrix4x4.TRS (transform.position+6f*Vector3.up, Quaternion.identity, Vector3.one);
MeshExtrusion.ExtrudeMesh (srcMesh, (GetComponent < MeshFilter> ()).mesh, sections, precomEdges, false);
This code simply elevates the plane (creates a box), with two sections. You have use the transformation matrix (Matrix4x4) to tell the script where your sections end, so first you get a transformation matrix to convert your world position to local coordinates (transform.worldToLocalMatrix), then you apply (by multiplying) another transformation to tell where you want to end up from your local point of view (Matrix4x4.TRS (transform.position+4f*Vector3.up, Quaternion.identity, Vector3.one)).
Your answer
Follow this Question
Related Questions
How do i Extrude a 2D mesh(or Model) from one point to another? 1 Answer
Hello i am having some trouble converting a JS to a C# script. 1 Answer
How do i Add more vertices and triangles when i extend my model 1 Answer
Getting errors with extrusion script. 0 Answers
How do i access the MeshExtrusion.cs from Unity's PE? 1 Answer