Beispiel #1
0
        private ActsAsGlobalOrigin.AnchorResult resultFailFrom(ActsAsGlobalOrigin.AnchorAttempt attempt)
        {
            switch (attempt)
            {
            case AnchorAttempt.Primary:
                return(ActsAsGlobalOrigin.AnchorResult.PrimaryFail);

            case AnchorAttempt.Secondary:
                return(ActsAsGlobalOrigin.AnchorResult.SecondaryFail);

            case AnchorAttempt.Backup:
                return(ActsAsGlobalOrigin.AnchorResult.BackupFail);
            }
            return(ActsAsGlobalOrigin.AnchorResult.GeneralFail);
        }
Beispiel #2
0
        private ActsAsGlobalOrigin.AnchorResult resultSuccessFrom(ActsAsGlobalOrigin.AnchorAttempt attempt)
        {
            switch (attempt)
            {
            case AnchorAttempt.Primary:
                return(ActsAsGlobalOrigin.AnchorResult.PrimarySuccess);

            case AnchorAttempt.Secondary:
                return(ActsAsGlobalOrigin.AnchorResult.SecondarySuccess);

            case AnchorAttempt.Backup:
                return(ActsAsGlobalOrigin.AnchorResult.BackupSuccess);
            }
            return(ActsAsGlobalOrigin.AnchorResult.GeneralSuccess);
        }
Beispiel #3
0
        private ActsAsGlobalOrigin.AnchorResult anchorToClosestPCF(ActsAsGlobalOrigin.AnchorAttempt anchorAttempt, MLPersistentCoordinateFrames.PCF.Types type)
        {
            if (MLPersistentCoordinateFrames.IsLocalized == false)
            {
                print("Localized map must first be created before finding a PCF");
                return(ActsAsGlobalOrigin.AnchorResult.GeneralFail);
            }

            MLResult resultFindClosestSecondaryPCFType = MLPersistentCoordinateFrames.FindClosestPCF(transform.position, out MLPersistentCoordinateFrames.PCF closestPCF, type);

            switch (resultFindClosestSecondaryPCFType.Result)
            {
            case MLResult.Code.Ok:
            {
                if (closestPCF == null)
                {
                    return(resultFailFrom(anchorAttempt));
                }
                else
                {
                    ///
                    /// Bind this GameObject's transform to the PCF
                    ///
                    this.transformBinding = new TransformBinding(this.GetInstanceID().ToString(), "ActsAsGlobalOrigin");
                    if (this.transformBinding == null)
                    {
                        return(resultFailFrom(anchorAttempt));
                    }

                    if (this.transformBinding.Bind(closestPCF, transform))
                    {
                        closestPCF.AddBinding(this);
                        this.pcf = closestPCF;

                        print("Added Binding");

                        return(resultSuccessFrom(anchorAttempt));
                    }
                    else
                    {
                        return(resultFailFrom(anchorAttempt));
                    }
                }
            }

            case MLResult.Code.InvalidParam:
                throw new System.NotImplementedException();

            case MLResult.Code.PrivilegeDenied:
                throw new System.NotImplementedException();

            case MLResult.Code.UnspecifiedFailure:
                print("UnspecifiedFailure");
                return(ActsAsGlobalOrigin.AnchorResult.GeneralFail);

            case MLResult.Code.PassableWorldLowMapQuality:
                print("PassableWorldLowMapQuality - quality of the room map is too low, re-map room");
                return(ActsAsGlobalOrigin.AnchorResult.PassableWorldLowMapQuality);

            case MLResult.Code.PassableWorldUnableToLocalize:
                print("PassableWorldUnableToLocalize - room layout has changed, re-map room or adjust lighting");
                return(ActsAsGlobalOrigin.AnchorResult.PassableWorldUnableToLocalize);
            }
            return(ActsAsGlobalOrigin.AnchorResult.GeneralFail);
        }