Ejemplo n.º 1
0
        //
        //
        //
        public static Mesh BuildArcSphere(Axis axis, float arcMinDeg, float arcMaxDeg, float radius, int sides)
        {
            Mesh mesh = BuildUnitArcSphere(axis, arcMinDeg, arcMaxDeg, sides);

            MeshAdapter.ScaleVertices(ref mesh, radius);
            return(mesh);
        }
Ejemplo n.º 2
0
        //
        //
        //
        public static Mesh BuildHemisphere(Axis axis, AxisSide axisSide, float radius, int sides)
        {
            if (radius > 0.02f)
            {
                // Works great up to radius = 0.02, under this limit normal issues appear

                MeshBuilder builder = new MeshBuilder();

                PointList points = CreatePolygon(axis, radius, sides);

                int n = sides / 4;

                PointList[] pointsM = new PointList[n + 1];
                pointsM [0] = points;

                Vector3 v = Vector(axis);

                float indexToRadAngle = Mathf.PI * 0.5f / n;

                if (axisSide == AxisSide.Positive)
                {
                    // First Hemisphere
                    for (int i = 1; i <= n; i++)
                    {
                        float angle = i * indexToRadAngle;
                        pointsM [i] = points.Scale(Mathf.Cos(angle)).Translate(radius * Mathf.Sin(angle) * v);
                        builder.Cap(pointsM [i - 1].Bridge(pointsM [i], PointList.BridgeMode.CloseReuse));
                    }
                }
                else
                {
                    // Second Hemisphere
                    for (int i = 1; i <= n; i++)
                    {
                        float angle = -i * indexToRadAngle;
                        pointsM [i] = points.Scale(Mathf.Cos(angle)).Translate(radius * Mathf.Sin(angle) * v);
                        builder.Cap(pointsM [i].Bridge(pointsM [i - 1], PointList.BridgeMode.CloseReuse));
                    }
                }

                return(builder.Build());
            }
            else
            {
                Mesh mesh = BuildHemisphere(axis, axisSide, 1.0f, sides);
                MeshAdapter.ScaleVertices(ref mesh, new Vector3(radius, radius, radius));
                return(mesh);
            }
        }