Ejemplo n.º 1
0
    private void Generate1st()
    {
        GameObject go;
        Object     obj = SelectPrefab.SolidHex(colorList [0]);

        if (size1 > 0)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s11 [0], s11 [1], s11 [2]), Quaternion.identity) as GameObject;
            go.name = "1-1";
        }
        else
        {
            return;
        }
        if (size1 > 1)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s12 [0], s12 [1], s12 [2]), Quaternion.identity) as GameObject;
            go.name = "1-2";
        }
        else
        {
            return;
        }
        if (size1 > 2)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s13 [0], s13 [1], s13 [2]), Quaternion.identity) as GameObject;
            go.name = "1-3";
        }
        else
        {
            return;
        }
        if (size1 > 3)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s14 [0], s14 [1], s14 [2]), Quaternion.identity) as GameObject;
            go.name = "1-4";
        }
        else
        {
            return;
        }
        if (size1 > 4)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s15 [0], s15 [1], s15 [2]), Quaternion.identity) as GameObject;
            go.name = "1-5";
        }
        else
        {
            return;
        }
        if (size1 > 5)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s16 [0], s16 [1], s16 [2]), Quaternion.identity) as GameObject;
            go.name = "1-5";
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 2
0
    private void Generate5th()
    {
        GameObject go;
        Object     obj = SelectPrefab.SolidHex(colorList [4]);

        if (size5 > 0)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s51 [0], s51 [1], s51 [2]), Quaternion.identity) as GameObject;
            go.name = "5-1";
        }
        else
        {
            return;
        }
        if (size5 > 1)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s52 [0], s52 [1], s52 [2]), Quaternion.identity) as GameObject;
            go.name = "5-2";
        }
        else
        {
            return;
        }
        if (size5 > 2)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s53 [0], s53 [1], s53 [2]), Quaternion.identity) as GameObject;
            go.name = "5-3";
        }
        else
        {
            return;
        }
        if (size5 > 3)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s54 [0], s54 [1], s54 [2]), Quaternion.identity) as GameObject;
            go.name = "5-4";
        }
        else
        {
            return;
        }
        if (size5 > 4)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s55 [0], s55 [1], s55 [2]), Quaternion.identity) as GameObject;
            go.name = "5-5";
        }
        else
        {
            return;
        }
        if (size5 > 5)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s56 [0], s56 [1], s56 [2]), Quaternion.identity) as GameObject;
            go.name = "5-6";
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 3
0
    private void Generate6th()
    {
        GameObject go;
        Object     obj = SelectPrefab.SolidHex(colorList [5]);

        if (size6 > 0)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s61 [0], s61 [1], s61 [2]), Quaternion.identity) as GameObject;
            go.name = "6-1";
        }
        else
        {
            return;
        }
        if (size6 > 1)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s62 [0], s62 [1], s62 [2]), Quaternion.identity) as GameObject;
            go.name = "6-2";
        }
        else
        {
            return;
        }
        if (size6 > 2)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s63 [0], s63 [1], s63 [2]), Quaternion.identity) as GameObject;
            go.name = "6-3";
        }
        else
        {
            return;
        }
        if (size6 > 3)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s64 [0], s64 [1], s64 [2]), Quaternion.identity) as GameObject;
            go.name = "6-4";
        }
        else
        {
            return;
        }
        if (size6 > 4)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s65 [0], s65 [1], s65 [2]), Quaternion.identity) as GameObject;
            go.name = "6-5";
        }
        else
        {
            return;
        }
        if (size6 > 5)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s66 [0], s66 [1], s66 [2]), Quaternion.identity) as GameObject;
            go.name = "6-6";
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 4
0
    private void Generate3rd()
    {
        GameObject go;
        Object     obj = SelectPrefab.SolidHex(colorList [2]);

        if (size3 > 0)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s31 [0], s31 [1], s31 [2]), Quaternion.identity) as GameObject;
            go.name = "3-1";
        }
        else
        {
            return;
        }
        if (size3 > 1)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s32 [0], s32 [1], s32 [2]), Quaternion.identity) as GameObject;
            go.name = "3-2";
        }
        else
        {
            return;
        }
        if (size3 > 2)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s33 [0], s33 [1], s33 [2]), Quaternion.identity) as GameObject;
            go.name = "3-3";
        }
        else
        {
            return;
        }
        if (size3 > 3)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s34 [0], s34 [1], s34 [2]), Quaternion.identity) as GameObject;
            go.name = "3-4";
        }
        else
        {
            return;
        }
        if (size3 > 4)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s35 [0], s35 [1], s35 [2]), Quaternion.identity) as GameObject;
            go.name = "3-5";
        }
        else
        {
            return;
        }
        if (size3 > 5)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s36 [0], s36 [1], s36 [2]), Quaternion.identity) as GameObject;
            go.name = "3-6";
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 5
0
    private void Generate4th()
    {
        GameObject go;
        Object     obj = SelectPrefab.SolidHex(colorList [3]);

        if (size4 > 0)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s41 [0], s41 [1], s41 [2]), Quaternion.identity) as GameObject;
            go.name = "4-1";
        }
        else
        {
            return;
        }
        if (size4 > 1)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s42 [0], s42 [1], s42 [2]), Quaternion.identity) as GameObject;
            go.name = "4-2";
        }
        else
        {
            return;
        }
        if (size4 > 2)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s43 [0], s43 [1], s43 [2]), Quaternion.identity) as GameObject;
            go.name = "4-3";
        }
        else
        {
            return;
        }
        if (size4 > 3)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s44 [0], s44 [1], s44 [2]), Quaternion.identity) as GameObject;
            go.name = "4-4";
        }
        else
        {
            return;
        }
        if (size4 > 4)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s45 [0], s45 [1], s45 [2]), Quaternion.identity) as GameObject;
            go.name = "4-5";
        }
        else
        {
            return;
        }
        if (size4 > 5)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s46 [0], s46 [1], s46 [2]), Quaternion.identity) as GameObject;
            go.name = "4-6";
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 6
0
    private void Generate2nd()
    {
        GameObject go;
        Object     obj = SelectPrefab.SolidHex(colorList [1]);

        if (size2 > 0)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s21 [0], s21 [1], s21 [2]), Quaternion.identity) as GameObject;
            go.name = "2-1";
        }
        else
        {
            return;
        }
        if (size2 > 1)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s22 [0], s22 [1], s22 [2]), Quaternion.identity) as GameObject;
            go.name = "2-2";
        }
        else
        {
            return;
        }
        if (size2 > 2)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s23 [0], s23 [1], s23 [2]), Quaternion.identity) as GameObject;
            go.name = "2-3";
        }
        else
        {
            return;
        }
        if (size2 > 3)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s24 [0], s24 [1], s24 [2]), Quaternion.identity) as GameObject;
            go.name = "2-4";
        }
        else
        {
            return;
        }
        if (size2 > 4)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s25 [0], s25 [1], s25 [2]), Quaternion.identity) as GameObject;
            go.name = "2-5";
        }
        else
        {
            return;
        }
        if (size2 > 5)
        {
            go      = GameObject.Instantiate(obj, CoordinateConversions.CubeToSquare(s26 [0], s26 [1], s26 [2]), Quaternion.identity) as GameObject;
            go.name = "2-6";
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 7
0
 public void transformPointsToLocal(double orientationOffset, double metersPerDegreeLatitude, double metersPerDegreeLongitude, double latitudeZero, double longitudeZero)
 {
     for (int i = 0; i < this.points.Length; i++)
     {
         double localY = CoordinateConversions.ConvertLatitudeToLocalY(this.points[i].y, this.points[i].x, orientationOffset, metersPerDegreeLatitude, metersPerDegreeLongitude, latitudeZero, longitudeZero);
         double localX = CoordinateConversions.ConvertLongitudeToLocalX(this.points[i].x, localY, orientationOffset, metersPerDegreeLongitude, longitudeZero);
         this.points[i].x = localX;
         this.points[i].y = localY;
     }
 }
Ejemplo n.º 8
0
        public void Demonstrate()
        {
            Console.WriteLine("[SENDER - INFO] Started sending example");
            //Marnehuizen
            double lat = 53.3889139;
            double lon = 6.263677777777778;

            EntityStatePdu espdu = new EntityStatePdu();

            espdu.ExerciseID = 1;

            EntityID eid = espdu.EntityID;

            eid.Site        = 0;
            eid.Application = 1;
            eid.Entity      = 2;

            EntityType entityType = espdu.EntityType;

            entityType.Country     = (ushort)Country.Netherlands; // NL
            entityType.EntityKind  = (byte)EntityKind.LifeForm;   // Life form (vs platform, munition, sensor, etc.)
            entityType.Domain      = (byte)Platform.Land;         // Land (vs air, surface, subsurface, space)
            entityType.Category    = 0;                           //empty
            entityType.Subcategory = 1;                           // Dismounted
            entityType.Specific    = 5;                           //carrying an assault rifle
            entityType.Extra       = 1;                           //Moving alone

            while (true)
            {
                lat += (1d / 11132000);
                lon += (1d / 40075) * Math.Cos(lat) / 360d;
                double[] disCoordinates = CoordinateConversions.getXYZfromLatLonDegrees(lat, lon, 0.0);

                Console.WriteLine("[SENDER - INFO] Entity is now at (lat:{0}, long:{1}", lat, lon);

                Vector3Double location = espdu.EntityLocation;
                location.X      = disCoordinates[0];
                location.Y      = disCoordinates[1];
                location.Z      = disCoordinates[2];
                espdu.Timestamp = DisTime.DisRelativeTimestamp;

                //send the constructed PDU to the specified multicast group
                _connector.sendPDU(espdu, MulticastGroup.Parse("224.5.5.5"));
                Console.WriteLine("[SENDER - INFO] PDU broadcasted");

                Thread.Sleep(15000);
            }
        }
Ejemplo n.º 9
0
    IEnumerator GetMaterials()
    {
        UnityWebRequest materialService = UnityWebRequest.Get("https://mms-material-service-stg.run.aws-usw02-pr.ice.predix.io/api/v2/clients/GELighting/sites/101/materials/views/lastlocation?status=active");

        materialService.SetRequestHeader("Content-Type", "application/json");
        materialService.SetRequestHeader("Authorization", Authorization.getToken());
        yield return(materialService.SendWebRequest());

        if (materialService.isNetworkError || materialService.isHttpError)
        {
            Debug.Log(materialService.error);
        }
        else
        {
            materials = JsonHelper.FromJson <MaterialClass>(JsonHelper.FixJson(materialService.downloadHandler.text));
            foreach (MaterialClass material in materials)
            {
                double     localZ           = CoordinateConversions.ConvertLatitudeToLocalY(material.y, material.x, orientationOffset, metersPerDegreeLatitude, metersPerDegreeLongitude, latitudeZero, longitudeZero);
                double     localX           = CoordinateConversions.ConvertLongitudeToLocalX(material.x, localZ, orientationOffset, metersPerDegreeLongitude, longitudeZero);
                GameObject materialInstance = Instantiate(palletAndBoxes, new Vector3((float)localX, (float)0.05420906, (float)localZ), Quaternion.Euler(-90, 0, 0));
                materialInstance.GetComponent <MaterialDetails>().MaterialId = material.materialId;
            }
        }
    }
Ejemplo n.º 10
0
    IEnumerator GetCarriers()
    {
        UnityWebRequest carrierService = UnityWebRequest.Get("https://mms-carrier-service-stg.run.aws-usw02-pr.ice.predix.io/api/v2/clients/GELighting/sites/101/carriers/locations/latest?active=true");

        carrierService.SetRequestHeader("Content-Type", "application/json");
        carrierService.SetRequestHeader("Authorization", Authorization.getToken());
        yield return(carrierService.SendWebRequest());

        if (carrierService.isNetworkError || carrierService.isHttpError)
        {
            Debug.Log(carrierService.error);
        }
        else
        {
            carriers = JsonHelper.FromJson <CarrierLocationClass>(JsonHelper.FixJson(carrierService.downloadHandler.text));
            foreach (CarrierLocationClass carrier in carriers)
            {
                double     localZ          = CoordinateConversions.ConvertLatitudeToLocalY(carrier.y, carrier.x, orientationOffset, metersPerDegreeLatitude, metersPerDegreeLongitude, latitudeZero, longitudeZero);
                double     localX          = CoordinateConversions.ConvertLongitudeToLocalX(carrier.x, localZ, orientationOffset, metersPerDegreeLongitude, longitudeZero);
                GameObject carrierInstance = Instantiate(forklift, new Vector3((float)localX, (float)0.06177858, (float)localZ), Quaternion.Euler(0, (float)(carrier.orientation + 90 + 40), 0));
                carrierInstance.transform.Find("forklift_truck").GetComponent <CarrierDetails>().CarrierId = carrier.carrierId;
            }
        }
    }
Ejemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        goalPosition = manager.transform.position;
        transform.up = this.velocity;

        if (this.velocity.magnitude == 0)
        {
            this.GetComponent <Rigidbody2D>().velocity =
                new Vector2(Random.Range(-5f, 5f), Random.Range(-5f, 5f))
                .normalized *
                2;
        }

        flock();
        goalPosition = manager.transform.position;
        stayInBorder();

        if (
            (this.location.x - this.prev_location.x) > threshold // If position in x axis > threshold value, send Espdu
            )
        {
            this.prev_location = this.location;
            this.sendNewEspdu  = true;
        }
        else if (
            (this.location.y - this.prev_location.y) > threshold // If position in y axis > threshold value, send Espdu
            )
        {
            this.prev_location = this.location;
            this.sendNewEspdu  = true;
        }
        else
        {
            this.sendNewEspdu = false;
        }

        for (int i = 0; i < 1; i++)
        {
            // Declaring the position of the Bird (in WSP - World Space Position)
            Vector3Double pos = new Vector3Double();
            pos.X = this.location.x;
            pos.Y = this.location.y;
            pos.Z = 0.0;
            Vector2 GPSloc = new Vector2();
            GPSloc.x = (float)pos.X;
            GPSloc.y = (float)pos.Y;
            double[] ODLoc =
                CoordinateConversions
                .getXYZfromLatLonDegrees(GPSloc.x, GPSloc.y, pos.Z);

            Vector3Double loc = new Vector3Double();
            loc.X = ODLoc[0];
            loc.Y = ODLoc[1];
            loc.Z = ODLoc[2];
            espdu.EntityLocation = loc;

            // Declaring the Bird's velocity
            Vector3Float vel = espdu.EntityLinearVelocity;
            vel.X = this.velocity.x;
            vel.Y = this.velocity.y;
            vel.Z = 0.0f;

            // Declaring the DeadReckoning Algorithm to be used (R, P, W)
            espdu.DeadReckoningParameters.DeadReckoningAlgorithm = (byte)2;

            //// THIS IS IN TESTING PHASE --------------------------------------------------------------------
            //// Setting the angular velocity of the Bird (as above)
            //Vector3Float angvelo = new Vector3Float
            //{
            //    X = this.GetComponent<Rigidbody2D>().angularVelocity,
            //    Y = 0.0f,
            //    Z = 0.0f
            //};
            //espdu.DeadReckoningParameters.EntityAngularVelocity = angvelo;
            //// END OF TESTING BLOCK ------------------------------------------------------------------------
            if (this.sendNewEspdu)
            {
                espdu.Timestamp = DisTime.DisRelativeTimestamp;

                // Prepare output
                DataOutputStream dos = new DataOutputStream(Endian.Big);
                espdu.MarshalAutoLengthSet(dos);

                // Transmit broadcast messages
                Sender.SendMessages(dos.ConvertToBytes());
                string mess =
                    string
                    .Format("Message sent with TimeStamp [{0}] Time Of[{1}]",
                            espdu.Timestamp,
                            (espdu.Timestamp >> 1));
                Debug.Log(mess);
            }
        }
    }
