columbuspopla.blogg.se

Unity3d pro builder uneven normals
Unity3d pro builder uneven normals





  1. #UNITY3D PRO BUILDER UNEVEN NORMALS FULL#
  2. #UNITY3D PRO BUILDER UNEVEN NORMALS CODE#

Pure coinsidence that saved some calculatons. Vertices = new Vector3(Mathf.Sin(endRad) * innerRadius + xPosition, Mathf.Cos(endRad) * innerRadius + yPosition, 0) įor (int i = 1 i < vertices.Length - 1 i++) Vertices = new Vector3(Mathf.Sin(startRad) * outerRadius + xPosition, Mathf.Cos(startRad) * outerRadius + yPosition, 0) Let's save the vector at the beginning and the one on the end to make a perfectly straight line Vector3 vertices = new Vector3 įloat degreeStepSize = (endDegree - startDegree) * 2 / (points - 3) įloat halfRadStepSize = (degreeStepSize) * Mathf.Deg2Rad / 2f įloat startRad = Mathf.Deg2Rad * startDegree įloat endRad = Mathf.Deg2Rad * endDegree We always need an uneven number of points! Points = (int)(Mathf.Abs(endDegree - startDegree) / 360f * points)

#UNITY3D PRO BUILDER UNEVEN NORMALS FULL#

The points for the full circle shall be whatever is given but if its not the full circle we dont need all the points! These values will result in no (or very ugly in the case of points = outerRadius || innerRadius < 0 || outerRadius <= 0)

#UNITY3D PRO BUILDER UNEVEN NORMALS CODE#

Here is the code I use to generate a circle: public static void createCircle(MeshFilter meshFilter, float innerRadius, float outerRadius, Color color, float xPosition = 0, float yPosition = 0, float startDegree = 0, float endDegree = 360, int points = 100) So I am looking for tips on improvements, to make it slow only (because that's probably the best it will get.) Unfortunately though, this is really, really slow! Since I just recently started looking into meshes, how they work, what they do and so on, I decided to use my own calculations to create a mesh of a circle.







Unity3d pro builder uneven normals