Exemplo n.º 1
0
        /// <summary>
        /// tweens an Images alpha property
        /// </summary>
        /// <returns>The kalpha to.</returns>
        /// <param name="self">Self.</param>
        /// <param name="to">To.</param>
        /// <param name="duration">Duration.</param>
        public static ITween<float> ZKalphaTo( this Image self, float to, float duration = 0.3f )
        {
            var tweenTarget = new ImageTarget( self, ImageTarget.ImageTargetType.Alpha );
            var tween = FloatTween.create();
            tween.initialize( tweenTarget, self.color.a, to, duration );

            return tween;
        }
 public VirtualButtonImpl(string name, int id, RectangleData area,
     ImageTarget imageTarget, DataSet dataSet)
 {
     mName = name;
     mID = id;
     mArea = area;
     mIsEnabled = true;
     mParentImageTarget = imageTarget;
     mParentDataSet = (DataSetImpl)dataSet;
 }
Exemplo n.º 3
0
        public void ViewTestsSimple()
        {
            var center = new GeoCoordinate(51.0886211395264,3.45352852344513);

            Image img = new Bitmap(2500, 2500);
            var target = new ImageTarget(img);

            View view = View.CreateFrom(target, 17, center);

            GeoCoordinate centerAfter = view.ConvertFromTargetCoordinates(target,
                target.XRes / 2f, target.YRes / 2f);

            Assert.AreEqual(center.Latitude, centerAfter.Latitude, 0.000001);
            Assert.AreEqual(center.Longitude, centerAfter.Longitude, 0.000001);
        }
