예제 #1
0
파일: MapaST.cs 프로젝트: Daraciel/WorldGen
        /*Planet*/
        private double MakePoint(Tetraedro T1, Point3D P, int D)
        {
            if (D > 0)
            {
                if (D == 11)
                {
                    T.AHeight = T1.AHeight;
                    T.BHeight = T1.BHeight;
                    T.CHeight = T1.CHeight;
                    T.DHeight = T1.DHeight;

                    T.ASeed = T1.ASeed;
                    T.BSeed = T1.BSeed;
                    T.CSeed = T1.CSeed;
                    T.DSeed = T1.DSeed;

                    T.A.X = T1.A.X; T.A.Y = T1.A.Y; T.A.Z = T1.A.Z;
                    T.B.X = T1.B.X; T.B.Y = T1.B.Y; T.B.Z = T1.B.Z;
                    T.C.X = T1.C.X; T.C.Y = T1.C.Y; T.C.Z = T1.C.Z;
                    T.D.X = T1.D.X; T.D.Y = T1.D.Y; T.D.Z = T1.D.Z;
                }
                T1.Reordenar();
                T1.Cortar(P, ref rnd);
                return(MakePoint(T1, P, --D));
            }
            else
            {
            }
            double blaa = ((T1.AHeight + T1.BHeight + T1.CHeight + T1.DHeight) / 4.0);

            return(blaa);
        }
예제 #2
0
파일: MapaST.cs 프로젝트: Daraciel/WorldGen
        //private MassLabelling etiquetadora;


        /// <summary>
        /// Constructor de la clase mapa
        /// </summary>
        /// <param name="W">Valor entero que representa la anchura del mapa</param>
        /// <param name="H">Valor entero que representa la altura del mapa</param>
        /// <param name="S">Valor decimal que representa la semilla del mapa</param>
        public MapaST(int W, int H, string S)
        {
            T          = new Tetraedro();
            _Width     = W;
            _Height    = H;
            Semilla    = S;
            _WaterLine = -0.02;
            setSeedFromString();
            Inicializar();
        }
예제 #3
0
파일: MapaST.cs 프로젝트: Daraciel/WorldGen
        //////////////////////////////////////////////////////
        //              FUNCIONES NECESARIAS                //
        //////////////////////////////////////////////////////

        /*Planet1*/
        /// <summary>
        /// Función para calcular la altura de un punto P
        /// </summary>
        /// <param name="P">Punto cartesiano</param>
        /// <returns>double que representa la aaltura del punto en el mapa</returns>
        private double MakeHeight(Point3D P)
        {
            double abx, aby, abz, acx, acy, acz, adx, ady, adz, apx, apy, apz;
            double bax, bay, baz, bcx, bcy, bcz, bdx, bdy, bdz, bpx, bpy, bpz;

            Tetraedro tetra = new Tetraedro();

            abx = T.B.X - T.A.X; aby = T.B.Y - T.A.Y; abz = T.B.Z - T.A.Z;
            acx = T.C.X - T.A.X; acy = T.C.Y - T.A.Y; acz = T.C.Z - T.A.Z;
            adx = T.D.X - T.A.X; ady = T.D.Y - T.A.Y; adz = T.D.Z - T.A.Z;
            apx = P.X - T.A.X; apy = P.Y - T.A.Y; apz = P.Z - T.A.Z;
            if ((adx * aby * acz + ady * abz * acx + adz * abx * acy
                 - adz * aby * acx - ady * abx * acz - adx * abz * acy) *
                (apx * aby * acz + apy * abz * acx + apz * abx * acy
                 - apz * aby * acx - apy * abx * acz - apx * abz * acy) > 0.0)
            {
                /* p está en el mismo lado de abc que d */
                if ((acx * aby * adz + acy * abz * adx + acz * abx * ady
                     - acz * aby * adx - acy * abx * adz - acx * abz * ady) *
                    (apx * aby * adz + apy * abz * adx + apz * abx * ady
                     - apz * aby * adx - apy * abx * adz - apx * abz * ady) > 0.0)
                {
                    /* p está en el mismo lado de abd que c */
                    if ((abx * ady * acz + aby * adz * acx + abz * adx * acy
                         - abz * ady * acx - aby * adx * acz - abx * adz * acy) *
                        (apx * ady * acz + apy * adz * acx + apz * adx * acy
                         - apz * ady * acx - apy * adx * acz - apx * adz * acy) > 0.0)
                    {
                        /* p está en el mismo lado de acd que b */
                        bax = -abx; bay = -aby; baz = -abz;

                        bcx = T.C.X - T.B.X; bcy = T.C.Y - T.B.Y; bcz = T.C.Z - T.B.Z;
                        bdx = T.D.X - T.B.X; bdy = T.D.Y - T.B.Y; bdz = T.D.Z - T.B.Z;
                        bpx = P.X - T.B.X; bpy = P.Y - T.B.Y; bpz = P.Z - T.B.Z;


                        if ((bax * bcy * bdz + bay * bcz * bdx + baz * bcx * bdy
                             - baz * bcy * bdx - bay * bcx * bdz - bax * bcz * bdy) *
                            (bpx * bcy * bdz + bpy * bcz * bdx + bpz * bcx * bdy
                             - bpz * bcy * bdx - bpy * bcx * bdz - bpx * bcz * bdy) > 0.0)
                        {
                            /* p está en el mismo lado de bcd que a */
                            /* Por lo que p está dentro del tetraedro */

                            tetra.A = new DPoint3D(T.A.X, T.A.Y, T.A.Z);
                            tetra.B = new DPoint3D(T.B.X, T.B.Y, T.B.Z);
                            tetra.C = new DPoint3D(T.C.X, T.C.Y, T.C.Z);
                            tetra.D = new DPoint3D(T.D.X, T.D.Y, T.D.Z);

                            tetra.AHeight = T.AHeight;
                            tetra.BHeight = T.BHeight;
                            tetra.CHeight = T.CHeight;
                            tetra.DHeight = T.DHeight;

                            tetra.ASeed = T.ASeed;
                            tetra.BSeed = T.BSeed;
                            tetra.CSeed = T.CSeed;
                            tetra.DSeed = T.DSeed;

                            return(MakePoint(tetra, P, 11));
                        }
                    }
                }
            } /* otherwise */

            tetra.A = new DPoint3D((-Math.Sqrt(3.0) - 0.20), (-Math.Sqrt(3.0) - 0.22), (-Math.Sqrt(3.0) - 0.23));
            tetra.B = new DPoint3D((-Math.Sqrt(3.0) - 0.19), (Math.Sqrt(3.0) + 0.18), (Math.Sqrt(3.0) + 0.17));
            tetra.C = new DPoint3D((Math.Sqrt(3.0) + 0.21), (-Math.Sqrt(3.0) - 0.24), (Math.Sqrt(3.0) + 0.15));
            tetra.D = new DPoint3D((Math.Sqrt(3.0) + 0.24), (Math.Sqrt(3.0) + 0.22), (-Math.Sqrt(3.0) - 0.25));

            tetra.AHeight = _WaterLine;
            tetra.BHeight = _WaterLine;
            tetra.CHeight = _WaterLine;
            tetra.DHeight = _WaterLine;

            tetra.ASeed = r1;
            tetra.BSeed = r2;
            tetra.CSeed = r3;
            tetra.DSeed = r4;

            return(MakePoint(tetra, P, Depth));
        }