Ejemplo n.º 12
0
        public Matrix JacobianPolarsWrtCartesians()
        {
            var j = CoordinateConversions.JacobianPolarsWrtCartesians(this);

            return(j);
        }
Ejemplo n.º 13
0
        public Polars ToPolars()
        {
            var polars = CoordinateConversions.CartesiansToPolars(this);

            return(polars);
        }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
            mcastAddress  = IPAddress.Parse("239.1.2.3");
            mcastPort     = 62040;
            broadcastPort = 62040;            //3000 for DisMapper default
            var espdu = new EntityStatePdu(); //Could use factory but easier this way

            //Alcatraz
            const double lat = 37.827;
            double       lon = -122.425;

            // Configure socket.
            //JoinMulticast();   //Used to talk to C# receiver.  No need to connect as we are just sending multicast
            //StartMulticast();  //Least preffered
            StartBroadcast();      //Used for DisMapper

            //Setup EntityState PDU
            espdu.ExerciseID = 1;
            var eid = espdu.EntityID;

            eid.Site        = 0;
            eid.Application = 1;
            eid.Entity      = 2;
            // Set the entity type. SISO has a big list of enumerations, so that by
            // specifying various numbers we can say this is an M1A2 American tank,
            // the USS Enterprise, and so on. We'll make this a tank. There is a
            // separate project elsehwhere in this project that implements DIS
            // enumerations in C++ and Java, but to keep things simple we just use
            // numbers here.
            var entityType = espdu.EntityType;

            entityType.EntityKind  = 1;     // Platform (vs lifeform, munition, sensor, etc.)
            entityType.Country     = 255;   // USA
            entityType.Domain      = 1;     // Land (vs air, surface, subsurface, space)
            entityType.Category    = 1;     // Tank
            entityType.Subcategory = 1;     // M1 Abrams
            entityType.Specific    = 3;     // M1A2 Abrams

            for (int i = 0; i < 100; i++)
            {
                lon += (i / 1000.0);

                double[] disCoordinates = CoordinateConversions.getXYZfromLatLonDegrees(lat, lon, 0.0);

                var location = espdu.EntityLocation;
                location.X      = disCoordinates[0];
                location.Y      = disCoordinates[1];
                location.Z      = disCoordinates[2];
                espdu.Timestamp = DisTime.DisRelativeTimestamp;

                //Prepare output
                var dos = new DataOutputStream(Endian.Big);
                espdu.MarshalAutoLengthSet(dos);

                // Transmit broadcast messages
                SendMessages(dos.ConvertToBytes());
                Console.Write("Message sent with TimeStamp [{0}] Time Of[{1}]", espdu.Timestamp, espdu.Timestamp >> 1);

                //Thread.Sleep(1000);
                Console.Write("Hit Enter for Next PDU.  Ctrl-C to Exit");
                Console.ReadLine();
            }

            mcastSocket.Close();
        }
Ejemplo n.º 15
0
        public XYZ ToXYZ()
        {
            var xyz = CoordinateConversions.RAEToXYZ(this);

            return(xyz);
        }