Пример #1
0
    protected float[] sortNearDistance(Collider[] cs, ref TargetFinder finder)
    {
        var sqrDists = new float[cs.Length];

        var myCenter = finder.tfSensor.position;


        for (var i = 0; i < cs.Length; i++)
        {
            var rbOhter = cs[i].attachedRigidbody;


            if (rbOhter != finder.owner.rb)
            {
                var otherCenter = rbOhter.GetComponent <_Action3>().tfObservedCenter.position;

                sqrDists[i] = (otherCenter - myCenter).sqrMagnitude;
            }
            else
            {
                sqrDists[i] = float.PositiveInfinity;
            }
        }


        System.Array.Sort(sqrDists, cs);


        return(sqrDists);
    }
    public override void OnHit(Collider col, Vector3 point, Vector3 dir)
    {
        base.OnHit(col, point, dir);
        if (chainIndex > 0)
        {
            TargetFinder finder = new TargetFinder();
            Transform    t      = finder.FindTarget(point, 5f, Game.game.enemyLayer, new Colour[1] {
                Colour.None
            }, new Colour[0], TargetFinder.SortType.Random);
            if (t)
            {
                Vector3    direction = (t.position - point).normalized;
                GameObject light     = (GameObject)Instantiate(chainLighting, point, Quaternion.identity);

                Quaternion      rotation = Quaternion.Euler(0f, 0f, Angle.CalculateAngle(transform.position, t.position));
                TeslaProjectile pro      = light.GetComponent <TeslaProjectile>();
                pro.velocity   = direction;
                pro.chainIndex = chainIndex - 1;
                pro.damage     = Mathf.RoundToInt((float)damage / 1.5f);
                pro.parent     = parent;
                pro.target     = t;
                pro.range      = 5f;

                pro.Initialize();
            }
        }
    }
Пример #3
0
    public override bool scan(ref TargetFinder finder, Collider[] cs)
    {
        //var sqrDists = base.sortNearDistance( cs, ref finder );
        base.shuffle(cs);          // むしろシャッフルで


        for (var i = 0; i < cs.Length; i++)
        {
            var irb = cs[i].attachedRigidbody;

            if (irb == finder.owner.rb)
            {
                continue;
            }


            var act = irb.GetComponent <_Hit3>().getAct();           //_Action3>();

            if (perceive(ref finder, act, scanRefreshTime))
            {
                return(true);
            }
        }

        return(false);
    }
Пример #4
0
    /// <summary>
    /// Handles new search results
    /// </summary>
    /// <param name="targetSearchResult"></param>
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
        // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(),
        // or to create a new ImageTargetBehaviour for each new result

        // Vuforia will return a new object with the right script automatically if you use
        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)

        //Check if the metadata isn't null
        if(targetSearchResult.MetaData == null)
        {
            return;
        }

        // First clear all trackables
        mObjectTracker.TargetFinder.ClearTrackables(false);

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mObjectTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate) as ImageTargetBehaviour;

        //if extended tracking was enabled from the menu, we need to start the extendedtracking on the newly found trackble.
        if(CloudRecognitionUIEventHandler.ExtendedTrackingIsEnabled)
        {
            imageTargetBehaviour.ImageTarget.StartExtendedTracking();
        }
    }
Пример #5
0
    //vuforia function
    public void OnInitialized(TargetFinder targetFinder)
    {
        Debug.Log("Cloud Reco initialized");

        enabledButton(true);
        GoWebsiteBtn.SetActive(false);
    }
