Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.SetContentView(Resource.Layout.hand_activity_main);
            mTextView    = (TextView)FindViewById(Resource.Id.handTextView);
            mSurfaceView = (GLSurfaceView)FindViewById(Resource.Id.handSurfaceview);

            mDisplayRotationManager = new DisplayRotationManager(this);

            // Keep the OpenGL ES running context.
            mSurfaceView.PreserveEGLContextOnPause = true;

            // Set the OpenGLES version.
            mSurfaceView.SetEGLContextClientVersion(2);

            // Set the EGL configuration chooser, including for the
            // number of bits of the color buffer and the number of depth bits.
            mSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0);

            mHandRenderManager = new HandRenderManager(this);
            mHandRenderManager.SetDisplayRotationManager(mDisplayRotationManager);
            mHandRenderManager.SetTextView(mTextView);

            mSurfaceView.SetRenderer(mHandRenderManager);
            mSurfaceView.RenderMode = Android.Opengl.Rendermode.Continuously;
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);
            mSurfaceView           = FindViewById <GLSurfaceView>(Resource.Id.surfaceview);
            mDisplayRotationHelper = new DisplayRotationHelper(this);

            Java.Lang.Exception exception = null;
            string message = null;

            try {
                mSession = new Session(/*context=*/ this);
            } catch (UnavailableArcoreNotInstalledException e) {
                message   = "Please install ARCore";
                exception = e;
            } catch (UnavailableApkTooOldException e) {
                message   = "Please update ARCore";
                exception = e;
            } catch (UnavailableSdkTooOldException e) {
                message   = "Please update this app";
                exception = e;
            } catch (Java.Lang.Exception e) {
                exception = e;
                message   = "This device does not support AR";
            }

            if (message != null)
            {
                Toast.MakeText(this, message, ToastLength.Long).Show();
                return;
            }

            // Create default config, check is supported, create session from that config.
            var config = new Google.AR.Core.Config(mSession);

            if (!mSession.IsSupported(config))
            {
                Toast.MakeText(this, "This device does not support AR", ToastLength.Long).Show();
                Finish();
                return;
            }

            mGestureDetector = new Android.Views.GestureDetector(this, new SimpleTapGestureDetector {
                SingleTapUpHandler = (MotionEvent arg) => {
                    onSingleTap(arg);
                    return(true);
                },
                DownHandler = (MotionEvent arg) => true
            });

            mSurfaceView.SetOnTouchListener(this);

            // Set up renderer.
            mSurfaceView.PreserveEGLContextOnPause = true;
            mSurfaceView.SetEGLContextClientVersion(2);
            mSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0);             // Alpha used for plane blending.
            mSurfaceView.SetRenderer(this);
            mSurfaceView.RenderMode = Rendermode.Continuously;
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            BitmapCache.Context = TextureCache.Context = Instance = this;

            DisplayMetrics m = new DisplayMetrics();

            WindowManager.DefaultDisplay.GetMetrics(m);
            density = m.Density;

            try
            {
                version = PackageManager.GetPackageInfo(PackageName, 0).VersionName;
            }
            catch (PackageManager.NameNotFoundException)
            {
                version = "???";
            }

            VolumeControlStream = Stream.Music;

            view = new GLSurfaceView(this);
            view.SetEGLContextClientVersion(2);
            view.SetEGLConfigChooser(false);
            view.SetRenderer(this);
            view.SetOnTouchListener(this);
            SetContentView(view);
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);
            mSurfaceView = FindViewById <GLSurfaceView>(Resource.Id.surfaceview);

            mSession = new Session(/*context=*/ this);

            // Create default config, check is supported, create session from that config.
            mDefaultConfig = Google.AR.Core.Config.CreateDefaultConfig();
            if (!mSession.IsSupported(mDefaultConfig))
            {
                Toast.MakeText(this, "This device does not support AR", ToastLength.Long).Show();
                Finish();
                return;
            }

            mGestureDetector = new Android.Views.GestureDetector(this, new SimpleTapGestureDetector {
                SingleTapUpHandler = (MotionEvent arg) => {
                    onSingleTap(arg);
                    return(true);
                },
                DownHandler = (MotionEvent arg) => true
            });

            mSurfaceView.SetOnTouchListener(this);

            // Set up renderer.
            mSurfaceView.PreserveEGLContextOnPause = true;
            mSurfaceView.SetEGLContextClientVersion(2);
            mSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0);             // Alpha used for plane blending.
            mSurfaceView.SetRenderer(this);
            mSurfaceView.RenderMode = Rendermode.Continuously;
        }
Exemplo n.º 5
0
 private void SetupGlSurfaceView()
 {
     glSurfaceView = FindViewById <GLSurfaceView>(Resource.Id.surfaceview);
     glSurfaceView.PreserveEGLContextOnPause = true;
     glSurfaceView.SetEGLContextClientVersion(2);
     glSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0);
     glSurfaceView.SetOnTouchListener(this);
     glSurfaceView.SetRenderer(this);
 }
Exemplo n.º 6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            mGlSurfaceView = new GLSurfaceView(this);
            ActivityManager am = (ActivityManager)GetSystemService(Context.ActivityService);

            mGlSurfaceView.SetEGLContextClientVersion(2);
            mGlSurfaceView.SetEGLConfigChooser(true);
            var gr = new GameRenderer();

            mGlSurfaceView.SetRenderer(gr);
            SetContentView(mGlSurfaceView);
        }
Exemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            this.SetContentView(Resource.Layout.world_activity_main);

            this.mSurfaceView       = (GLSurfaceView)FindViewById(Resource.Id.surfaceview);
            mDisplayRotationManager = new DisplayRotationManager(this);
            InitGestureDetector();

            mSurfaceView.PreserveEGLContextOnPause = true;
            mSurfaceView.SetEGLContextClientVersion(OPENGLES_VERSION);

            // Set the EGL configuration chooser, including for the number of
            // bits of the color buffer and the number of depth bits.
            mSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0);

            mWorldRenderManager = new WorldRenderManager(this, this.ApplicationContext);
            mWorldRenderManager.SetDisplayRotationManager(mDisplayRotationManager);
            mWorldRenderManager.SetQueuedSingleTaps(mQueuedSingleTaps);

            mSurfaceView.SetRenderer(mWorldRenderManager);
            mSurfaceView.RenderMode = Android.Opengl.Rendermode.Continuously;
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);
            mSurfaceView           = FindViewById <GLSurfaceView>(Resource.Id.surfaceview);
            mDisplayRotationHelper = new DisplayRotationHelper(this);

            Java.Lang.Exception exception = null;
            string message = null;

            try
            {
                mSession = new Session(/*context=*/ this);
            }
            catch (UnavailableArcoreNotInstalledException e)
            {
                message   = "Please install ARCore";
                exception = e;
            }
            catch (UnavailableApkTooOldException e)
            {
                message   = "Please update ARCore";
                exception = e;
            }
            catch (UnavailableSdkTooOldException e)
            {
                message   = "Please update this app";
                exception = e;
            }
            catch (Java.Lang.Exception e)
            {
                exception = e;
                message   = "This device does not support AR";
            }

            if (message != null)
            {
                Toast.MakeText(this, message, ToastLength.Long).Show();
                return;
            }


            // Create default config, check is supported, create session from that config.
            var config = new Google.AR.Core.Config(mSession);

            if (!mSession.IsSupported(config))
            {
                Toast.MakeText(this, "This device does not support AR", ToastLength.Long).Show();
                Finish();
                return;
            }

            AugmentedImageDatabase imageDatabase = new AugmentedImageDatabase(mSession);

            Bitmap bitmap = null;

            try
            {
                var inputStream = Assets.Open("qrcode.png");
                bitmap = BitmapFactory.DecodeStream(inputStream);
            }
            catch (IOException e)
            {
                Log.Error(TAG, "I/O exception loading augmented image bitmap.", e);
            }
            index = imageDatabase.AddImage("interstellar", bitmap, 0.01f);
            config.AugmentedImageDatabase = imageDatabase;

            mSession.Configure(config);

            mGestureDetector = new GestureDetector(this, new TapGestureDetector
            {
                SingleTapUpHandler = (MotionEvent arg) => {
                    OnSingleTap(arg);
                    return(true);
                },
                DownHandler = (MotionEvent arg) => true
            });

            mSurfaceView.SetOnTouchListener(this);



            // Set up renderer.
            mSurfaceView.PreserveEGLContextOnPause = true;
            mSurfaceView.SetEGLContextClientVersion(2);
            mSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0); // Alpha used for plane blending.
            mSurfaceView.SetRenderer(this);
            mSurfaceView.RenderMode = Rendermode.Continuously;
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            try
            {
                //need to add this on main layout
                //mSurfaceView = FindViewById<GLSurfaceView>(Resource.Id.surfaceview);

                Java.Lang.Exception exception = null;
                string message = null;

                try
                {
                    //Create session
                    //mSession = new Session(_context);
                }
                //catch (UnavailableArcoreNotInstalledException ex)
                //{
                //    message = "Please install ARCore";
                //    exception = ex;
                //}
                //catch (UnavailableApkTooOldException ex)
                //{
                //    message = "Please update ARCore";
                //    exception = ex;
                //}
                //catch (UnavailableSdkTooOldException ex)
                //{
                //    message = "Please update this app";
                //    exception = ex;
                //}
                catch (Java.Lang.Exception ex)
                {
                    exception = ex;
                    message   = "This device does not support AR";
                }

                if (message != null)
                {
                    Toast.MakeText(_context, message, ToastLength.Long).Show();
                    return;
                }

                // Create default config, check is supported, create session from that config.
                var config = new Google.AR.Core.Config(mSession);
                if (!mSession.IsSupported(config))
                {
                    Toast.MakeText(_context, "This device does not support AR", ToastLength.Long).Show();
                    return;
                }

                mGestureDetector = new Android.Views.GestureDetector(_context, new SimpleTapGestureDetector
                {
                    SingleTapUpHandler = (MotionEvent arg) => {
                        onSingleTap(arg);
                        return(true);
                    },
                    DownHandler = (MotionEvent arg) => true
                });

                mSurfaceView.SetOnTouchListener(this);

                // Set up renderer.
                mSurfaceView.PreserveEGLContextOnPause = true;
                mSurfaceView.SetEGLContextClientVersion(2);
                mSurfaceView.SetEGLConfigChooser(8, 8, 8, 8, 16, 0); // Alpha used for plane blending.
                mSurfaceView.SetRenderer(this);
                mSurfaceView.RenderMode = Rendermode.Continuously;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(@"           ERROR: ", ex.Message);
            }
        }