예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static Half Log10(Half x) =>
 (Half)M.Log10(x);
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static Half Log(Half x) =>
 (Half)M.Log(x);
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public static Half Log(Half x,
                        Half y) =>
 (Half)M.Log(x, y);
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static Half Floor(Half x) =>
 (Half)M.Floor(x);
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public static Half IEEERemainder(Half x,
                                  Half y) =>
 (Half)M.IEEERemainder(x, y);
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static Half Exp(Half x) =>
 (Half)M.Exp(x);
예제 #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static Half Cosh(Half x) =>
 (Half)M.Cosh(x);
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static Half Ceiling(Half x) =>
 (Half)M.Ceiling(x);
예제 #9
0
 private static float GetSquaredDistance(Biome biome, float temp, float rain)
 {
     return(MathF.Abs((biome.Temperature - temp) * (biome.Temperature - temp) + (biome.Downfall - rain) * (biome.Downfall - rain)));
 }
예제 #10
0
        private void GenerateDome(int horizontalLines, int verticalClip, int verticalLines, out Vertex[] verts, out int[] tris)
        {
            // This function was a pain to create. It produces a UV sphere.
            // The top and bottom of the sphere is made using a triangle fan.
            // The top triangle fan is created followed by the the rest of the
            // sphere until the verticalClip is reached. Lastly the bottom cap
            // is added.

            // Define our vertice and triangle arrays along with our radius,
            // triangle index (tc) and vertex index (i).
            verts = new Vertex[((horizontalLines - verticalClip - 1) * verticalLines) + 2];
            tris  = new int[((((horizontalLines - verticalClip - 1) * verticalLines) * 2)) * 3];
            float radius = 1f;
            int   tc     = 0;
            int   i      = 0;

            // Create our top triangle fan.
            for (int m = 0; m < verticalLines; m++)
            {
                tris[tc++] = 0;                             // Middle of fan.
                tris[tc++] = m + 1;                         // The next vertex.
                if (m != 0)
                {
                    tris[tc++] = m;                         // The current vertex.
                }
                else
                {
                    tris[tc++] = verticalLines;             // The final vertex.
                }
            }
            verts[i++] = new Vertex(Vector3.UnitY * radius, Sky);

            // We would like to know what the lowest vertex is so we can place
            // our final bottom vertex at the same y position.
            float lowestY = float.PositiveInfinity;

            for (int m = 1; m < horizontalLines - verticalClip; m++)
            {
                for (int n = 0; n < verticalLines; n++)
                {
                    // Create a X, Y and Z position from our m and n values.
                    float x = Mathf.Sin(Mathf.PI * m / horizontalLines) * Mathf.Cos(2 * Mathf.PI * n / verticalLines);
                    float z = Mathf.Sin(Mathf.PI * m / horizontalLines) * Mathf.Sin(2 * Mathf.PI * n / verticalLines);
                    float y = Mathf.Cos(Mathf.PI * m / horizontalLines);

                    // Update the lowest known Y for later.
                    if (y < lowestY)
                    {
                        lowestY = y;
                    }

                    // Don't place triangles down if we are on an edge.
                    if (m < horizontalLines - (verticalClip + 1) && m > 0)
                    {
                        // Standard triangles.
                        if (n < verticalLines - 1)
                        {
                            tris[tc++] = i;
                            tris[tc++] = i + 1;
                            tris[tc++] = i + 1 + verticalLines;

                            tris[tc++] = i;
                            tris[tc++] = i + 1 + verticalLines;
                            tris[tc++] = i + 0 + verticalLines;
                        }
                        else
                        {
                            // Triangles on the edges of each loop.
                            tris[tc++] = i;
                            tris[tc++] = i + 1 - verticalLines;
                            tris[tc++] = i + 1;

                            tris[tc++] = i;
                            tris[tc++] = i + 1;
                            tris[tc++] = i + 0 + verticalLines;
                        }
                    }

                    Vector3 color = new Vector3(255, 255, 0);

                    // Make the ground.
                    if (m == horizontalLines - (verticalClip + 1))
                    {
                        color = new Vector3(Ground.R, Ground.G, Ground.B);
                    }
                    // Make the sky by interperlating between the sky and horizon.
                    else
                    {
                        float t = Mathf.Pow(1 - y, 3);
                        if (t > 1)
                        {
                            t = 1;
                        }
                        if (t < 0)
                        {
                            t = 0;
                        }
                        color = Vector3.Lerp(new Vector3(Sky.R, Sky.G, Sky.B), new Vector3(Horizon.R, Horizon.G, Horizon.B), t);
                    }

                    // Lastly, create our shiny new vertex and do it all over again.
                    verts[i++] = new Vertex(new Vector3(x, y, z) * radius, color / 255);
                }
            }

            // Finally, create our bottom triangle fan (floor).
            for (int m = 0; m < verticalLines; m++)
            {
                tris[tc] = i;
                tc++;
                tris[tc++] = (i - verticalLines) + m;

                if (m == verticalLines - 1)
                {
                    tris[tc++] = i - verticalLines;
                }
                else
                {
                    tris[tc++] = (i - verticalLines) + m + 1;
                }
            }
            verts[i++] = new Vertex(Vector3.UnitY * radius * lowestY, Ground);
        }