Пример #6
0
    /// <summary>
    /// Handles new search results
    /// </summary>
    /// <param name="targetSearchResult"></param>
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
        // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(),
        // or to create a new ImageTargetBehaviour for each new result

        // Vuforia will return a new object with the right script automatically if you use
        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)

        //Check if the metadata isn't null
        if(targetSearchResult.MetaData == null)
        {
            return;
        }

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mObjectTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate) as ImageTargetBehaviour;

        if (imageTargetBehaviour != null)
        {
            string metadata1 = targetSearchResult.MetaData;
            Debug.Log("We got a target metadata: " + metadata1);

            // stop the target finder
            mCloudRecoBehaviour.CloudRecoEnabled = false;

            // Calls the TargetCreated Method of the SceneManager object to start loading
            // the BookData from the JSON
            mContentManager.TargetCreated(targetSearchResult.MetaData);
            mContentManager.AnimationsManager.SetInitialAnimationFlags();
        }
    }
 protected void Awake()
 {
     initalizeSelfAgent();
     m_navMeshAgent = this.GetComponent <NavMeshAgent>();
     m_targetFinder = new TargetFinder(this.name, this.transform.position, GameObject.Find("TargetIndicator"));
     m_healthBar    = this.GetComponentInChildren <HealthBar>();
 }
Пример #8
0
 /// <summary>
 ///     <para>
 ///         Loads the entity or entities referenced by this navigation property, unless <see cref="NavigationEntry.IsLoaded" />
 ///         is already set to true.
 ///     </para>
 ///     <para>
 ///         Note that entities that are already being tracked are not overwritten with new data from the database.
 ///     </para>
 /// </summary>
 public override void Load()
 {
     if (!IsLoaded)
     {
         TargetFinder.Load((INavigation)Metadata, InternalEntry);
     }
 }
Пример #9
0
    public void OnInitialized(TargetFinder targetFinder)
    {
        Debug.Log("Cloud Reco initialized successfully.");

        m_ObjectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
        m_TargetFinder  = targetFinder;
    }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     current_state = State.IDLE;
     agent = GetComponent<NavMeshAgent>();
     tf = reference.GetComponent<TargetFinder>();
     current_target = 0;
 }
Пример #11
0
 /// <summary>
 /// visualize update errors
 /// </summary>
 public void OnUpdateError(TargetFinder.UpdateState updateError)
 {
     /*switch (updateError)
     {
         case TargetFinder.UpdateState.UPDATE_ERROR_AUTHORIZATION_FAILED:
             ErrorMsg.New("Authorization Error","The cloud recognition service access keys are incorrect or have expired.");
             break;
         case TargetFinder.UpdateState.UPDATE_ERROR_BAD_FRAME_QUALITY:
             ErrorMsg.New("Poor Camera Image","The camera does not have enough detail, please try again later");
             break;
         case TargetFinder.UpdateState.UPDATE_ERROR_NO_NETWORK_CONNECTION:
             ErrorMsg.New("Network Unavailable","Please check your internet connection and try again.");
             break;
         case TargetFinder.UpdateState.UPDATE_ERROR_PROJECT_SUSPENDED:
             ErrorMsg.New("Authorization Error","The cloud recognition service has been suspended.");
             break;
         case TargetFinder.UpdateState.UPDATE_ERROR_REQUEST_TIMEOUT:
             ErrorMsg.New("Request Timeout","The network request has timed out, please check your internet connection and try again.");
             break;
         case TargetFinder.UpdateState.UPDATE_ERROR_SERVICE_NOT_AVAILABLE:
             ErrorMsg.New("Service Unavailable","The service is unavailable, please try again later.");
             break;
         case TargetFinder.UpdateState.UPDATE_ERROR_TIMESTAMP_OUT_OF_RANGE:
             ErrorMsg.New("Clock Sync Error","Please update the date and time and try again.");
             break;
         case TargetFinder.UpdateState.UPDATE_ERROR_UPDATE_SDK:
             ErrorMsg.New("Unsupported Version","The application is using an unsupported version of Vuforia.");
             break;
     }*/
 }