Exemplo n.º 4
0
 // Creates a new Image Target with the data of the Image Target with the
 // given name.
 // Returns false if Image Target does not exist.
 public void GetImageTarget(string name, out ImageTarget it)
 {
     try
     {
         it = imageTargets[name];
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 5
0
		/// <summary>
		/// tweens an Images fillAmount property
		/// </summary>
		/// <returns>The kfill amount to.</returns>
		/// <param name="self">Self.</param>
		/// <param name="to">To.</param>
		/// <param name="duration">Duration.</param>
		public static ITween<float> ZKfillAmountTo( this Image self, float to, float duration = 0.3f )
		{
			var tweenTarget = new ImageTarget( self, ImageTarget.ImageTargetType.FillAmount );
			var tween = ZestKit.cacheFloatTweens ? QuickCache<FloatTween>.pop() : new FloatTween();
			tween.initialize( tweenTarget, self.fillAmount, to, duration );

			return tween;
		}
Exemplo n.º 6
0
        /// <summary>
        /// tweens an Images fillAmount property
        /// </summary>
        /// <returns>The kfill amount to.</returns>
        /// <param name="self">Self.</param>
        /// <param name="to">To.</param>
        /// <param name="duration">Duration.</param>
        public static ITween<float> ZKfillAmountTo( this Image self, float to, float duration = 0.3f )
        {
            var tweenTarget = new ImageTarget( self, ImageTarget.ImageTargetType.FillAmount );
            var tween = FloatTween.create();
            tween.initialize( tweenTarget, self.fillAmount, to, duration );

            return tween;
        }
 /// <summary>
 /// Loads the image into given imageView using defined parameters.
 /// </summary>
 /// <param name="parameters">Parameters for loading the image.</param>
 /// <param name="imageView">Image view that should receive the image.</param>
 public static IScheduledWork Into(this TaskParameter parameters, Image imageView)
 {
     var target = new ImageTarget(imageView);
     return parameters.Into(target);
 }
Exemplo n.º 8
0
    public Entry ParseEntry(JSONNode entry)
    {
        // Create entry
        Entry entryObject = new Entry();

        entryObject.setId(entry["id"]);

        // Create target
        Target targetObject;
        var    target     = entry["target"];
        string targetType = target["type"];

        switch (targetType)
        {
        case "IMAGE_TARGET":
            ImageTarget imageTargetObject = new ImageTarget();
            imageTargetObject.setFilename(target["filename"]);
            imageTargetObject.setStorageID(target["storageID"]);
            imageTargetObject.setId(target["id"]);
            imageTargetObject.setType(Target.targetType.IMAGE_TARGET);
            targetObject = imageTargetObject;
            break;

        case "GEOLOCATION_TARGET":
            GeolocationTarget geolocationTargetObject = new GeolocationTarget();
            geolocationTargetObject.setCity(target["city"]);
            geolocationTargetObject.setContinent(target["continent"]);
            geolocationTargetObject.setCountry(target["country"]);
            geolocationTargetObject.setId(target["id"]);
            geolocationTargetObject.setLatitude(target["latitude"]);
            geolocationTargetObject.setLongitude(target["longitude"]);
            geolocationTargetObject.setPlace(target["place"]);
            geolocationTargetObject.setType(Target.targetType.GEOLOCATION_TARGET);
            targetObject = geolocationTargetObject;
            break;

        case "BRICK_TARGET":
            BrickTarget brickTargetObject = new BrickTarget();
            brickTargetObject.setId(target["id"]);
            brickTargetObject.setType(Target.targetType.BRICK_TARGET);
            targetObject = brickTargetObject;
            break;

        default:
            targetObject = new Target();
            break;
        }
        List <string> hologramsListObject = new List <string>();
        int           j          = 0;
        var           hologramID = target["holograms"][j];

        while (hologramID != null)
        {
            hologramsListObject.Add(hologramID);
            hologramID = target["holograms"][++j];
        }
        targetObject.setHolograms(hologramsListObject);
        entryObject.setTarget(targetObject);

        // Create Hologram
        Hologram hologramObject;
        var      hologram     = entry["hologram"];
        string   hologramType = hologram["type"];

        switch (hologramType)
        {
        case "IMAGE_HOLOGRAM":
            ImageHologram imageHologramObject = new ImageHologram();
            imageHologramObject.setFilename(hologram["filename"]);
            imageHologramObject.setId(hologram["id"]);
            imageHologramObject.setStorageID(hologram["storageID"]);
            imageHologramObject.setTargetID(hologram["targetID"]);
            imageHologramObject.setType(Hologram.hologramType.IMAGE_HOLOGRAM);
            imageHologramObject.setTarget(targetObject);
            hologramObject = imageHologramObject;
            break;

        case "VIDEO_HOLOGRAM":
            VideoHologram videoHologramObject = new VideoHologram();
            videoHologramObject.setFilename(hologram["filename"]);
            videoHologramObject.setId(hologram["id"]);
            videoHologramObject.setStorageID(hologram["storageID"]);
            videoHologramObject.setTargetID(hologram["targetID"]);
            videoHologramObject.setType(Hologram.hologramType.VIDEO_HOLOGRAM);
            videoHologramObject.setTarget(targetObject);
            hologramObject = videoHologramObject;
            break;

        case "ECHO_HOLOGRAM":
            EchoHologram echoHologramObject = new EchoHologram();
            echoHologramObject.setFilename(hologram["filename"]);
            echoHologramObject.setId(hologram["id"]);
            echoHologramObject.setEncodedEcho(hologram["encodedEcho"]);
            echoHologramObject.setTextureFilename(hologram["textureFilename"]);
            echoHologramObject.setTargetID(hologram["targetID"]);
            echoHologramObject.setType(Hologram.hologramType.ECHO_HOLOGRAM);
            echoHologramObject.setTarget(targetObject);
            List <string> videosListObject = new List <string>();

            j = 0;
            var videoID = hologram["vidoes"][j];
            while (videoID != null)
            {
                videosListObject.Add(videoID);
                hologramID = hologram["vidoes"][++j];
            }
            echoHologramObject.setVidoes(videosListObject);

            hologramObject = echoHologramObject;
            break;

        case "MODEL_HOLOGRAM":
            ModelHologram modelHologramObject = new ModelHologram();
            modelHologramObject.setEncodedFile(hologram["encodedFile"]);
            modelHologramObject.setFilename(hologram["filename"]);
            modelHologramObject.setId(hologram["id"]);
            modelHologramObject.setMaterialFilename(hologram["materialFilename"]);
            modelHologramObject.setMaterialStorageID(hologram["materialStorageID"]);
            modelHologramObject.setStorageID(hologram["storageID"]);
            modelHologramObject.setTargetID(hologram["targetID"]);
            var textureFilenames  = hologram["textureFilenames"].AsArray;
            var textureStorageIDs = hologram["textureStorageIDs"].AsArray;
            for (j = 0; j < textureFilenames.Count; j++)
            {
                modelHologramObject.addTexture(textureFilenames[j], textureStorageIDs[j]);
            }
            modelHologramObject.setType(Hologram.hologramType.MODEL_HOLOGRAM);
            modelHologramObject.setTarget(targetObject);
            // If applicable, update model hologram with .glb version
            if (entry["additionalData"]["glbHologramStorageID"] != null)
            {
                modelHologramObject.setFilename(entry["additionalData"]["glbHologramStorageFilename"]);
                modelHologramObject.setStorageID(entry["additionalData"]["glbHologramStorageID"]);
            }
            hologramObject = modelHologramObject;
            break;

        default:
            hologramObject = new Hologram();
            break;
        }
        entryObject.setHologram(hologramObject);

        // Create SDKs array
        bool[] sdksObject = new bool[9];
        var    sdks       = entry["sdks"].AsArray;

        for (j = 0; j < 9; j++)
        {
            sdksObject[j] = sdks[j];
        }
        entryObject.setSupportedSDKs(sdksObject);

        // Create Additional Data
        var additionalData = entry["additionalData"];

        foreach (var data in additionalData)
        {
            entryObject.addAdditionalData(data.Key, data.Value);
        }

        // Add entry to database
        dbObject.addEntry(entryObject);

        // Return
        return(entryObject);
    }
Exemplo n.º 9
0
 // Set attributes of the Image Target with the given name.
 // If the Image Target does not yet exist it is created automatically.
 public void SetImageTarget(ImageTarget item, string name)
 {
     imageTargets[name] = item;
 }
 protected override void InternalUnregisterTrackable()
 {
     base.mTrackable = (Trackable)(this.mImageTarget = null);
 }
Exemplo n.º 11
0
    /// <summary>
    /// Takes a given GameObject to add a new ImageTargetBehaviour to. This new Behaviour is associated with the given ImageTarget
    /// </summary>
    public ImageTargetBehaviour FindOrCreateImageTargetBehaviourForTrackable(ImageTarget trackable, GameObject gameObject, DataSet dataSet)
    {
        DataSetTrackableBehaviour trackableBehaviour = gameObject.GetComponent<DataSetTrackableBehaviour>();

        // add an ImageTargetBehaviour if none is attached yet
        if (trackableBehaviour == null)
        {
            trackableBehaviour = gameObject.AddComponent<ImageTargetBehaviour>();
            ((IEditorTrackableBehaviour)trackableBehaviour).SetInitializedInEditor(true);
        }

        // configure the new ImageTargetBehaviour instance:
        if (!(trackableBehaviour is ImageTargetBehaviour))
        {
            Debug.LogError(
                string.Format("DataSet.CreateTrackable: Trackable of type ImageTarget was created, but behaviour of type {0} was provided!",
                                trackableBehaviour.GetType()));
            return null;
        }

        IEditorImageTargetBehaviour editorImgTargetBehaviour = (ImageTargetBehaviour)trackableBehaviour;
        if (dataSet != null) editorImgTargetBehaviour.SetDataSetPath(dataSet.Path);
        editorImgTargetBehaviour.SetImageTargetType(trackable.ImageTargetType);
        editorImgTargetBehaviour.SetNameForTrackable(trackable.Name);
        editorImgTargetBehaviour.InitializeImageTarget(trackable);

        mTrackableBehaviours[trackable.ID] = trackableBehaviour;

        return trackableBehaviour as ImageTargetBehaviour;
    }
 /// <summary>
 /// Function is called when tracking is lost - initiates handoff
 /// </summary>
 /// <param name="imgTarget"></param>
 public void OnTrackingLostHandoff(ImageTarget imgTarget)
 {
     TrackingLost();
 }
 /// <summary>
 /// Function is called when tracking is found - ends the handoff
 /// </summary>
 /// <param name="imgTarget">Image target that was found</param>
 public void OnTrackingFoundHandoff(ImageTarget imgTarget)
 {
     TrackingFound();
 }
Exemplo n.º 14
0
        // Update is called once per frame
        void Update()
        {
            StateManager sm = TrackerManager.Instance.GetStateManager();
            IEnumerable <TrackableBehaviour> tbs = sm.GetActiveTrackableBehaviours();

            Found.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    Question.gameObject.SetActive(true);
                    Found.gameObject.SetActive(false);
                    Q1.gameObject.SetActive(true);
                    Q2.gameObject.SetActive(true);
                    Q3.gameObject.SetActive(true);
                    Q4.gameObject.SetActive(true);
                }
            });

            Q1.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    BlackFade.gameObject.SetActive(true);
                    Wrong.gameObject.SetActive(true);
                }
            });

            Q2.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    BlackFade.gameObject.SetActive(true);
                    Wrong.gameObject.SetActive(true);
                }
            });

            Q3.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    BlackFade.gameObject.SetActive(true);
                    Wrong.gameObject.SetActive(true);
                }
            });

            Q4.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    Correct.gameObject.SetActive(true);
                    BlackFade.gameObject.SetActive(true);
                }
            });

            Wrong.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    Wrong.gameObject.SetActive(false);
                    BlackFade.gameObject.SetActive(false);
                }
            });

            Correct.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    Correct.gameObject.SetActive(false);
                    Question.gameObject.SetActive(false);
                    Q1.gameObject.SetActive(false);
                    Q2.gameObject.SetActive(false);
                    Q3.gameObject.SetActive(false);
                    Q4.gameObject.SetActive(false);
                    Congratulations.gameObject.SetActive(true);
                    BlackFade.gameObject.SetActive(false);
                    Cam.gameObject.SetActive(true);
                    Done.gameObject.SetActive(true);
                }
            });

            Done.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    Done.gameObject.SetActive(false);
                    Congratulations.gameObject.SetActive(false);
                    Cam.gameObject.SetActive(false);
                    KeepSearching.gameObject.SetActive(true);
                    BlackFade.gameObject.SetActive(true);
                }
            });

            KeepSearching.GetComponent <Button> ().onClick.AddListener(delegate {
                if (click)
                {
                    KeepSearching.gameObject.SetActive(false);
                    BlackFade.gameObject.SetActive(false);
                    Badge.gameObject.SetActive(true);
                }
            });



            foreach (TrackableBehaviour tb in tbs)
            {
                string      name = tb.TrackableName;
                ImageTarget it   = tb.Trackable as ImageTarget;
                Vector2     size = it.GetSize();

                Debug.Log("Active image target:" + name + "  -size: " + size.x + ", " + size.y);
            }
        }
 /// <summary> From the any type of ImageTarget into this</summary>
 public void CopyFrom(int srcid, ImageTarget srctype, int srcmiplevel, int sx, int sy, int sz, int dx, int dy, int width, int height)
 {
     GL.CopyImageSubData(srcid, srctype, srcmiplevel, sx, sy, sz, Id, ImageTarget.Renderbuffer, 0, dx, dy, 0, width, height, 1);
     GLStatics.Check();
 }
