예제 #1
0
        protected override async void Start()
        {
            base.Start();

            arkitComponent                 = Scene.CreateComponent <ARKitComponent>();
            arkitComponent.Camera          = Camera;
            arkitComponent.Orientation     = UIKit.UIInterfaceOrientation.Portrait;
            arkitComponent.ARConfiguration = new ARWorldTrackingConfiguration {
                PlaneDetection   = ARPlaneDetection.Horizontal,
                AutoFocusEnabled = true,
            };
            arkitComponent.DidAddAnchors    += ArkitComponent_DidAddAnchors;
            arkitComponent.DidRemoveAnchors += ArkitComponent_DidRemoveAnchors;
            arkitComponent.DidUpdateAnchors += ArkitComponent_DidUpdateAnchors;
            arkitComponent.ARFrame          += ArkitComponent_ARFrame;
            arkitComponent.Run(Options.DelayedStart);

            ContinuesHitTestAtCenter = true;

            Scene.CreateComponent <DebugRenderer>();

            cursorNode           = Scene.CreateChild();
            cursorNode.Position  = Vector3.UnitZ * 100;    //hide cursor at start - pos at (0,0,100)
            cursorModel          = cursorNode.CreateComponent <Urho.Shapes.Plane>();
            cursorModel.ViewMask = 0x80000000;             //hide from raycasts (Raycast() uses a differen viewmask so the cursor won't be visible for it)
            cursorNode.RunActions(new RepeatForever(new ScaleTo(0.3f, 0.15f), new ScaleTo(0.3f, 0.2f)));

            anchorsNode = Scene.CreateChild();

            var cursorMaterial = new Material();

            cursorMaterial.SetTexture(TextureUnit.Diffuse, ResourceCache.GetTexture2D("Textures/Cursor.png"));
            cursorMaterial.SetTechnique(0, CoreAssets.Techniques.DiffAlpha);
            cursorModel.Material    = cursorMaterial;
            cursorModel.CastShadows = false;

            Input.TouchEnd     += args => OnGestureTapped(args.X, args.Y);
            UnhandledException += OnUnhandledException;

            loadingLabel = new Text {
                Value = "Detecting planes...",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                TextAlignment       = HorizontalAlignment.Center,
            };

            loadingLabel.SetColor(new Color(0.5f, 1f, 0f));
            loadingLabel.SetFont(font: CoreAssets.Fonts.AnonymousPro, size: 42);
            UI.Root.AddChild(loadingLabel);

            actionSoundSource = Scene.CreateComponent <SoundSource>();

            Node musicNode = Scene.CreateChild("Music");

            themeSoundSource = musicNode.CreateComponent <SoundSource>();
            themeSoundSource.SetSoundType(SoundType.Music.ToString());
            themeSoundSource.Gain = 0.1f;
        }
예제 #2
0
 void SetupAR()
 {
     arkitComponent                 = Scene.CreateComponent <ARKitComponent>();
     arkitComponent.Camera          = Camera;
     arkitComponent.Orientation     = UIKit.UIInterfaceOrientation.Portrait;
     arkitComponent.ARConfiguration = new ARWorldTrackingConfiguration {
         PlaneDetection = ARPlaneDetection.Horizontal,
     };
     arkitComponent.Run(Options.DelayedStart);
 }
예제 #3
0
 protected override void InitializeAR()
 {
     arkitComponent                 = scene.CreateComponent <ARKitComponent>();
     arkitComponent.Orientation     = UIKit.UIInterfaceOrientation.Portrait;
     arkitComponent.ARConfiguration = new ARWorldTrackingConfiguration
     {
         PlaneDetection = ARPlaneDetection.Horizontal
     };
     arkitComponent.DidAddAnchors    += OnAddAnchor;
     arkitComponent.DidUpdateAnchors += OnUpdateAnchors;
     arkitComponent.DidRemoveAnchors += OnRemoveAnchors;
     arkitComponent.RunEngineFramesInARKitCallbakcs = Options.DelayedStart;
     arkitComponent.Run();
 }
예제 #4
0
        protected override unsafe void Start()
        {
            base.Start();

            anchorsNode = Scene.CreateChild();

            arkitComponent                   = Scene.CreateComponent <ARKitComponent>();
            arkitComponent.Orientation       = UIKit.UIInterfaceOrientation.Portrait;
            arkitComponent.ARConfiguration   = new ARFaceTrackingConfiguration();
            arkitComponent.DidAddAnchors    += ArkitComponent_DidAddAnchors;
            arkitComponent.DidRemoveAnchors += ArkitComponent_DidRemoveAnchors;
            arkitComponent.DidUpdateAnchors += ArkitComponent_DidUpdateAnchors;
            arkitComponent.RunEngineFramesInARKitCallbakcs = Options.DelayedStart;
            arkitComponent.Run();
        }