Пример #12
0
    public void OnInitialized(TargetFinder targetFinder)
    {
        message.text = "Cloud Reco Initialized Success!";

        objectTracker     = TrackerManager.Instance.GetTracker <ObjectTracker>();
        this.targetFinder = targetFinder;
    }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            Attempt.Action(
                () =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                var options = _package.Options;
                var source  = SolutionUtilities.GetSelectedFiles(_dte, false, options.GenerationOptions).FirstOrDefault(ProjectItemModel.IsSupported);
                if (source == null)
                {
                    throw new InvalidOperationException("Cannot go to tests for this item because no supported files were found");
                }

                var status = TargetFinder.FindExistingTargetItem(source, options.GenerationOptions, out var targetItem);
                switch (status)
                {
                case FindTargetStatus.FileNotFound:
                case FindTargetStatus.FolderNotFound:
                    throw new InvalidOperationException("No unit tests were found for the selected file.");

                case FindTargetStatus.ProjectNotFound:
                    throw new InvalidOperationException("Cannot go to tests for this item because there is no project '" + source.TargetProjectName + "'");
                }

                VsProjectHelper.ActivateItem(targetItem);
            }, _package);
        }
    /// <summary>
    /// Awake is being used to initialize all the reference the class needs,
    /// and to bring it to an initial state.
    /// </summary>
    void Awake()
    {
        _timer  = 0f;
        _placed = false;
        _orginalProjectileMode   = true;
        _currentProjectile       = _projectiles[0];
        _currentProjectileDamage = _projectileDamages[0];
        _currentShootPace        = _projectilesShootPaces[0];
        _spawner      = GetComponentInChildren <ProjectileSpawner>();
        _targetFinder = GetComponentInChildren <TargetFinder>();
        _omc          = GetComponent <ObjectMaterialController>();
        _rotation     = GetComponentInChildren <Transform>();
        _transforms   = GetComponentsInChildren <Transform>();

        _damageMultiplier    = 1f;
        _shootPaceMultiplier = 1f;
        _collids             = false;

        level       = 1;
        sellValue   = costs / 2;
        upgradeCost = costs / 2;

        health = initialHealth;

        _omc.SetBaseMaterial(_placedMaterial);
        _spawner.SetProjectileSpeed(_projectileSpeed);
        _spawner.SetProjectileDamage(_currentProjectileDamage);
        _spawner.SetProjectile(_currentProjectile);
        SetLayerToPlaceMode();
    }
Пример #15
0
    public void OnInitialized(TargetFinder targetFinder)
    {
        Debug.Log("Cloud Reco initialized");
// Get reference to the object tracker
        targetFinderObj = targetFinder;
        objectTracker   = TrackerManager.Instance.GetTracker <ObjectTracker>();
    }
Пример #16
0
        public CompletionTargetMarker Analyze(ITreeNode targetNode)
        {
            var finder = new TargetFinder();

            ((ICSharpTreeNode)targetNode).Accept(finder);
            return(finder.Result);
        }
Пример #17
0
    private void Start()
    {
        _movementComponent = GetComponent <MovementComponent>();
        _attackComponent   = GetComponent <AttackComponent>();
        _targetFinder      = GetComponent <TargetFinder>();

        findTargetCondition = (newCandidate, selectedTarget) =>
        {
            var transformPos      = Map.Get2DPos(transform.position);
            var candidatePosition = Map.Get2DPos(newCandidate.transform.position);

            var newDistance      = Vector2.Distance(candidatePosition, transformPos);
            var selectedDistance = float.MaxValue;
            if (selectedTarget)
            {
                selectedDistance = Vector2.Distance(Map.Get2DPos(selectedTarget.transform.position), transformPos);
            }

            if (newDistance <= selectedDistance && newDistance <= _movementComponent.DistanceToCurrentTarget)
            {
                if (_movementComponent.TryToGetNavigablePositionFromTarget(newCandidate, out var pos))
                {
                    return(true);
                }
            }
            return(false);
        };
    }
    /// <summary>
    /// Handles new search results
    /// </summary>
    /// <param name="targetSearchResult"></param>
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
        // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(),
        // or to create a new ImageTargetBehaviour for each new result

        // Vuforia will return a new object with the right script automatically if you use
        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)
        string model_name =targetSearchResult.MetaData;
        //Check if the metadata isn't null
        if(targetSearchResult.MetaData == null)
        {
            return;
        }
        Debug.Log ("Metadata value is " + model_name);
        BundleURL = model_name;
        StartCoroutine(DownloadAndCache());
        // First clear all trackables
        mImageTracker.TargetFinder.ClearTrackables(false);

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate) as ImageTargetBehaviour;

        // ADD THIS TO STOP CLOUD SCAN
        CloudRecoBehaviour cloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
        cloudRecoBehaviour.enabled = false;

        //if extended tracking was enabled from the menu, we need to start the extendedtracking on the newly found trackble.
        if(CloudRecognitionUIEventHandler.ExtendedTrackingIsEnabled)
        {
            imageTargetBehaviour.ImageTarget.StartExtendedTracking();
        }
    }