Exemplo n.º 16
0
        // Update is called once per frame
        void Update()
        {
            StateManager sm = TrackerManager.Instance.GetStateManager();
            IEnumerable <TrackableBehaviour> tbs = sm.GetActiveTrackableBehaviours();

            foreach (TrackableBehaviour tb in tbs)
            {
                string      name = tb.TrackableName;
                ImageTarget it   = tb.Trackable as ImageTarget;
                Vector2     size = it.GetSize();

                Debug.Log("Active image target:" + name + "  -size: " + size.x + ", " + size.y);

                TextTargetName.GetComponent <Text>().text   = name;
                Panel_Text.GetComponent <Text>().text       = name;
                TextTargetNameUI.GetComponent <Text>().text = name;
                ButtonAction.gameObject.SetActive(true);
                TextDescription.gameObject.SetActive(true);

                PanelDescription.gameObject.SetActive(true);
                PanelDescriptionInside.gameObject.SetActive(true);
                ButtonActionShow.gameObject.SetActive(true);


                if (name == "Mercury")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Mercury_final"); });
                    TextDescription.GetComponent <Text>().text = "   The smallest planet in our solar system and the nearest to the Sun. " +
                                                                 "Mercury is only slightly larger than the Earth's moon. From the surface of Mercury, the Sun would appear more than three " +
                                                                 "times as large as it does when viewed from Earth and the sunlight would be as much as 11 times brighter." +
                                                                 "\nAge: 4.503 billion years" +
                                                                 "\nRadius(Size): 2,440 km" +
                                                                 "\nDistance from Sun: 57.91 million km" +
                                                                 "\nNumber of moon/s: no moon";
                }
                if (name == "Venus")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Venus_final"); });
                    TextDescription.GetComponent <Text>().text = "   The second planet from the Sun and our closest planetary neighbor. Venus " +
                                                                 "is similar in structure and size to Earth. Venus spins slowly in the opposite direction most planets do. Its thick atmosphere " +
                                                                 "traps heat with greenhouse effect, making it the hottest planet in our solar system." +
                                                                 "\nAge: 4.503 billion years" +
                                                                 "\nRadius(Size): 6,052 km " +
                                                                 "\nDistance from Sun: 108.2 million km" +
                                                                 "\nNumber of moon/s: no moon";
                }
                if (name == "Earth")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Earth_final"); });
                    TextDescription.GetComponent <Text>().text = "   Our home planet is the third planet from the Sun and the only planet we know " +
                                                                 "so far that is inhabited by living things. It is the only world in our solar system with liquid water on the surface. It is just " +
                                                                 "slightly larger than nearby Venus. " +
                                                                 "\nAge: 4.543 billion years" +
                                                                 "\nRadius(Size): 6,371 km " +
                                                                 "\nDistance from Sun: 149.6 million km" +
                                                                 "\nNumber of moon/s: 1 moon";
                }
                if (name == "Mars")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Mars_final"); });
                    TextDescription.GetComponent <Text>().text = "   The fourth planet, and it is a dusty,cold, dessert world with a very thin atmosphere. " +
                                                                 "This dynamic planet has seasons, polar ice caps, extinct volcanoes, canyons and weather. Mars is one of the most explored bodies in our " +
                                                                 "solar system and it is the only planet where we've sent rovers to roam the alien landscape. " +
                                                                 "\nAge: 4.603 billion years" +
                                                                 "\nRadius(Size): 3,390 km" +
                                                                 "\nDistance from Sun: 227.9 million km" +
                                                                 "\nNumber of moon/s: 2 moons (Phobos and Deimos)";
                }
                if (name == "Jupiter")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Jupiter_final"); });
                    TextDescription.GetComponent <Text>().text = "   The fifth planet from the Sun and is, by far, the largest planet in the solar system. " +
                                                                 "It is more than twice as massive as all the other planets combined. Jupiter's stripes and swirls are actually cold. windy clouds of ammonia " +
                                                                 "and water, floating in an atmosphere of hydrogen and helium. Jupiter's iconic Great Red Spot is a giant " +
                                                                 "storm bigger than Earth that has raged for hundreds of years." +
                                                                 "\nAge: 4.503 billion years" +
                                                                 "\nRadius(Size): 69,911 km" +
                                                                 "\nDistance from Sun: 778.5 million km" +
                                                                 "\nNumber of moon/s: 79 moons";
                }
                if (name == "Saturn")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Saturn_final"); });
                    TextDescription.GetComponent <Text>().text = "   The sixth planet from the Sun and the second largest planet in our solar system. Adorned with " +
                                                                 "a dazzling system of icy rings, Saturn is unique among the planets. It is not the only planet to have rings but none are as spectacular or as " +
                                                                 "complex as Saturn. Saturn is home to some of the most fascinating landscapes in our solar system." +
                                                                 "\nAge: 4.503 billion years" +
                                                                 "\nRadius(Size): 58,232 km" +
                                                                 "\nDistance from Sun: 1.443 billion km" +
                                                                 "\nNumber of moon/s: 62 moons";
                }
                if (name == "Uranus")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Uranus_final"); });
                    TextDescription.GetComponent <Text>().text = "   The seventh planet from the Sun and the third largest planet in our solar system. Uranus is " +
                                                                 "very cold and windy. The ice giant is surrounded by 13 faint rings and 27 small moons as it rotates at a nearby 90 degree angle from the plane of " +
                                                                 "its orbit. This unique tilt make Uranus appear to spin on its side, orbiting the Sun like a rolling ball." +
                                                                 "\nAge: 4.503 billion years" +
                                                                 "\nRadius(Size): 25,362 km" +
                                                                 "\nDistance from Sun: 2.871 billion km" +
                                                                 "\nNumber of moon/s: 27 moons";
                }
                if (name == "Neptune")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Neptune_final"); });
                    TextDescription.GetComponent <Text>().text = "   Dark, cold and whipped by supersonic winds, ice giant Neptune is the eighth and the most " +
                                                                 "distant planet in our solar system. More than 30 times as far from the Sun as Earth. Neptune is the only planet in our solar system that is not visible " +
                                                                 "to the naked eye. Neptune is so far from the Sun that high noon on the big blue planet would seem like dim twilight to us." +
                                                                 "\nAge: 4.503 billion years" +
                                                                 "\nRadius(Size): 24,622 km" +
                                                                 "\nDistance from the Sun: 4.492 billion km" +
                                                                 "\nNumber of moon/s: 14 moons";
                }
                if (name == "Sun")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/Sun_final"); });
                    TextDescription.GetComponent <Text>().text = "   The Sun is the star at the center of the Solar System. It is a nearly perfect sphere of hot plasma, with " +
                                                                 "internal convective motion that generates a magnetic field via a dynamo process. " +
                                                                 "\nAge: 4.5 billion years" +
                                                                 "\nRadius(Size): 695,508 km";
                }
            }
        }