예제 #5
0
        protected override void Start()
        {
            base.Start();

            //Scene.CreateComponent<PhysicsWorld>();
            Scene.CreateComponent <DebugRenderer>();

            Zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));

            new MonoDebugHud(this).Show(Color.Green, 45);

            arkitComponent                 = Scene.CreateComponent <ARKitComponent>();
            arkitComponent.Orientation     = UIKit.UIInterfaceOrientation.Portrait;
            arkitComponent.ARConfiguration = new ARWorldTrackingConfiguration {
                PlaneDetection =
                    ARPlaneDetection.Horizontal
#if false // uncomment once Xamarin.iOS with xcode93 is released:
                    | ARPlaneDetection.Vertical,
#endif
            };

            arkitComponent.DidAddAnchors    += ArkitComponent_DidAddAnchors;
            arkitComponent.DidRemoveAnchors += ArkitComponent_DidRemoveAnchors;
            arkitComponent.DidUpdateAnchors += ArkitComponent_DidUpdateAnchors;
            arkitComponent.ARFrame          += ArkitComponent_ARFrame;
            arkitComponent.RunEngineFramesInARKitCallbakcs = Options.DelayedStart;
            arkitComponent.Run();

            anchorsNode = Scene.CreateChild();

            loadingLabel = new Text {
                Value = "Detecting planes...",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                TextAlignment       = HorizontalAlignment.Center,
            };
            loadingLabel.SetColor(new Color(0.5f, 0.9f, 0.1f));
            loadingLabel.SetFont(font: CoreAssets.Fonts.AnonymousPro, size: 35);
            UI.Root.AddChild(loadingLabel);

            Input.TouchEnd += Input_TouchEnd;
        }
예제 #6
0
        protected override void Start()
        {
            base.Start();

            arkitComponent                 = Scene.CreateComponent <ARKitComponent>();
            arkitComponent.Orientation     = UIKit.UIInterfaceOrientation.Portrait;
            arkitComponent.ARConfiguration = new ARWorldTrackingConfiguration
            {
                PlaneDetection = ARPlaneDetection.Horizontal,
            };
            arkitComponent.RunEngineFramesInARKitCallbakcs = Options.DelayedStart;
            arkitComponent.Run();

            // Tree
            treeNode = Scene.CreateChild();
            treeNode.SetScale(0.05f);
            treeNode.Position = new Vector3(0, -0.3f, 0.75f);
            treeNode.Rotate(new Quaternion(0, 100, 0), TransformSpace.Local);

            var planeNode = treeNode.CreateChild();

            planeNode.Scale = new Vector3(5, 0.1f, 10);
            var plane = planeNode.CreateComponent <Urho.SharpReality.TransparentPlaneWithShadows>();

            var model = treeNode.CreateComponent <AnimatedModel>();

            model.CastShadows = true;

            var material = new Material();

            material.SetTexture(TextureUnit.Diffuse, ResourceCache.GetTexture2D("Textures/CocosNucifera_BaseColor.jpg"));
            material.SetTexture(TextureUnit.Normal, ResourceCache.GetTexture2D("Textures/CocosNucifera_Normal_DirectX.jpg"));
            material.SetTechnique(0, CoreAssets.Techniques.DiffNormal);

            model.Model    = ResourceCache.GetModel("Models/Tree1.mdl");
            model.Material = material;

            var animation = treeNode.CreateComponent <AnimationController>();

            animation.Play("Animations/Tree.ani", 0, true, 0.2f);
        }
예제 #7
0
        protected override unsafe void Start()
        {
            UnhandledException += OnUnhandledException;
            Log.LogLevel        = LogLevel.Debug;

            base.Start();

            arkitComponent                 = Scene.CreateComponent <ARKitComponent>();
            arkitComponent.Camera          = Camera;
            arkitComponent.Orientation     = UIKit.UIInterfaceOrientation.Portrait;
            arkitComponent.ARConfiguration = new ARWorldTrackingConfiguration {
                AutoFocusEnabled = true,
                PlaneDetection   = ARPlaneDetection.Horizontal,
            };
            arkitComponent.Run(Options.DelayedStart);

            // Mutant
            mutantNode = Scene.CreateChild();
            mutantNode.SetScale(0.2f);
            mutantNode.Position = new Vector3(0, -0.5f, 0.75f);

            var planeNode = mutantNode.CreateChild();

            planeNode.Scale = new Vector3(10, 0.1f, 10);
            //var plane = planeNode.CreateComponent<Urho.SharpReality.TransparentPlaneWithShadows>();

            var model = mutantNode.CreateComponent <AnimatedModel>();

            model.CastShadows = true;
            model.Model       = ResourceCache.GetModel("Models/Mutant.mdl");
            model.Material    = ResourceCache.GetMaterial("Materials/mutant_M.xml");

            var animation = mutantNode.CreateComponent <AnimationController>();

            animation.Play("Animations/Mutant_HipHop1.ani", 0, true, 0.2f);

            Input.TouchBegin += OnTouchBegin;
            Input.TouchEnd   += OnTouchEnd;
        }