Пример #19
0
    /// <summary>
    /// called when TargetFinder has been initialized successfully
    /// </summary>
    public void OnInitialized(TargetFinder targetFinder)
    {
        Debug.Log("ModelReco initialized.");

        // Keep a reference to the Target Finder
        mTargetFinder = targetFinder;
    }
Пример #20
0
 /// <summary>
 ///     <para>
 ///         Loads the entity or entities referenced by this navigation property, unless <see cref="IsLoaded" />
 ///         is already set to true.
 ///     </para>
 ///     <para>
 ///         Note that entities that are already being tracked are not overwritten with new data from the database.
 ///     </para>
 /// </summary>
 public virtual void Load()
 {
     if (!IsLoaded)
     {
         TargetFinder.Load(Metadata, InternalEntry);
     }
 }
    /// <summary>
    /// Called when TargetFinder has been initialized successfully
    /// </summary>
    public void OnInitialized(TargetFinder targetFinder)
    {
        Debug.Log("Cloud Reco initialized successfully.");

        // get a reference to the Object Tracker, remember it
        m_ObjectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>();
    }
Пример #22
0
    public void OnInitialized(TargetFinder targetFinder)
    {
        Debug.Log("Cloud Reco initialized");

        // get a reference to the Image Tracker, remember it
        // mImageTracker = (ObjectTracker)TrackerManager.Instance.GetTracker<ObjectTracker>();
    }
Пример #23
0
    /// <summary>
    /// visualize initialization errors
    /// </summary>
    public void OnInitError(TargetFinder.InitState initError)
    {
        // Reset target finder reference
        mTargetFinder = null;

        Debug.LogError("Model Reco init error: " + initError.ToString());
        ShowErrorMessageInUI(initError.ToString());
    }
Пример #24
0
 // Start is called before the first frame update
 void Start()
 {
     _line            = GetComponentInChildren <LineRenderer>();
     _targetFinder    = GetComponentInChildren <TargetFinder>();
     _line.startWidth = 0.2f;
     _line.endWidth   = 0.2f;
     _startPoint      = GetComponentInChildren <ProjectileSpawner>().transform;
 }
Пример #25
0
    /// <summary>
    /// Awake is being used to initialize all the reference the class needs,
    /// and to bring it to an initial state.
    /// </summary>
    void Awake()
    {
        base.Awake();
        _timer = 0f;

        _targetFinder = GetComponentInChildren <TargetFinder>();
        _targetFinder.ChangeMode(TargetFinder.TargetFinderMode.NearestEnemy);
        _lr = GetComponentInChildren <LineRenderer>();
    }
Пример #26
0
 void Update() //updates the hp each frame
 {
     count = 0;
     foreach (targetFinder TargetFinder in targetFinders)
     {
         TargetFinder.updateHp(Party.HPs[count]);
         count = count + 1;
     }
 }
Пример #27
0
 public BotBrain(GameObject owner)
 {
     Owner         = owner;
     _shooting     = new BulletBotShooting(this);
     _targetFinder = new TargetFinder(this);
     _parts.Add(_shooting);
     _parts.Add(_targetFinder);
     _enemyController = owner.GetComponent <EnemyController>();
 }
Пример #28
0
 public void Init(DataGame dataCities, Vector3 earth)
 {
     _earth          = earth;
     _targetFinder   = GetComponent <TargetFinder>();
     _rocketPrep     = GetComponent <RocketPrep>();
     _cityCondition  = GetComponent <CityCondition>();
     _dataCities     = dataCities;
     _flightAltitude = UnityEngine.Random.Range(5, 25);
 }
    public override void Start()
    {
        Transform t = gameObject.transform;

        start_position = new Vector3(t.position.x, t.position.y, t.position.z);
        targetfinder   = t.parent.GetComponent <TargetFinder>() as TargetFinder;
        tower_shooting = t.parent.GetComponent <TowerShooting>() as TowerShooting;

        life_time = 10 / tower_shooting.attacks_per_sec;
    }