Exemplo n.º 17
0
    void IEditorImageTargetBehaviour.InitializeImageTarget(ImageTarget imageTarget)
    {
        mTrackable = mImageTarget = imageTarget;
        mVirtualButtonBehaviours = new Dictionary<int, VirtualButtonBehaviour>();

        // do not change the aspect ratio of user defined targets, these are set by the algorithm internally
        if (imageTarget.ImageTargetType == ImageTargetType.PREDEFINED)
        {
            // Handle any changes to the image target in the scene
            // that are not reflected in the config file
            Vector2 imgTargetUnitySize = GetSize();

            imageTarget.SetSize(imgTargetUnitySize);
        }
        else // instead, set the aspect of the unity object to the value of the user defined target
        {
            Vector2 udtSize = imageTarget.GetSize();

            // set the size of the target to the value returned from cloud reco:
            transform.localScale =
                new Vector3(udtSize.x,
                            udtSize.x,
                            udtSize.x);

            IEditorImageTargetBehaviour editorThis = this;
            editorThis.CorrectScale();

            editorThis.SetAspectRatio(udtSize.y / udtSize.x);
        }
    }
Exemplo n.º 18
0
        void Update()
        {
            StateManager sm = TrackerManager.Instance.GetStateManager();
            IEnumerable <TrackableBehaviour> tbs = sm.GetActiveTrackableBehaviours();

            foreach (TrackableBehaviour tb in tbs)
            {
                string      name = tb.TrackableName;
                ImageTarget it   = tb.Trackable as ImageTarget;
                Vector2     size = it.GetSize();

                Debug.Log("Active image target:" + name + "  -size: " + size.x + ", " + size.y);

                TextTargetNameFacts.GetComponent <Text>().text      = name;
                TextTargetNamePanelFacts.GetComponent <Text>().text = name;
                TextDescriptionFacts.gameObject.SetActive(true);
                PanelDescriptionFacts.gameObject.SetActive(true);


                if (name == "Mercury")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. Mercury is named after the Roman deity Mercury, the messenger of the gods." +
                                                                      "\n2. Mercury has no moon." +
                                                                      "\n3. Only two spacecraft have ever visited Mercury. The Mariner 10 and MESSENGER." +
                                                                      "\n4. A day on the surface of Mercury lasts 176 Earth days and A year on Mercury takes 88 Earth days.";
                }

                if (name == "Venus")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. Venus is named for the ancient Roman goddess of love anf beauty." +
                                                                      "\n2. Venus has no moon." +
                                                                      "\n3. Venus is the hottest planet in our Solar System." +
                                                                      "\n4. Venus is often called the Earth's sister planet." +
                                                                      "\n5. Venus has the longest rotation period of any planet int he Solar System and rotates in the opposite direction to most other planets.";
                }

                if (name == "Earth")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. Earth is the only planet not named after a god." +
                                                                      "\n2. There is only natural satellite of the planet Earth." +
                                                                      "\n3. The Earth was once believed to be the centre of the universe. " +
                                                                      "\n4. There is only one natural satellite of the planet Earth." +
                                                                      "\n5. The Earth is the densest planet in the Solar System.";
                }

                if (name == "Mars")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. Befitting the red planet's bloody color, the Romans named Mars after their god of war, Ares." +
                                                                      "\n2. Only 18 missions to Mars have been successful." +
                                                                      "\n3. Mars is home to the tallest mountain in the solar system." +
                                                                      "\n4. Mars was once believed to be home to intelligent life." +
                                                                      "\n5. Pieces of Mars have been found on Earth." +
                                                                      "\n6. MArs has the largest dust storms in the solar system.";
                }

                if (name == "Jupiter")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. Jupiter was named after the king of gods in Roman mythology. In a similar manner, the ancient Greeks named the planet after Zeus, the king of the Greek pantheon." +
                                                                      "\n2. Jupiter has a unique cloud features." +
                                                                      "\n3. Eight spcaecraft have visited Jupiter. The Pioneer 10 and 11, Voyager 1 and 2, Galileo, Cassini, Ulysses, and New Horizons missions. " +
                                                                      "\n4. The Great Red spot is a huge storm on Jupiter. ";
                }

                if (name == "Saturn")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. Saturn is named after a character in Roman mythology. Saturn is named after the god Saturns, the god of agriculture and harvest." +
                                                                      "\n2. Saturn has oval-shaped storms similar to Jupiter." +
                                                                      "\n3. Saturn is made mostly of hydrogen." +
                                                                      "\n4. Saturn has the most extensive rings in the solar system. " +
                                                                      "\n5. Saturn is the flattest planet. " +
                                                                      "\n6. Four spacecraft have visited Saturn. The Pioneer 11, Voyager 1 and 2, and the Cassini-Hyugens missions.";
                }

                if (name == "Uranus")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. The name Uranus was first proposed by German astronomer Johann Elert Bode." +
                                                                      "\n2. Uranus is often referred to as an ice giant planet." +
                                                                      "\n3. Uranus hits the coldest temperatures of any planet. " +
                                                                      "\n4. Uranus has two sets of very thin dark coloured rings." +
                                                                      "\n5. Only one spacecraft has flown by Uranus. It is the Voyager 2." +
                                                                      "\n6. It has 27 known moons, all of which are named after characters from the works of William Shakespeare and Alexander Pope.";
                }

                if (name == "Neptune")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. In Roman Mythology, Neptune was the god of the sea." +
                                                                      "\n2. Neptune is the smallest of the ice giants. " +
                                                                      "\n3. Neptune has a very active climate. " +
                                                                      "\n4. Neptune has a very thin collection of rings." +
                                                                      "\n5. Only one spacecraft has flown by Neptune. It is the Voyager 2 spacecraft.";
                }

                if (name == "Pluto")
                {
                    TextDescriptionFacts.GetComponent <Text>().text = "Did you know? \n" +
                                                                      "\n1. Pluto is named after the greek god of the underworld. " +
                                                                      "\n2. Pluto was reclassified from a planet to a dwarf planet in 2006." +
                                                                      "\n3. Pluto has been visited by one spacecraft. It is the New Horizons spacecraft." +
                                                                      "\n4. Pluto is the largest dwarf planet." +
                                                                      "\n5. Pluto is one third water. " +
                                                                      "\n6. Pluto has a eccentric and inclined orbit.";
                }

                if (name == "Sun")
                {
                    TextDescriptionFacts.GetComponent <Text> ().text = "Did you know? \n" +
                                                                       "\n1. Sun was named after the God of Enlightenment, Apollo." +
                                                                       "\n2. As its centre, the Sun reaches temperatures of 15 million degrees C." +
                                                                       "\n3. The Sun is all the colours mized together, this appears white to our eyes." +
                                                                       "\n4. One million Earths could fit inside the Sun." +
                                                                       "\n5. The Sun is an almost perfect square.";
                }
            }
        }
