コード例 #1
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            var experience = ArExperience.Deserialize(Arguments.GetByteArray(IntentExtrasKeyExperienceData));

            var arExperiencePath = experience.Path;

            var config = new ArchitectStartupConfiguration
            {
                LicenseKey       = GetString(Resource.String.wikitude_license_key),
                CameraPosition   = Util.PlatformConverter.ConvertSharedToPlatformPosition(experience.CameraPosition),
                CameraResolution = Util.PlatformConverter.ConvertSharedToPlatformResolution(experience.CameraResolution),
                CameraFocusMode  = Util.PlatformConverter.ConvertSharedToPlatformFocusMode(experience.CameraFocusMode),
                Camera2Enabled   = experience.Camera2Enabled,
                ArFeatures       = (int)experience.FeaturesMask
            };

            architectView.OnCreate(config);
            architectView.OnPostCreate();

            architectView.Load(arExperiencePath);
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Activity_url_launcher);

            var experienceBytes = Intent.GetByteArrayExtra(SimpleArFragment.IntentExtrasKeyExperienceData);
            var experience      = ArExperience.Deserialize(experienceBytes);

            fragment = (experience.FeaturesMask & Features.Geo) == Features.Geo ? new SimpleGeoFragment() : new SimpleArFragment();

            var args = new Bundle();

            args.PutByteArray(SimpleArFragment.IntentExtrasKeyExperienceData, experienceBytes);
            fragment.Arguments = args;

            var fragmentTransaction = SupportFragmentManager.BeginTransaction();

            fragmentTransaction.Replace(Resource.Id.mainFragement, fragment);
            fragmentTransaction.Commit();

            // Prevent device from sleeping
            Window.AddFlags(flags: WindowManagerFlags.KeepScreenOn);
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            /*
             * Used to enabled remote debugging of the ArExperience with
             * google chrome https://developers.google.com/web/tools/chrome-devtools/remote-debugging
             */
            WebView.SetWebContentsDebuggingEnabled(true);


            if (!Intent.HasExtra(IntentExtrasKeyExperienceData))
            {
                var message = GetString(Resource.String.error_loading_ar_experience_invalid_intent, Class.SimpleName, IntentExtrasKeyExperienceData);
                throw new System.Exception(message);
            }

            /*
             * The following code is used to run different configurations of the SimpleArActivity.
             * It is not required to use the ArchitectView but is used to simplify the example app.
             *
             * Because of this the Activity has to be startet with correct intent extras.
             * e.g.:
             * var experience = new ArExperience(
             *      "ExperienceName",
             *      "ExperiencePath",
             *      Features.ImageTracking | Features.Geo,
             *      CameraPosition.Back,
             *      CameraResolution.Auto,
             *      CameraFocusMode.Continuous,
             *      camera2Enabled: true
             * );
             *
             * var intent = new Intent(this, typeof(SimpleArActivity));
             * intent.PutExtra(SimpleArActivity.IntentExtrasKeyExperienceData, ArExperience.Serialize(lastExperience));
             * StartActivity(intent);
             */
            var experience = ArExperience.Deserialize(Intent.GetByteArrayExtra(IntentExtrasKeyExperienceData));

            arExperiencePath = experience.Path;

            /*
             * The ArchitectStartupConfiguration is a required parameter for architectView.OnCreate.
             * It controls the startup of the ArchitectView which includes camera settings,
             * the required device features to run the ArchitectView and the LicenseKey which
             * has to be set to enable an AR-Experience.
             */
            var config = new ArchitectStartupConfiguration                                                                // Creates a config with its default values.
            {
                LicenseKey       = GetString(Resource.String.wikitude_license_key),                                       // Has to be set, to get a trial license key visit http://www.wikitude.com/developer/licenses.
                CameraPosition   = Util.PlatformConverter.ConvertSharedToPlatformPosition(experience.CameraPosition),     // The default camera is the first camera available for the system.
                CameraResolution = Util.PlatformConverter.ConvertSharedToPlatformResolution(experience.CameraResolution), // The default resolution is 640x480.
                CameraFocusMode  = Util.PlatformConverter.ConvertSharedToPlatformFocusMode(experience.CameraFocusMode),   // The default focus mode is continuous auto focus.
                Camera2Enabled   = experience.Camera2Enabled,                                                             // The camera2 api is enabled by default on devices that support it.
                ArFeatures       = (int)experience.FeaturesMask                                                           // This tells the ArchitectView which AR-features it is going to use, the default is all of them.
            };

            architectView = new ArchitectView(this);
            architectView.OnCreate(config); // Mandatory ArchitectView lifecycle call

            SetContentView(architectView);  // Adds the architectView to the activity.

            // Prevent device from sleeping
            Window.AddFlags(flags: WindowManagerFlags.KeepScreenOn);
        }