Пример #30
0
        private static bool Save(XmlNode xGroupNode, TargetFinder targetFinder, string ID)
        {
            targetFinder.Id = "TF_" + ID;
            XmlNode xPatchAction = xGroupNode.InsertCompressedElement(SST.TargetFinder);

            xPatchAction.CreateAttribute(SST.PatchType, targetFinder.TargetFinderType.ToString());
            xPatchAction.CreateAttribute(SST.ID, targetFinder.Id);
            xPatchAction.CreateAttribute(SST.Name, targetFinder.Name);
            return(targetFinder.Save(xPatchAction));
        }
Пример #31
0
 void Start()
 {
     if (!isServer)
     {
         return;
     }
     combatHandler = this.GetComponent <CombatHandler>();
     combatHandler.targetChanged += targetChanged;
     targetFinder    = this.GetComponent <TargetFinder>();
     movementHandler = this.GetComponent <MovementHandler>();
 }
Пример #32
0
        private TargetFinder <IEntity> GetTargetFinder(float range, IWorldPosition origin, IEntity[] targets)
        {
            IWorldGenerator generator      = Substitute.For <IWorldGenerator>();
            var             monsterFactory = Substitute.For <IEntityFactory <IEntity> >();

            monsterFactory.GetActiveEntities().Returns(targets);
            generator.MapLength.Returns(100);
            var targetFinder = new TargetFinder <IEntity>(origin, range, generator, monsterFactory);

            return(targetFinder);
        }
Пример #33
0
        public bool isReach(float reach, ref TargetFinder finder)
        {
            if (!isExists)
            {
                return(false);
            }

            //var sqrDist = ( act.rb.position - finder.owner.rb.position ).sqrMagnitude;
            var sqrDist = (act.tfObservedCenter.position - finder.tfSensor.position).sqrMagnitude;

            return(sqrDist < reach * reach);
        }
Пример #34
0
 /// <summary>
 /// visualize initialization errors
 /// </summary>
 public void OnInitError(TargetFinder.InitState initError)
 {
     switch (initError)
     {
         case TargetFinder.InitState.INIT_ERROR_NO_NETWORK_CONNECTION:
             ErrorMsg.New("Network Unavailable", "Please check your internet connection and try again.", RestartApplication);
             break;
         case TargetFinder.InitState.INIT_ERROR_SERVICE_NOT_AVAILABLE:
             ErrorMsg.New("Service Unavailable", "Failed to initialize app because the service is not available.");
             break;
     }
 }
Пример #35
0
        private void AddFinder(TargetFinder finder, bool applyRefresh)
        {
            var fHolder = new EntryBlockHolder(finder, editorFactory, SwooshParent);
            int line    = glmFinder.AddLineFixed(fHolder.Height);

            glmFinder.AddElementFilling(line, fHolder, GlobalLayout.MinFill);
            if (applyRefresh)
            {
                ReloadPools();
                glmFinder.InvokeResize();
            }
        }
Пример #36
0
 /// <summary>
 /// visualize initialization errors
 /// </summary>
 public void OnInitError(TargetFinder.InitState initError)
 {
     switch (initError)
     {
         case TargetFinder.InitState.INIT_ERROR_NO_NETWORK_CONNECTION:
             //ErrorMsg.New("Network Unavailable", "Failed to initialize CloudReco because the device has no network connection.", LoadAboutScene);
             break;
         case TargetFinder.InitState.INIT_ERROR_SERVICE_NOT_AVAILABLE:
            // ErrorMsg.New("Service Unavailable", "Failed to initialize CloudReco because the service is not available.", LoadAboutScene);
             break;
     }
 }