Exemplo n.º 19
0
        // Update is called once per frame
        void Update()
        {
            StateManager sm = TrackerManager.Instance.GetStateManager();
            IEnumerable <TrackableBehaviour> tbs = sm.GetActiveTrackableBehaviours();

            foreach (TrackableBehaviour tb in tbs)
            {
                string      name = tb.TrackableName;
                ImageTarget it   = tb.Trackable as ImageTarget;
                Vector2     size = it.GetSize();

                Debug.Log("Active image target:" + name + "  -size: " + size.x + ", " + size.y);

//Evertime the target found it will show “name of target” on the TextTargetName. Button, Description and Panel will visible (active)

                TextTargetName.GetComponent <Text>().text = name;
                ButtonAction.gameObject.SetActive(true);
                TextDescription.gameObject.SetActive(true);
                PanelDescription.gameObject.SetActive(true);


//If the target name was “zombie” then add listener to ButtonAction with location of the zombie sound (locate in Resources/sounds folder) and set text on TextDescription a description of the zombie

                if (name == "bumi")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/bumi"); });
                    TextDescription.GetComponent <Text>().text = "Planet ketiga adalah Bumi yang sering disebut sebagai Planet Biru, bumi merupakan planet dimana kita tinggal. Sebagian besar Bumi ditutupi oleh lautan, sehingga nampak biru. Bumi diselimuti oleh udara tebal yang disebut atmosfer. Fungsi dari atmosfer untuk menyaring panas dari Matahari sehingga tidak terbakar.";
                }



//If the target name was “unitychan” then add listener to ButtonAction with location of the unitychan sound (locate in Resources/sounds folder) and set text on TextDescription a description of the unitychan / robot

                if (name == "venus")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/venus"); });
                    TextDescription.GetComponent <Text>().text = "Planet kedua yaitu venus, Venus merupakan planet terdekat dari Bumi. Venus lebih panas dibanding Merkurius yang lebih dekat dengan Matahari. Hal ini terjadi karena Planet Venus memiliki lapisan atmosfer tebal yang dilapisi awan. Venus melakukan rotasi dengan arah yang berlawanan dengan rotasi planet-planet lainnya. Venus berotasi searah dengan jarum jam. Satu hari di Venus sama dengan 243 hari di Bumi.";
                }

                if (name == "merkurius")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/merkurius"); });
                    TextDescription.GetComponent <Text>().text = "Planet pertama adalah Merkurius, merkurius merupakan planet terdekat dari matahari yang  berjarak 58jt km, Merkurius sulit terlihat di langit pada malam hari jika dilihat dari Bumi. Markurius baru terlihat setelah Matahari terbenam, atau sebelum Matahari terbit. Keunikan dari Merkurius adalah melesat cepat mengelilingi Matahari, tetapi berotasi sangat lambat. Satu hari di Merkurius sama dengan 30 hari di Bumi.";
                }

                if (name == "mars")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/mars"); });
                    TextDescription.GetComponent <Text>().text = "Planet ke empat  adalah Mars. Mars dijuluki sebagai Planet Merah.  Planet ini disebut paling menyerupai Bumi. Satu hari di Mars sama dengan 24,6 jam di Bumi.  Ia juga memiliki kutub yang diselimuti es.  Suhu udara di Mars lebih dingin daripada suhu di Bumi, yaitu sekitar   - 63 derajat Celsius,  karena letak Mars yang lebih jauh dari Matahari dibanding Bumi.  Mars juga memiliki lapisan atmosfer, namun lebih tipis dibanding Bumi.";
                }

                if (name == "jupiter")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/jupiter"); });
                    TextDescription.GetComponent <Text>().text = "Planet kelima adalah planet Jupiter. Jupiter adalah planet terbesar di dalam tata surya. Suhu di planet ini pun sangat rendah, mencapai kurang lebih - 100 derajat Celsius. Planet Jupiter merupakan planet yang sebagian besar terdiri atas gas. Letak inti planetnya pun jauh di tengah. Planet ini memiliki bintik merah yang ternyata merupakan badai raksasa.";
                }

                if (name == "saturnus")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/saturnus"); });
                    TextDescription.GetComponent <Text>().text = "Planet keenam dalam sistem tata surya adalah planet Saturnus. Saturnus terlihat memiliki cincin yang melingkari tubuhnya. Cincin tersebut terdiri atas lingkaran bebatuan, debu, dan es yang terperangkap dalam orbit mengelilingi planet tersebut.";
                }

                if (name == "uranus")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/uranus"); });
                    TextDescription.GetComponent <Text>().text = "Planet Uranus merupakan planet ketujuh dalam sistem tata surya. Planet Uranus berputar miring karena porosnya yang hampir sejajar dengan orbitnya.  Suhu planet ini sangat dingin, yaitu sekitar minus 212 derajat Celsius.";
                }

                if (name == "neptunus")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/neptunus"); });
                    TextDescription.GetComponent <Text>().text = "Planet yang berada di urutan paling jauh dari Matahari adalah planet Neptunus. Planet ini tampak berwarna biru gelap dari kejauhan dan tidak memiliki permukaan yang nyata. Sama halnya dengan Jupiter, Saturnus, dan Uranus, planet ini juga terdiri atas gumpalan gas.";
                }

                if (name == "matahari")
                {
                    ButtonAction.GetComponent <Button>().onClick.AddListener(delegate { playSound("sounds/matahari"); });
                    TextDescription.GetComponent <Text>().text = "Matahari adalah sebuah bintang raksasa yang sangat panas seperti bola pijar. Matahari merupakan pusat tata surya  yang dikelilingi benda langit lainnya. Suhu di permukaannya hampir 6000 derajat Celsius. Suhu inti Matahari mencapai 15.000.000 derajat Celsius. Percikan panasnya dapat membakar segala sesuatu hingga 97 kilometer.  Namun, Matahari hanya tergolong bintang sedang. Masih banyak bintang besar yang jauh lebih besar dan lebih panas dari matahari.";
                }
            }
        }
 /// <summary>
 /// Takes a given GameObject to add a new ImageTargetBehaviour to. This new Behaviour is associated with the given ImageTarget
 /// </summary>
 public ImageTargetBehaviour FindOrCreateImageTargetBehaviourForTrackable(ImageTarget trackable, GameObject gameObject)
 {
     return(FindOrCreateImageTargetBehaviourForTrackable(trackable, gameObject, null));
 }
Exemplo n.º 21
0
        // Update is called once per frame
        void Update()
        {
            ////Panelmain.gameObject.SetActive (false);
            StateManager sm = TrackerManager.Instance.GetStateManager();
            IEnumerable <TrackableBehaviour> tbs = sm.GetActiveTrackableBehaviours();

            Panelmain.gameObject.SetActive(false);
            Panelmain2.gameObject.SetActive(false);

            foreach (TrackableBehaviour tb in tbs)
            {
                string      name = tb.TrackableName;
                ImageTarget it   = tb.Trackable as ImageTarget;
                Vector2     size = it.GetSize();

                Debug.Log("Active image target:" + name + "  -size: " + size.x + ", " + size.y);

                //Evertime the target found it will show “name of target” on the TextTargetName. Button, Description and Panel will visible (active)

                TextTargetName.GetComponent <Text>().text = name;
                //				ButtonAction.gameObject.SetActive(true);
                //				TextDescription.gameObject.SetActive(true);
                //				PanelDescription.gameObject.SetActive(true);



                //If the target name was “zombie” then add listener to ButtonAction with location of the zombie sound (locate in Resources/sounds folder) and set text on TextDescription a description of the zombie
                if (name == "reff")
                {
                    //ButtonAction.GetComponent<Button>().onClick.AddListener(delegate { playSound("sounds/ZombieLongDeath"); });
                    //                  Vector3 targetPosition = TextTargetName.TransformPoint(new Vector3(0, 5, -10));
                    //                  transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
                    TextTargetName.GetComponent <Text>().text = "";//Microwave Cost usage: 2AED/hour
                    Panelmain2.gameObject.SetActive(true);
                }
                if (name == "mic")
                {
                    //ButtonAction.GetComponent<Button>().onClick.AddListener(delegate { playSound("sounds/ZombieLongDeath"); });
                    //					Vector3 targetPosition = TextTargetName.TransformPoint(new Vector3(0, 5, -10));
                    //					transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
                    TextTargetName.GetComponent <Text>().text = "";//Microwave Cost usage: 2AED/hour
                    Panelmain.gameObject.SetActive(true);
                }
                //				while (name == "IMG_20170510_123436_01") {
                //					//Panelmane().active = true;
                //					Panelmane.gameObject.SetActive (true);
                //
                //				}


                ////	if(name == "blenderr"){
                //ButtonAction.GetComponent<Button>().onClick.AddListener(delegate { playSound("sounds/ZombieLongDeath"); });
                //		Vector3 targetPosition = TextTargetName.TransformPoint(new Vector3(0, 5, -10));
                //					transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, 2);



                ////		TextTargetName.GetComponent<Text>().text = "Blender Cost usage: 0.5AED/hour";
                ///	}



                //If the target name was “unitychan” then add listener to ButtonAction with location of the unitychan sound (locate in Resources/sounds folder) and set text on TextDescription a description of the unitychan / robot

                //				if (name == "unitychan")
                //				{
                //					ButtonAction.GetComponent<Button>().onClick.AddListener(delegate { playSound("sounds/HelloBabyGirl"); });
                //					TextDescription.GetComponent<Text>().text = "A robot is a mechanical or virtual artificial agent, usually an electromechanical machine that is guided by a computer program or electronic circuitry, and thus a type of an embedded system.";
                //				}
            }
        }
