Procedural Mesh in Unity: Render a Cone

Procedural Mesh in Unity: Render a Cone

Building a Cone in Unity 3d  - c#

I’ve been thinking about implementing some sort of primitive form, cube, cylinder, capsule, etc. and look like a ship without much effort. The capsule could fit in, but does not convince me too, and the problem is that unity has no more forms.
Then I will build a cone.

 

Motivation: this drawback, motivated me to create my own primitive ship, a cone.

 

Method:

does not exist, in computer graphics, the completely circular and soft as real-world ways, because in the world of rasterization the pixels are square. What we can do is an approximation of the desired,

First I will divide the primitive form of the cone into two parts in order to work more comfortable,

 

Part1:  circular base, the genre radially interpolating vertices. The indices of the triangles are generated by 0-1-2 according to image and each triangle shares two vertices in common.

 

cinfo1

Part2:  generating the cone body, I use the vertices of the circular base and I link with the vertex of the peak, (which is equal to the center vertex displaced only in one axis). I also follow the order shown in the image.

cinfo2

 

UV Map: no yet.

 

Result:

is a great cone, very smooth, soooo smooooth! , the base maybe should be fixed. The solution is generate the triangle mesh with individual vertex (non share vertex). Anyway is fine to me.

 

Download:

Package contain both cones (smooth cone and sharp edged cone).

 

 

 

Note: te code isn’t optimal, if anyone would like improve it, welcome it!

Martin.