Пример #37
0
 // Here we handle a cloud target recognition event
 public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
 {
     // do something with the target metadata
     mTargetMetadata = targetSearchResult.MetaData;
     // stop the target finder (i.e. stop scanning the cloud)
     mCloudRecoBehaviour.CloudRecoEnabled = false;
     // Build augmentation based on target
     if (ImageTargetTemplate) {
         // enable the new result with the same ImageTargetBehaviour:
         ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
         ImageTargetBehaviour imageTargetBehaviour = (ImageTargetBehaviour)tracker.TargetFinder.EnableTracking(targetSearchResult, ImageTargetTemplate.gameObject);
     }
 }
Пример #38
0
    private IEnumerator fire()
    {
        while (true)
        {
            yield return(new WaitForSeconds(1f / fireRate));

            var target = TargetFinder.FindTarget(transform, range * 1.2f);
            if (inRange(target, 1.0f) && visible(target) && Mathf.Abs(angleToTarget(target)) < maxAngle)
            {
                doFire(target);
            }
        }
    }
Пример #39
0
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        mTargetMetadata = targetSearchResult.MetaData;
        Debug.Log (targetSearchResult.TargetName);
        name = targetSearchResult.TargetName;
        fileName = fileName + targetSearchResult.TargetName.ToString() + ".obj";
        StartCoroutine (Load());

        fileName = "https://s3.amazonaws.com/hackny.springhurst/";
        mCloudRecoBehaviour.CloudRecoEnabled = false;

        if (ImageTargetTemplate) {
            ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
            ImageTargetBehaviour imageTargetBehaviour =
                (ImageTargetBehaviour)tracker.TargetFinder.EnableTracking(
                    targetSearchResult, ImageTargetTemplate.gameObject);
        }
    }
Пример #40
0
    /// <summary>
    /// Handles new search results
    /// </summary>
    /// <param name="targetSearchResult"></param>
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
        // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(),
        // or to create a new ImageTargetBehaviour for each new result

        // Vuforia will return a new object with the right script automatically if you use
        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)

        //Check if the metadata isn't null
        if(targetSearchResult.MetaData == null)
        {
            return;
        }

        // First clear all trackables
        mObjectTracker.TargetFinder.ClearTrackables(false);

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mObjectTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate) as ImageTargetBehaviour;

        //Check metadata:
        string modelName = targetSearchResult.MetaData;
        Debug.Log ("Found metadata " + modelName);

        //Insert code here to either
        //a) display the content if the metadata is an image, model, or video
        //b) create a text overlay if the metadata is just text

        //For now, let's just display the text. We'll find the textoverlay object and set its value
        TextMesh textOverlay = imageTargetBehaviour.gameObject.transform.Find ("TextOverlay").GetComponent<TextMesh>();
        textOverlay.text = modelName;

        //if extended tracking was enabled from the menu, we need to start the extendedtracking on the newly found trackble.
        if(CloudRecognitionUIEventHandler.ExtendedTrackingIsEnabled)
        {
            imageTargetBehaviour.ImageTarget.StartExtendedTracking();
        }
    }
    /// <summary>
    /// Handles new search results
    /// </summary>
    /// <param name="targetSearchResult"></param>
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        GameObject vcube = GameObject.Find("Cube");

        // This code demonstrates how to reuse an ImageTargetBehaviour for new search results and modifying it according to the metadata
        // Depending on your application, it can make more sense to duplicate the ImageTargetBehaviour using Instantiate(),
        // or to create a new ImageTargetBehaviour for each new result

        // Vuforia will return a new object with the right script automatically if you use
        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)
        string model_name = targetSearchResult.MetaData; //check it with

        //Check if the metadata isn't null
        if(targetSearchResult.MetaData == null)
        {
            return;
        }

        Debug.Log("Metadata value is " + model_name ); //check it with

        LoadJSONBookData(model_name);
        if(mBookData != null )
        {
            titleb = mBookData.BookTitle;
            BundleURL = mBookData.BookDetailUrl;
            Debug.Log("Title" + titleb);

            //mIsBookThumbRequested = true;
        }
        switch(titleb)

        {
        case "assetbundle":
            Debug.Log("call assetbundle loading fuction");
            //assetbundleloadfunction()
            //Handheld.PlayFullScreenMovie ("www.idigisolutions.com/ar/video1.ogg", Color.black, FullScreenMovieControlMode.CancelOnInput);
            //vplayer = GetComponent<importmovie>();
            //var xRenderer = transform.Find("Cube");

            //vcube.SetActive(false);
            //cube.SetActive(false);
            StartCoroutine(DownloadAndCache());
                break;
        case "video":
            Debug.Log("call video streaming function");
            //IVideoBackgroundEventHandler()
            //Handheld.PlayFullScreenMovie ("www.idigisolutions.com/ar/video1.ogg", Color.black, FullScreenMovieControlMode.CancelOnInput);
            //GameObject vcube = GameObject.Find("Cube");
            //vcube.SetActive(true);

            break;
        }
        //string booktitle =
        //Debug.Log(booktitle);

        // we have to check whether to go to assetbundle or to video
        /*if( int = video)
        {
            function(PlayMode video);
        }
        else{
            StartCoroutine(DownloadAndCache());
        }*/
        //StartCoroutine(DownloadAndCache());
        // First clear all trackables
        mImageTracker.TargetFinder.ClearTrackables(false);

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, mParentOfImageTargetTemplate) as ImageTargetBehaviour;

        //if extended tracking was enabled from the menu, we need to start the extendedtracking on the newly found trackble.
        if(CloudRecognitionUIEventHandler.ExtendedTrackingIsEnabled)
        {
            imageTargetBehaviour.ImageTarget.StartExtendedTracking();
        }
    }