Exemplo n.º 22
0
    //获取该target下的所有用户及视频信息
    //POST /videos/cloud/targetId/{targetId}/memberCode/{memberCode} 2018-01-22-用户查看云识别时光轴
    IEnumerator LoadImageTarget(ImageTarget target, System.Action <ImageTarget, VideoTargetDate> handle)
    {
        /*自动获取手机的信息
         * System.Collections.Generic.Dictionary<string, string> headers = new System.Collections.Generic.Dictionary<string, string>();
         *
         * headers.Add("Content-Type", "application/json");
         *
         *
         * JsonData data = new JsonData();
         * data["phone"] = "13816848999";
         * data["targetId"] = "920df90c-dbb4-41bf-ab70-b2bc14c189c1";
         * data["token"] = "";
         * byte[] bs = System.Text.UTF8Encoding.UTF8.GetBytes(data.ToJson());
         *
         * //WWW www = new WWW("http://106.14.60.213:8080/business/AR/cloud", bs, headers);
         *
         * //headers.Add("token", App.MgrConfig._token);
         */
        WWWForm wwwForm = new WWWForm();

        wwwForm.AddField("phone", App.MgrConfig._phone);
        wwwForm.AddField("targetId", target.Uid);
        wwwForm.AddField("token", "");
        byte[] rawData = wwwForm.data;
        WWW    www     = new WWW(App.MgrConfig._Server + "AR/cloud", wwwForm);

/*
 *      Dictionary<string, string> headers = new Dictionary<string, string>();
 *      headers.Add("Content-Type", "application/json");
 *      JsonData jsonData = new JsonData();
 *      jsonData["phone"] = App.MgrConfig._phone;
 *      jsonData["targetId"] = target.Uid;
 *      Debug.Log(jsonData.ToJson());
 *      //byte[] bs = System.Text.UTF8Encoding.UTF8.GetBytes(data.ToJson());
 *      byte[] bs = System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson());
 *
 *      WWW www = new WWW(App.MgrConfig._Server +"AR/cloud",bs,headers);
 */
        yield return(www);

        string m_info = string.Empty;

        if (www.error != null)
        {
            m_info = www.error;
            yield return(null);
        }
        if (www.isDone && www.error == null)
        {
            m_info = www.text.ToString();
            yield return(m_info);

            Debug.Log(m_info);
            JsonData jd = JsonMapper.ToObject(m_info);
            string   id = jd["data"]["id"].ToString();
            jd = jd["data"]["timeLineVideoList"];
            if (jd == null)
            {
                Destroy(GameObject.Find(target.Uid));
                yield break;
            }
            //Debug.Log (jd.ToString ());
            byte[] bytes = Convert.FromBase64String(target.MetaData);
            string s     = System.Text.Encoding.GetEncoding("utf-8").GetString(bytes);

            VideoTargetDate data = new VideoTargetDate(target.Uid, s, id, "");


            for (int i = 0; i < jd.Count; i++)
            {
                VideoTargetCell cell = new VideoTargetCell(
                    jd [i] ["createDate"].ToString(),
                    jd [i] ["user"]["nickName"].ToString(),
                    jd [i] ["timeVideoSrc"].ToString(),
                    jd [i] ["user"]["userLogo"].ToString(),
                    jd [i] ["user"]["id"].ToString(),
                    jd [i] ["user"]["isFriend"].ValueAsBoolean(),
                    jd[i]["isVertical"].ToString());
                data.videoList.Add(cell);
            }

            handle(target, data);
        }
    }
Exemplo n.º 23
0
    // Creates a new Image Target with the data of the Image Target with the
    // given name.
    // Returns false if Image Target does not exist.
    public bool GetImageTarget(string name, out ImageTarget it)
    {
        try
        {
            it = imageTargets[name];
        }
        catch(KeyNotFoundException)
        {
            it = new ImageTarget();
            return false;
        }
        catch(Exception e)
        {
            throw e;
        }

        return true;
    }
Exemplo n.º 24
0
 public void Load(ImageTarget target, System.Action <ImageTarget, VideoTargetDate> handle)
 {
     StartCoroutine(LoadImageTarget(target, handle));
 }
 /// <summary>
 /// This method disconnects the TrackableBehaviour from it's associated trackable.
 /// Use it only if you know what you are doing - e.g. when you want to destroy a trackable, but reuse the TrackableBehaviour.
 /// </summary>
 protected override void InternalUnregisterTrackable()
 {
     mTrackable = mImageTarget = null;
 }
Exemplo n.º 26
0
 internal ImageTargetAbstractBehaviour FindOrCreateImageTargetBehaviourForTrackable(ImageTarget trackable, GameObject gameObject)
 {
     return(this.FindOrCreateImageTargetBehaviourForTrackable(trackable, gameObject, null));
 }
Exemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        private void ScaleImage(MagickGeometry geomatry = null, bool?source = null)
        {
            try
            {
                var action = false;

                var image_s = ImageSource.GetInformation();
                var image_t = ImageTarget.GetInformation();
                if (source == null)
                {
                    if (geomatry is MagickGeometry)
                    {
                        if (image_s.ValidCurrent)
                        {
                            image_s.Current.Resize(geomatry); image_s.Current.RePage(); action = true;
                        }
                        if (image_t.ValidCurrent)
                        {
                            image_t.Current.Resize(geomatry); image_t.Current.RePage(); action = true;
                        }
                    }
                    else
                    {
                        action |= image_s.Reload();
                        action |= image_t.Reload();
                    }
                }
                else if (source ?? false)
                {
                    if (geomatry is MagickGeometry)
                    {
                        if (image_s.ValidCurrent)
                        {
                            image_s.Current.Resize(geomatry); image_s.Current.RePage(); action = true;
                        }
                    }
                    else
                    {
                        action |= image_s.Reload();
                    }
                }
                else
                {
                    if (geomatry is MagickGeometry)
                    {
                        if (image_t.ValidCurrent)
                        {
                            image_t.Current.Resize(geomatry); image_t.Current.RePage(); action = true;
                        }
                    }
                    else
                    {
                        action |= image_t.Reload();
                    }
                }

                if (action)
                {
                    UpdateImageViewer(compose: LastOpIsCompose, assign: true, reload: false);
                }
            }
            catch (Exception ex) { ex.ShowMessage(); }
        }
Exemplo n.º 28
0
        internal ImageTargetAbstractBehaviour FindOrCreateImageTargetBehaviourForTrackable(ImageTarget trackable, GameObject gameObject, DataSet dataSet)
        {
            DataSetTrackableBehaviour dataSetTrackableBehaviour = gameObject.GetComponent <DataSetTrackableBehaviour>();

            if (dataSetTrackableBehaviour == null)
            {
                dataSetTrackableBehaviour = BehaviourComponentFactory.Instance.AddImageTargetBehaviour(gameObject);
            }
            if (!(dataSetTrackableBehaviour is ImageTargetAbstractBehaviour))
            {
                Debug.LogError(string.Format("DataSet.CreateTrackable: Trackable of type ImageTarget was created, but behaviour of type {0} was provided!", dataSetTrackableBehaviour.GetType()));
                return(null);
            }
            dataSetTrackableBehaviour.InitializeTarget(trackable, false);
            this.mTrackableBehaviours[trackable.ID] = dataSetTrackableBehaviour;
            return(dataSetTrackableBehaviour as ImageTargetAbstractBehaviour);
        }
Exemplo n.º 29
0
        /// <summary>
        /// tweens an Images color property
        /// </summary>
        /// <returns>The kcolor to.</returns>
        /// <param name="self">Self.</param>
        /// <param name="to">To.</param>
        /// <param name="duration">Duration.</param>
        public static ITween<Color> ZKcolorTo( this Image self, Color to, float duration = 0.3f )
        {
            var tweenTarget = new ImageTarget( self, ImageTarget.ImageTargetType.Alpha );
            var tween = ColorTween.create();
            tween.initialize( tweenTarget, self.color, to, duration );

            return tween;
        }
        /// <summary>
        /// Loads the image into given Image using defined parameters.
        /// </summary>
        /// <param name="parameters">Parameters for loading the image.</param>
        /// <param name="imageView">Image view that should receive the image.</param>
        public static IScheduledWork Into(this TaskParameter parameters, Image imageView)
        {
            var target = new ImageTarget(imageView);

            return(parameters.Into <Image>(target));
        }
Exemplo n.º 31
0
        static void DrawGizmo(ImageTargetController scr, GizmoType gizmoType)
        {
            var signature = scr.SourceType.ToString();

            switch (scr.SourceType)
            {
            case ImageTargetController.DataSource.ImageFile:
                if (EasyARController.Settings && !EasyARController.Settings.GizmoConfig.ImageTarget.EnableImageFile)
                {
                    return;
                }
                signature += scr.ImageFileSource.PathType.ToString() + scr.ImageFileSource.Path;
                break;

            case ImageTargetController.DataSource.TargetDataFile:
                if (EasyARController.Settings && !EasyARController.Settings.GizmoConfig.ImageTarget.EnableTargetDataFile)
                {
                    return;
                }
                signature += scr.TargetDataFileSource.PathType.ToString() + scr.TargetDataFileSource.Path;
                break;

            case ImageTargetController.DataSource.Target:
                if (EasyARController.Settings && !EasyARController.Settings.GizmoConfig.ImageTarget.EnableTarget)
                {
                    return;
                }
                if (scr.Target != null)
                {
                    signature += scr.Target.runtimeID().ToString();
                }
                break;

            default:
                break;
            }

            if (scr.GizmoData.Material == null)
            {
                scr.GizmoData.Material = new Material(Shader.Find("EasyAR/ImageTargetGizmo"));
            }
            if (scr.GizmoData.Signature != signature)
            {
                if (scr.GizmoData.Texture != null)
                {
                    UnityEngine.Object.DestroyImmediate(scr.GizmoData.Texture);
                    scr.GizmoData.Texture = null;
                }

                string path;
                switch (scr.SourceType)
                {
                case ImageTargetController.DataSource.ImageFile:
                    path = scr.ImageFileSource.Path;
                    if (scr.ImageFileSource.PathType == PathType.StreamingAssets)
                    {
                        path = Application.streamingAssetsPath + "/" + scr.ImageFileSource.Path;
                    }
                    if (System.IO.File.Exists(path))
                    {
                        var sourceData = System.IO.File.ReadAllBytes(path);
                        scr.GizmoData.Texture = new Texture2D(2, 2);
                        scr.GizmoData.Texture.LoadImage(sourceData);
                        scr.GizmoData.Texture.Apply();
                        UpdateScale(scr, scr.ImageFileSource.Scale);
                        if (SceneView.lastActiveSceneView)
                        {
                            SceneView.lastActiveSceneView.Repaint();
                        }
                    }
                    break;

                case ImageTargetController.DataSource.TargetDataFile:
                    path = scr.TargetDataFileSource.Path;
                    if (scr.TargetDataFileSource.PathType == PathType.StreamingAssets)
                    {
                        path = Application.streamingAssetsPath + "/" + scr.TargetDataFileSource.Path;
                    }
                    if (System.IO.File.Exists(path))
                    {
                        if (!EasyARController.Initialized)
                        {
                            EasyARController.GlobalInitialization();
                            if (!EasyARController.Initialized)
                            {
                                Debug.LogWarning("EasyAR Sense target data gizmo enabled but license key validation failed, target data gizmo will not show");
                            }
                        }
                        var sourceData = System.IO.File.ReadAllBytes(path);

                        using (Buffer buffer = Buffer.wrapByteArray(sourceData))
                        {
                            var targetOptional = ImageTarget.createFromTargetData(buffer);
                            if (targetOptional.OnSome)
                            {
                                using (ImageTarget target = targetOptional.Value)
                                {
                                    var imageList = target.images();
                                    if (imageList.Count > 0)
                                    {
                                        var image = imageList[0];
                                        scr.GizmoData.Texture = new Texture2D(image.width(), image.height(), TextureFormat.R8, false);
                                        scr.GizmoData.Texture.LoadRawTextureData(image.buffer().data(), image.buffer().size());
                                        scr.GizmoData.Texture.Apply();
                                    }
                                    foreach (var image in imageList)
                                    {
                                        image.Dispose();
                                    }
                                    UpdateScale(scr, target.scale());
                                    if (SceneView.lastActiveSceneView)
                                    {
                                        SceneView.lastActiveSceneView.Repaint();
                                    }
                                }
                            }
                        }
                    }
                    break;

                case ImageTargetController.DataSource.Target:
                    if (scr.Target != null)
                    {
                        var imageList = (scr.Target as ImageTarget).images();
                        if (imageList.Count > 0)
                        {
                            var image = imageList[0];
                            scr.GizmoData.Texture = new Texture2D(image.width(), image.height(), TextureFormat.R8, false);
                            scr.GizmoData.Texture.LoadRawTextureData(image.buffer().data(), image.buffer().size());
                            scr.GizmoData.Texture.Apply();
                        }
                        foreach (var image in imageList)
                        {
                            image.Dispose();
                        }
                        UpdateScale(scr, (scr.Target as ImageTarget).scale());
                        if (SceneView.lastActiveSceneView)
                        {
                            SceneView.lastActiveSceneView.Repaint();
                        }
                    }
                    break;

                default:
                    break;
                }

                if (scr.GizmoData.Texture == null)
                {
                    scr.GizmoData.Texture = new Texture2D(2, 2);
                    scr.GizmoData.Texture.LoadImage(new byte[0]);
                    scr.GizmoData.Texture.Apply();
                }
                scr.GizmoData.Signature = signature;
            }

            if (scr.GizmoData.Material && scr.GizmoData.Texture)
            {
                scr.GizmoData.Material.SetMatrix("_Transform", scr.transform.localToWorldMatrix);
                if (scr.GizmoData.Texture.format == TextureFormat.R8)
                {
                    scr.GizmoData.Material.SetInt("_isRenderGrayTexture", 1);
                }
                else
                {
                    scr.GizmoData.Material.SetInt("_isRenderGrayTexture", 0);
                }
                scr.GizmoData.Material.SetFloat("_Ratio", (float)scr.GizmoData.Texture.height / scr.GizmoData.Texture.width);
                Gizmos.DrawGUITexture(new Rect(0, 0, 1, 1), scr.GizmoData.Texture, scr.GizmoData.Material);
            }
        }
 public bool SetInitializationTarget(ImageTarget imageTarget, Vector3 occluderMin, Vector3 occluderMax)
 {
     return(this.SetInitializationTarget(imageTarget, occluderMin, occluderMax, Vector3.zero, Quaternion.identity));
 }