Пример #42
0
 public bool HasApplicableTarget(TargetFinder findTarget)
 {
     if (patternType == ActionPattern.ActionPatternType.Action)
     {
         foreach (var entity in findTarget(target))
         {
             if (entity != null && entity.IsActionApplicable(type))
             {
                 return true;
             }
         }
         return false;
     }
     else if (patternType == ActionPatternType.Vector)
     {
         foreach (var entity in findTarget(target))
         {
             if (entity is FieldObject)
             {
                 return true;
             }
         }
         return false;
     }
     else if (patternType == ActionPattern.ActionPatternType.Projectile)
     {
         foreach (var entity in findTarget(E_Target.Self))
         {
             if (entity != null && entity is Automaton)
             {
                 return true;
             }
         }
         return false;
     }
     else if (patternType == ActionPattern.ActionPatternType.Delegate)
     {
         IEnumerable<IActionHandler> realFirers = findTarget(target);
         foreach (var entity in realFirers)
         {
             Automaton firer = entity as Automaton;
             if (firer != null)
             {
                 if (ActionPattern.Create(strValue).HasApplicableTarget(firer.FindTarget))
                 {
                     return true;
                 }
             }
         }
         return false;
     }
     else if (patternType == ActionPattern.ActionPatternType.Sequence)
     {
         return children[0].HasApplicableTarget(findTarget);
     }
     else if (patternType == ActionPattern.ActionPatternType.Exclusive)
     {
         foreach (var childAction in children)
         {
             if (childAction.HasApplicableTarget(findTarget))
             {
                 return true;
             }
         }
         return false;
     }
     return false;
 }
Пример #43
0
 public void OnInitError(TargetFinder.InitState initError)
 {
     Debug.Log ("Cloud Reco init error " + initError.ToString());
 }
    /// <summary>
    /// Updates the target to follow depending on the road.
    /// </summary>
    public void UpdateTarget()
    {
        GameObject lastGround = ground;
        ground = FindGround();
        if (ground)
        {
            bool groundChanged = ground != lastGround;

            if (groundChanged)
                targetFinder = CreateTargetFinder();
            else if (targetFinder != null)
                targetFinder.UpdateTarget();
        }
    }
Пример #45
0
 public void OnUpdateError(TargetFinder.UpdateState updateError)
 {
     Debug.Log ("Cloud Reco update error " + updateError.ToString());
 }
Пример #46
0
 public ImageTrackerImpl()
 {
     mImageTargetBuilder = new ImageTargetBuilderImpl();
     mTargetFinder = new TargetFinderImpl();
 }