Exemplo n.º 33
0
		/// <summary>
		/// tweens an Images color property
		/// </summary>
		/// <returns>The kcolor to.</returns>
		/// <param name="self">Self.</param>
		/// <param name="to">To.</param>
		/// <param name="duration">Duration.</param>
		public static ITween<Color> ZKcolorTo( this Image self, Color to, float duration = 0.3f )
		{
			var tweenTarget = new ImageTarget( self, ImageTarget.ImageTargetType.Alpha );
			var tween = ZestKit.cacheColorTweens ? QuickCache<ColorTween>.pop() : new ColorTween();
			tween.initialize( tweenTarget, self.color, to, duration );

			return tween;
		}
Exemplo n.º 34
0
 public void OnImageRecognized(ImageTarget target)
 {
     Renderer.IsEffectVisible = false;
 }
Exemplo n.º 35
0
 // Set attributes of the Image Target with the given name.
 // If the Image Target does not yet exist it is created automatically.
 public void SetImageTarget(ImageTarget item, string name)
 {
     imageTargets[name] = item;
 }
Exemplo n.º 36
0
 public void OnImageLost(ImageTarget target)
 {
     Renderer.IsEffectVisible = true;
 }
Exemplo n.º 37
0
 /// <summary>
 /// This method disconnects the TrackableBehaviour from it's associated trackable.
 /// Use it only if you know what you are doing - e.g. when you want to destroy a trackable, but reuse the TrackableBehaviour.
 /// </summary>
 protected override void InternalUnregisterTrackable()
 {
     mTrackable = mImageTarget = null;
 }
Exemplo n.º 38
0
 public void OnTrackingLost(ImageTarget imgTarget)
 {
     isTracking = false;
     SendToEditor(MiraConnectionMessageIds.trackingLostMsgId, true);
 }
Exemplo n.º 39
0
 /// <summary>
 /// Takes a given GameObject to add a new ImageTargetBehaviour to. This new Behaviour is associated with the given ImageTarget
 /// </summary>
 public ImageTargetBehaviour FindOrCreateImageTargetBehaviourForTrackable(ImageTarget trackable, GameObject gameObject)
 {
     return FindOrCreateImageTargetBehaviourForTrackable(trackable, gameObject, null);
 }
    private IEnumerator LoadImageTarget()
    {
        var path = TargetPath;
        var type = Type;
        WWW www;

        if (type == PathType.Absolute)
        {
            path = Utility.AddFileHeader(path);
#if UNITY_ANDROID && !UNITY_EDITOR
            path = "file://" + path;
#endif
        }
        else if (type == PathType.StreamingAssets)
        {
            path = Utility.AddFileHeader(Application.streamingAssetsPath + "/" + path);
        }
        Debug.Log("[EasyAR]:" + path);
        www = new WWW(path);
        while (!www.isDone)
        {
            yield return(0);
        }
        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(www.error);
            www.Dispose();
            yield break;
        }
        var           data   = www.bytes;
        easyar.Buffer buffer = easyar.Buffer.create(data.Length);
        var           ptr    = buffer.data();
        Marshal.Copy(data, 0, ptr, data.Length);

        Optional <easyar.ImageTarget> op_target;
        if (targetType == TargetType.LocalImage)
        {
            var image = ImageHelper.decode(buffer);
            if (!image.OnSome)
            {
                throw new System.Exception("decode image file data failed");
            }

            var p = new ImageTargetParameters();
            p.setImage(image.Value);
            p.setName(TargetName);
            p.setScale(TargetSize);
            p.setUid("");
            p.setMeta("");
            op_target = ImageTarget.createFromParameters(p);

            if (!op_target.OnSome)
            {
                throw new System.Exception("create image target failed from image target parameters");
            }

            image.Value.Dispose();
            buffer.Dispose();
            p.Dispose();
        }
        else
        {
            op_target = ImageTarget.createFromTargetData(buffer);

            if (!op_target.OnSome)
            {
                throw new System.Exception("create image target failed from image target target data");
            }

            buffer.Dispose();
        }

        target = op_target.Value;
        Destroy(www.texture);
        www.Dispose();
        if (ImageTracker == null)
        {
            yield break;
        }
        ImageTracker.LoadImageTarget(this, (_target, status) =>
        {
            targetImage = ((_target as ImageTarget).images())[0];
            Debug.Log("[EasyAR] Targtet name: " + _target.name() + " target runtimeID: " + _target.runtimeID() + " load status: " + status);
            Debug.Log("[EasyAR] Target size" + targetImage.width() + " " + targetImage.height());
        });
    }
Exemplo n.º 41
0
    private ImageTargetBehaviour CreateImageTargetBehaviour(ImageTarget imageTarget)
    {
        GameObject imageTargetObject = new GameObject();
        ImageTargetBehaviour newITB =
            imageTargetObject.AddComponent<ImageTargetBehaviour>();

        IEditorImageTargetBehaviour newEditorITB = newITB;

        Debug.Log("Creating Image Target with values: " +
                  "\n ID:           " + imageTarget.ID +
                  "\n Name:         " + imageTarget.Name +
                  "\n Path:         " + newEditorITB.DataSetPath +
                  "\n Size:         " + imageTarget.GetSize().x + "x" + imageTarget.GetSize().y);

        // Set Image Target attributes.
        newEditorITB.SetNameForTrackable(imageTarget.Name);
        newEditorITB.SetDataSetPath(newEditorITB.DataSetPath);
        newEditorITB.transform.localScale = new Vector3(imageTarget.GetSize().x, 1.0f, imageTarget.GetSize().y);
        newEditorITB.CorrectScale();
        newEditorITB.SetAspectRatio(imageTarget.GetSize()[1] / imageTarget.GetSize()[0]);
        newEditorITB.InitializeImageTarget(imageTarget);

        return newITB;
    }
 public void OnImageRecognized(ImageTarget target)
 {
     Invoke("CheckSpelling", 0.1f);
 }