Beispiel #1
0
        public static SCNPlane CreateSquarePlane(float size, NSObject contents)
        {
            var plane = SCNPlane.Create(size, size);

            plane.InsertMaterial(SCNMaterialExtensions.CreateMaterial(contents), 0);
            return(plane);
        }
        private void HandleTap(UIGestureRecognizer gestureRecognize)
        {
            // Get current frame
            var currentFrame = SceneView.Session.CurrentFrame;

            if (currentFrame == null)
            {
                return;
            }

            // Create an image plane using a snapshot of the view
            var imagePlane = SCNPlane.Create(SceneView.Bounds.Width / 6000, SceneView.Bounds.Height / 6000);

            imagePlane.FirstMaterial.Diffuse.Contents  = SceneView.Snapshot();
            imagePlane.FirstMaterial.LightingModelName = SCNLightingModel.Constant;

            // Create a plane node and add it to the scene
            var planeNode = SCNNode.FromGeometry(imagePlane);

            SceneView.Scene.RootNode.AddChildNode(planeNode);

            // Set transform of node to be 10cm in front of the camera
            var translation       = SCNMatrix4.CreateTranslation(0, 0, 0.1f);
            var cameraTranslation = currentFrame.Camera.Transform.ToSCNMatrix4();

            planeNode.Transform = SCNMatrix4.Mult(cameraTranslation, translation);
        }
Beispiel #3
0
        public static SCNPlane CreatePlane(CGSize size, NSObject contents)
        {
            var plane = SCNPlane.Create(size.Width, size.Height);

            plane.InsertMaterial(SCNMaterialExtensions.CreateMaterial(contents), 0);
            return(plane);
        }
Beispiel #4
0
        private SCNNode GetFrameNode(SCNNode node, nfloat frameWidth)
        {
            node.Geometry.

            var plane = SCNPlane.Create(width + (2 * frameWidth), height + (2 * frameWidth));

            var planeNode = SCNNode.Create();

            planeNode.Geometry = plane;
            //planeNode.Geometry.FirstMaterial.Diffuse.Contents = UIColor.Blue;

            /*
             * `SCNPlane` is vertically oriented in its local coordinate space, but
             * `ARImageAnchor` assumes the image is horizontal in its local space, so
             * rotate the plane to match.
             */
            var EulerY = planeNode.EulerAngles.Y;
            var EulerZ = planeNode.EulerAngles.Z;

            planeNode.EulerAngles = new SCNVector3((float)-3.1416 / 2, EulerY, EulerZ);


            var frameSidePlane = SCNPlane.Create(0.01f, height);
            var planeSideNode  = SCNNode.Create();

            planeSideNode.Geometry = frameSidePlane;
            planeSideNode.Geometry.FirstMaterial.Diffuse.Contents = UIColor.Green;
            planeNode.Position = new SCNVector3(0, 0, 0);

            planeNode.Add(planeSideNode);


            return(planeNode);
        }
Beispiel #5
0
        void PlaceAnchorNode(SCNNode node, ARPlaneAnchor anchor)
        {
            var plane = SCNPlane.Create(anchor.Extent.X, anchor.Extent.Z);

            plane.FirstMaterial.Diffuse.Contents = UIColor.LightGray;
            var planeNode = SCNNode.FromGeometry(plane);

            //Locate the plane at the position of the anchor
            planeNode.Position = new SCNVector3(anchor.Extent.X, 0.0f, anchor.Extent.Z);
            //Rotate it to lie flat
            planeNode.Transform = SCNMatrix4.CreateRotationX((float)(Math.PI / 2.0));
            node.AddChildNode(planeNode);

            //Mark the anchor with a small red box
            var box = new SCNBox {
                Height = 0.18f, Width = 0.18f, Length = 0.18f
            };

            box.FirstMaterial.Diffuse.ContentColor = UIColor.Red;
            var anchorNode = new SCNNode {
                Position = new SCNVector3(0, 0, 0), Geometry = box
            };

            planeNode.AddChildNode(anchorNode);
        }
Beispiel #6
0
        private static SCNGeometry CreateGeometry(nfloat width, nfloat length, string imagePath)
        {
            UIImage image    = null;
            var     material = new SCNMaterial();

            if (!string.IsNullOrEmpty(imagePath))
            {
                image = UIImage.FromFile(imagePath);
                material.Diffuse.Contents = image;
                //material.Diffuse.ContentColor
            }
            else
            {
                material.Diffuse.Contents = UIColor.White;
            }



            material.DoubleSided = true;

            var geometry = SCNPlane.Create(width, length);

            geometry.Materials = new[] { material };

            return(geometry);
        }
Beispiel #7
0
        private SCNNode CreatePlane(ARReferenceImage detectecImage)
        {
            nfloat width  = detectecImage.PhysicalSize.Width;
            nfloat height = detectecImage.PhysicalSize.Height;

            SCNMaterial material = new SCNMaterial();

            material.Diffuse.Contents = UIColor.Blue;
            material.DoubleSided      = false;

            SCNPlane geometry = SCNPlane.Create(width, height);

            geometry.Materials = new[] { material };

            SCNNode planeNode = new SCNNode
            {
                Geometry = geometry,
                Position = new SCNVector3(0, 0, 0)
            };

            float angle = (float)(-Math.PI / 2);

            planeNode.EulerAngles = new SCNVector3(angle, 0, 0);

            return(planeNode);
        }
Beispiel #8
0
        public override void PresentStep(int index, PresentationViewController presentationViewController)
        {
            SCNTransaction.Begin();
            SCNTransaction.AnimationDuration = 1;

            switch (index)
            {
            case 0:
                break;

            case 1:
                //add a plan in the background
                TextManager.FadeOutText(SlideTextManager.TextType.Code);
                TextManager.FadeOutText(SlideTextManager.TextType.Subtitle);

                var bg    = SCNNode.Create();
                var plane = SCNPlane.Create(100, 100);
                bg.Geometry = plane;
                bg.Position = new SCNVector3(0, 0, -60);
                presentationViewController.CameraNode.AddChildNode(bg);

                ((SCNView)presentationViewController.View).Scene.FogColor         = NSColor.White;
                ((SCNView)presentationViewController.View).Scene.FogStartDistance = 10;
                ((SCNView)presentationViewController.View).Scene.FogEndDistance   = 50;
                break;

            case 2:
                ((SCNView)presentationViewController.View).Scene.FogDensityExponent = 0.3f;
                break;
            }

            SCNTransaction.Commit();
        }
        public virtual SCNNode CreateARPlaneNode(ARPlaneAnchor anchor, UIColor color)
        {
            Console.WriteLine($"ADD: {anchor.Alignment}, {anchor.Extent}");

            var material = new SCNMaterial();

            material.Diffuse.Contents = color;

            var geometry = new SCNPlane
            {
                Width     = anchor.Extent.X,
                Height    = anchor.Extent.Z,
                Materials = new[] { material, material, material, material },
            };

            var rotation = SCNMatrix4.Identity;

            SCNMatrix4.CreateRotationX((float)-Math.PI / 2.0f, out rotation);

            var planeNode = new SCNNode
            {
                Geometry    = geometry,
                Position    = new SCNVector3(anchor.Center.X, 0, anchor.Center.Z),
                Transform   = rotation,
                PhysicsBody = CreatePlanePhysics(geometry)
            };

            return(planeNode);
        }
        public void DidUpdateNode(ISCNSceneRenderer renderer, SCNNode node, ARAnchor anchor)
        {
            var planeAnchor = anchor as ARPlaneAnchor;

            if (planeAnchor == null)
            {
                return;
            }

            Console.WriteLine($"didUpdateNode :{node.ChildNodes.Length}");

            foreach (var childNode in node.ChildNodes)
            {
                SCNPlane planeNode = childNode.Geometry as SCNPlane;
                if (planeNode != null)
                {
                    childNode.Position = new SCNVector3(planeAnchor.Center.X, 0f, planeAnchor.Center.Z);
                    planeNode.Width    = new nfloat(planeAnchor.Extent.X);
                    planeNode.Height   = new nfloat(planeAnchor.Extent.Z);
                }
                else if (childNode.Geometry is SCNText)
                {
                    childNode.Position = new SCNVector3(-0.3f, -0.55f, 0.25f);
                }
            }
        }
Beispiel #11
0
        private SCNNode GetFillPlane()
        {
            var length = 1f - 2f * BorderSegment.Thickness;
            var plane  = SCNPlane.Create(length, length * this.AspectRatio);
            var node   = SCNNode.FromGeometry(plane);

            node.Name    = "fillPlane";
            node.Opacity = 0.6f;

            var material = plane.FirstMaterial;

            material.Diffuse.Contents = UIImage.FromBundle("art.scnassets/textures/grid.png");

            var textureScale = SimdExtensions.CreateFromScale(new SCNVector3(40f, 40f * this.AspectRatio, 1f));

            material.Diffuse.ContentsTransform  = textureScale;
            material.Emission.Contents          = UIImage.FromBundle("art.scnassets/textures/grid.png");
            material.Emission.ContentsTransform = textureScale;
            material.Diffuse.WrapS     = SCNWrapMode.Repeat;
            material.Diffuse.WrapT     = SCNWrapMode.Repeat;
            material.DoubleSided       = true;
            material.Ambient.Contents  = UIColor.Black;
            material.LightingModelName = SCNLightingModel.Constant;

            return(node);
        }
 bool PlaneSizeEqualToExtent(ARPlaneAnchor anchor, SCNPlane plane, NVector3 extent)
 {
     if (plane.Width != (nfloat)anchor.Extent.X || plane.Height != (nfloat)anchor.Extent.Z)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Beispiel #13
0
        private void AddPlane()
        {
            SCNNode planeNode = new SCNNode();

            planeNode.Geometry = SCNPlane.Create(0.05f, 0.05f);
            planeNode.Geometry.FirstMaterial.Diffuse.Contents  = UIColor.Green; //Color del objeto
            planeNode.Geometry.FirstMaterial.Specular.Contents = UIColor.White; //Color del reflejo
            planeNode.Position = new SCNVector3(0, 0.1f, 0.1f);

            sceneView.Scene.RootNode.AddChildNode(planeNode);
        }
Beispiel #14
0
        public override void SetupSlide(PresentationViewController presentationViewController)
        {
            TextManager.SetTitle("Shadows");

            TextManager.AddBulletAtLevel("Static", 0);
            TextManager.AddBulletAtLevel("Dynamic", 0);
            TextManager.AddBulletAtLevel("Projected", 0);

            var sceneryHolder = SCNNode.Create();

            sceneryHolder.Name     = "scenery";
            sceneryHolder.Position = new SCNVector3(5, -19, 12);

            GroundNode.AddChildNode(sceneryHolder);

            //add scenery
            var scenery = Utils.SCAddChildNode(sceneryHolder, "scenery", "Scenes.scnassets/banana/level", 130);

            scenery.Position = new SCNVector3(-291.374969f, 1.065581f, -30.519293f);
            scenery.Scale    = new SCNVector3(0.044634f, 0.044634f, 0.044634f);
            scenery.Rotation = new SCNVector4(1, 0, 0, -NMath.PI / 2);

            PalmTree = Utils.SCAddChildNode(GroundNode, "PalmTree", "Scenes.scnassets/palmTree/palm_tree", 15);

            PalmTree.Position = new SCNVector3(3, -1, 7);
            PalmTree.Rotation = new SCNVector4(1, 0, 0, -NMath.PI / 2);

            foreach (var child in PalmTree.ChildNodes)
            {
                child.CastsShadow = false;
            }

            //add a static shadow
            var shadowPlane = SCNNode.FromGeometry(SCNPlane.Create(15, 15));

            shadowPlane.EulerAngles = new SCNVector3(-NMath.PI / 2, (float)(Math.PI / 4) * 0.5f, 0);
            shadowPlane.Position    = new SCNVector3(0.5f, 0.1f, 2);
            shadowPlane.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Images/staticShadow", "tiff"));
            GroundNode.AddChildNode(shadowPlane);
            StaticShadowNode         = shadowPlane;
            StaticShadowNode.Opacity = 0;

            var character = Utils.SCAddChildNode(GroundNode, "explorer", "Scenes.scnassets/explorer/explorer_skinned", 9);

            var animScene    = SCNScene.FromFile("Scenes.scnassets/explorer/idle");
            var animatedNode = animScene.RootNode.FindChildNode("Bip001_Pelvis", true);

            character.AddAnimation(animatedNode.GetAnimation(animatedNode.GetAnimationKeys() [0]), new NSString("idle"));

            character.EulerAngles = new SCNVector3(0, NMath.PI / 2, NMath.PI / 2);
            character.Position    = new SCNVector3(20, 0, 7);
            Character             = character;
        }
Beispiel #15
0
        private SCNNode CreateLavaNode(ARPlaneAnchor planeAnchor)
        {
            SCNNode lavaNode = new SCNNode();

            lavaNode.Geometry = SCNPlane.Create(planeAnchor.Extent.X, planeAnchor.Extent.Z);
            lavaNode.Geometry.FirstMaterial.Diffuse.Contents = new UIImage("Lava.png");
            lavaNode.Geometry.FirstMaterial.DoubleSided      = true;
            lavaNode.Position    = new SCNVector3(planeAnchor.Center.X, planeAnchor.Center.Y, planeAnchor.Center.Z);
            lavaNode.EulerAngles = new SCNVector3(ConvertDegreesToRadians(90), 0, 0);

            return(lavaNode);
        }
Beispiel #16
0
        SCNGeometry CreateGeometry(float width, float length, UIColor color)
        {
            SCNMaterial material = new SCNMaterial();

            material.Diffuse.Contents = color;
            material.DoubleSided      = true;

            SCNPlane geometry = SCNPlane.Create(width, length);

            geometry.Materials = new[] { material };

            return(geometry);
        }
        private void CreateVirtualScreenNode()
        {
            SCNPlane screenGeometry = new SCNPlane
            {
                Width  = 1,
                Height = 1
            };

            screenGeometry.FirstMaterial.DoubleSided      = true;
            screenGeometry.FirstMaterial.Diffuse.Contents = UIColor.Green;

            virtualScreenNode = SCNNode.FromGeometry(screenGeometry);
        }
Beispiel #18
0
        private static SCNGeometry CreateGeometry(float width, float length, SKScene videoScene)
        {
            var material = new SCNMaterial();

            material.Diffuse.Contents = videoScene;
            material.DoubleSided      = true;

            var geometry = SCNPlane.Create(width, length);

            geometry.Materials = new[] { material };

            return(geometry);
        }
Beispiel #19
0
        private static SCNPlane CreateGeometry(ARPlaneAnchor planeAnchor, UIColor colour)
        {
            var material = new SCNMaterial();

            material.Diffuse.Contents = colour;
            material.DoubleSided      = true;
            material.Transparency     = 0.8f;

            var geometry = SCNPlane.Create(planeAnchor.Extent.X, planeAnchor.Extent.Z);

            geometry.Materials = new[] { material };

            return(geometry);
        }
Beispiel #20
0
        private SCNNode CreateTrackNode()
        {
            var geometry = new SCNPlane()
            {
                Width = this.Width, Height = this.Length
            };

            var trackNode = new SCNNode();

            trackNode.Geometry = geometry;
            trackNode.Geometry.Materials.First().Diffuse.Contents = TRACK_COLOR;
            trackNode.EulerAngles = new SCNVector3(-1 * (float)Math.PI / 2, (float)Math.PI / 2, 0);
            trackNode.Position    = new SCNVector3(0f, 0f, 0f);

            return(trackNode);
        }
        /// <summary>
        /// Creates a plane an place in on the center of the plane anchor
        /// and rotates so it lies flat
        /// </summary>
        private void PlaceAnchorNode(SCNNode node, ARPlaneAnchor anchor)
        {
            var plane = SCNPlane.Create(anchor.Extent.X, anchor.Extent.Z);

            var material = new SCNMaterial();

            material.Diffuse.Contents        = UIImage.FromFile("art.scnassets/PlaneGrid/grid.png");
            plane.Materials                  = new[] { material };
            plane.FirstMaterial.Transparency = 0.1f;

            var planeNode = SCNNode.FromGeometry(plane);

            planeNode.Position  = new SCNVector3(anchor.Center.X, 0.0f, anchor.Center.Z);
            planeNode.Transform = SCNMatrix4.CreateRotationX((float)(-Math.PI / 2.0));
            node.AddChildNode(planeNode);
        }
Beispiel #22
0
        static SCNNode CreateIconImageNode(string imageName, CGSize size)
        {
            var image         = UIImage.FromBundle(imageName);
            var imageGeometry = SCNPlane.Create(size.Width, size.Height);

            imageGeometry.FirstMaterial.Diffuse.Contents     = image;
            imageGeometry.FirstMaterial.LightingModelName    = SCNLightingModel.Constant;
            imageGeometry.FirstMaterial.DoubleSided          = true;
            imageGeometry.FirstMaterial.ReadsFromDepthBuffer = false;
            imageGeometry.FirstMaterial.WritesToDepthBuffer  = false;
            var planeNode = new SCNNode
            {
                Geometry = imageGeometry
            };

            return(planeNode);
        }
Beispiel #23
0
        public static SCNNode SCPlaneNodeWithImage(NSImage image, nfloat size, bool isLit)
        {
            var node = SCNNode.Create();

            var factor = size / (nfloat)(Math.Max(image.Size.Width, image.Size.Height));

            node.Geometry = SCNPlane.Create(image.Size.Width * factor, image.Size.Height * factor);
            node.Geometry.FirstMaterial.Diffuse.Contents = image;

            //if we don't want the image to be lit, set the lighting model to "constant"
            if (!isLit)
            {
                node.Geometry.FirstMaterial.LightingModelName = SCNLightingModel.Constant;
            }

            return(node);
        }
Beispiel #24
0
        public Plane(ARPlaneAnchor anchor)
        {
            this.PlaneAnchor = anchor;

            var grid = UIImage.FromBundle("plane_grid2.png");

            this.PlaneGeometry = SCNPlane.Create(PlaneAnchor.Extent.X, PlaneAnchor.Extent.Z);
            this.PlaneNode     = SCNNode.FromGeometry(PlaneGeometry);

            PlaneGeometry.FirstMaterial.Transparency     = 0.5f;
            PlaneGeometry.FirstMaterial.Diffuse.Contents = grid;

            PlaneNode.Transform = SCNMatrix4.CreateRotationX((float)-Math.PI / 2);
            PlaneNode.Position  = new SCNVector3(PlaneAnchor.Center.X, 0, PlaneAnchor.Center.Z);

            AddChildNode(PlaneNode);
        }
Beispiel #25
0
        private SCNNode CreateConcreteNode(ARPlaneAnchor planeAnchor)
        {
            SCNNode concreteNode = new SCNNode();

            concreteNode.Geometry = SCNPlane.Create(planeAnchor.Extent.X, planeAnchor.Extent.Z);
            concreteNode.Geometry.FirstMaterial.Diffuse.Contents = new UIImage("Concrete.png");
            concreteNode.Geometry.FirstMaterial.DoubleSided      = true;
            concreteNode.Position    = new SCNVector3(planeAnchor.Center.X, planeAnchor.Center.Y, planeAnchor.Center.Z);
            concreteNode.EulerAngles = new SCNVector3(ConvertDegreesToRadians(90), 0, 0);

            //TODO 4.1 Creando superficie
            SCNPhysicsBody staticBody = SCNPhysicsBody.CreateStaticBody();

            concreteNode.PhysicsBody = staticBody;

            return(concreteNode);
        }
Beispiel #26
0
        internal Tile(SCNPlane plane)
        {
            base.Init();
            Geometry = plane;
            Opacity  = 0F;

            // Create a child node with another plane of the same size, but a darker color to stand out better
            // This helps users see captured tiles from the back.
            if (ChildNodes.Length == 0)
            {
                var innerPlane = SCNPlane.Create(plane.Width, plane.Height);
                innerPlane.Materials = new[] { Utilities.Material(Utilities.AppBrown.ColorWithAlpha(0.8F), false, false) };
                var innerNode = SCNNode.FromGeometry(innerPlane);
                innerNode.EulerAngles = new SCNVector3(0, (float)Math.PI, 0);
                AddChildNode(innerNode);
            }
        }
Beispiel #27
0
        static SCNNode CreateBackgroundPlaneNode(CGSize size, UIColor color, float radius)
        {
            var planeGeometry = SCNPlane.Create(size.Width, size.Height);

            planeGeometry.CornerRadius = radius;
            planeGeometry.FirstMaterial.Diffuse.Contents     = color;
            planeGeometry.FirstMaterial.LightingModelName    = SCNLightingModel.Constant;
            planeGeometry.FirstMaterial.DoubleSided          = true;
            planeGeometry.FirstMaterial.ReadsFromDepthBuffer = false;
            planeGeometry.FirstMaterial.WritesToDepthBuffer  = false;
            var planeNode = new SCNNode
            {
                Geometry = planeGeometry
            };

            return(planeNode);
        }
        public void DidAddNode(ISCNSceneRenderer renderer, SCNNode node, ARAnchor anchor)
        {
            var planeAnchor = anchor as ARPlaneAnchor;

            if (planeAnchor == null)
            {
                return;
            }

            Console.WriteLine("didAddNode");

            var text = SCNText.Create("This is a good spot", 0);

            text.Font = UIFont.FromName("Arial", 1);
            if (text.FirstMaterial != null)
            {
                text.FirstMaterial.Diffuse.Contents = UIColor.Green;
            }

            var textNode = SCNNode.FromGeometry(text);

            textNode.Position = new SCNVector3(-0.3f, -0.55f, 0.25f);
            textNode.Scale    = new SCNVector3(0.075f, 0.1f, 0.5f);

            var plane     = SCNPlane.Create(new nfloat(planeAnchor.Extent.X), new nfloat(planeAnchor.Extent.Z));
            var planeNode = SCNNode.FromGeometry(plane);

            planeNode.Position = new SCNVector3(planeAnchor.Center.X, 0f, planeAnchor.Center.Z);

            var txtAngles = textNode.EulerAngles;

            txtAngles.X          = (float)(-1f * (Math.PI / 2f));
            textNode.EulerAngles = txtAngles;
            var planeAngles = planeNode.EulerAngles;

            planeAngles.X         = (float)(-1f * (Math.PI / 2f));
            planeNode.EulerAngles = planeAngles;

            planeNode.Opacity = 0.25f;

            node.AddChildNode(planeNode);
            node.AddChildNode(textNode);
        }
Beispiel #29
0
        public BorderSegment(Corner corner, Alignment alignment, CGSize borderSize) : base()
        {
            this.corner    = corner;
            this.alignment = alignment;

            this.plane      = SCNPlane.Create(BorderSegment.Thickness, BorderSegment.Thickness);
            this.borderSize = borderSize;

            var material = this.plane.FirstMaterial;

            material.Diffuse.Contents  = GameBoard.BorderColor;
            material.Emission.Contents = GameBoard.BorderColor;
            material.DoubleSided       = true;
            material.Ambient.Contents  = UIColor.Black;
            material.LightingModelName = SCNLightingModel.Constant;

            this.Geometry = this.plane;
            this.Opacity  = 0.8f;
        }
Beispiel #30
0
        private void SetupTiles()
        {
            IsBusyUpdatingTiles = true;

            // Determine number of rows and columns
            var numRows    = Math.Min(maxTileCount, (int)(Math.Ceiling(size.Height / maxTileSize)));
            var numColumns = Math.Min(maxTileCount, (int)(Math.Ceiling(size.Width / maxTileSize)));

            var newTiles = new List <Tile>();

            // Create updates tiles and lay them out
            for (var row = 0; row < numRows; row++)
            {
                for (var col = 0; col < numColumns; col++)
                {
                    var plane = SCNPlane.Create(size.Width / numColumns, size.Height / numRows);
                    plane.Materials = new[] { Utilities.Material(color, false, false) };

                    var xPos = -size.Width / 2 + plane.Width / 2 + col * plane.Width;
                    var yPos = size.Height / 2 - plane.Height / 2 - row * plane.Height;

                    var tileNode = new Tile(plane);
                    tileNode.Position = new SCNVector3((float)xPos, (float)yPos, 0);
                    newTiles.Add(tileNode);
                }
            }

            // Replace the nodes in the scene graph.
            foreach (var tile in Tiles)
            {
                tile.RemoveFromParentNode();
            }
            foreach (var tile in newTiles)
            {
                AddChildNode(tile);
            }
            Tiles = newTiles;

            sizeOnLastTileUpdate = size;
            IsBusyUpdatingTiles  = false;
        }
		private void SetupSceneElements (SCNScene scene)
		{
			AddTrainToScene (scene, new SCNVector3 (-5f, 20f, -40f));
			AddWoodenBlockToScene (scene, ResourceManager.GetResourcePath ("WoodCubeA.jpg"), new SCNVector3 (-10f, 15f, 10f));
			AddWoodenBlockToScene (scene, ResourceManager.GetResourcePath ("WoodCubeB.jpg"), new SCNVector3 (-9f, 10f, 10f));
			AddWoodenBlockToScene (scene, ResourceManager.GetResourcePath ("WoodCubeC.jpg"), new SCNVector3 (20f, 15f, -11f));
			AddWoodenBlockToScene (scene, ResourceManager.GetResourcePath ("WoodCubeA.jpg"), new SCNVector3 (25f, 5f, -20f));

			var wallBox = new SCNBox {
				Width = 400f,
				Height = 100f,
				Length = 4f,
				ChamferRadius = 0f
			};

			var wall = SCNNode.FromGeometry (wallBox);
			wall.Geometry.FirstMaterial.Diffuse.Contents = ResourceManager.GetResourcePath ("wall.jpg");
			wall.Geometry.FirstMaterial.Diffuse.ContentsTransform = SCNMatrix4.Mult (
				SCNMatrix4.Scale (24f, 2f, 1f),
				SCNMatrix4.CreateTranslation (0f, 1f, 0f)
			);

			wall.Geometry.FirstMaterial.Diffuse.WrapS = SCNWrapMode.Repeat;
			wall.Geometry.FirstMaterial.Diffuse.WrapT = SCNWrapMode.Mirror;
			wall.Geometry.FirstMaterial.DoubleSided = false;
			wall.CastsShadow = false;
			wall.Geometry.FirstMaterial.LocksAmbientWithDiffuse = true;

			wall.Position = new SCNVector3 (0f, 50f, -92f);
			wall.PhysicsBody = SCNPhysicsBody.CreateStaticBody ();
			scene.RootNode.AddChildNode (wall);

			wall = wall.Clone ();
			wall.Position = new SCNVector3 (202f, 50f, 0f);
			wall.Rotation = new SCNVector4 (0f, 1f, 0f, (float)Math.PI / 2f);
			scene.RootNode.AddChildNode (wall);

			wall = wall.Clone ();
			wall.Position = new SCNVector3 (-202f, 50f, 0f);
			wall.Rotation = new SCNVector4 (0f, 1f, 0f, -(float)Math.PI / 2f);
			scene.RootNode.AddChildNode (wall);

			var planeGeometry = new SCNPlane {
				Width = 400f,
				Height = 100f
			};

			var backWall = SCNNode.FromGeometry (planeGeometry);
			backWall.Geometry.FirstMaterial = wall.Geometry.FirstMaterial;
			backWall.Position = new SCNVector3 (0f, 50f, 200f);
			backWall.Rotation = new SCNVector4 (0f, 1f, 0f, (float)Math.PI);
			backWall.CastsShadow = false;
			backWall.PhysicsBody = SCNPhysicsBody.CreateStaticBody ();
			scene.RootNode.AddChildNode (backWall);

			planeGeometry = new SCNPlane {
				Width = 400f,
				Height = 400f
			};

			var ceilNode = SCNNode.FromGeometry (planeGeometry);
			ceilNode.Position = new SCNVector3 (0f, 100f, 0f);
			ceilNode.Rotation = new SCNVector4 (1f, 0f, 0f, (float)Math.PI / 2f);
			ceilNode.Geometry.FirstMaterial.DoubleSided = false;
			ceilNode.CastsShadow = false;
			ceilNode.Geometry.FirstMaterial.LocksAmbientWithDiffuse = true;
			scene.RootNode.AddChildNode (ceilNode);

			var rnd = new Random ();
			for (int i = 0; i < 4; i++) {
				AddWoodenBlockToScene (scene, ResourceManager.GetResourcePath ("WoodCubeA.jpg"),
					new SCNVector3 (rnd.Next (0, 60) - 30f, 20f, rnd.Next (0, 40) - 20f));
				AddWoodenBlockToScene (scene, ResourceManager.GetResourcePath ("WoodCubeB.jpg"),
					new SCNVector3 (rnd.Next (0, 60) - 30f, 20f, rnd.Next (0, 40) - 20f));
				AddWoodenBlockToScene (scene, ResourceManager.GetResourcePath ("WoodCubeC.jpg"),
					new SCNVector3 (rnd.Next (0, 60) - 30f, 20f, rnd.Next (0, 40) - 20f));
			}

			var blockBox = new SCNBox {
				Width = 22f,
				Height = 0.2f,
				Length = 34f,
				ChamferRadius = 0f
			};

			var block = SCNNode.Create ();
			block.Position = new SCNVector3 (20f, 10f, -16f);
			block.Rotation = new SCNVector4 (0f, 1f, 0f, (float)-Math.PI / 4f);
			block.Geometry = blockBox;

			var frontMat = SCNMaterial.Create ();
			frontMat.LocksAmbientWithDiffuse = true;
			frontMat.Diffuse.Contents = ResourceManager.GetResourcePath ("book_front.jpg");
			frontMat.Diffuse.MipFilter = SCNFilterMode.Linear;

			var backMat = SCNMaterial.Create ();
			backMat.LocksAmbientWithDiffuse = true;
			backMat.Diffuse.Contents = ResourceManager.GetResourcePath ("book_back.jpg");
			backMat.Diffuse.MipFilter = SCNFilterMode.Linear;

			block.Geometry.Materials = new SCNMaterial[] { frontMat, backMat };
			block.PhysicsBody = SCNPhysicsBody.CreateDynamicBody ();
			scene.RootNode.AddChildNode (block);

			var rug = SCNNode.Create ();
			rug.Position = new SCNVector3 (0f, 0.01f, 0f);
			rug.Rotation = new SCNVector4 (1f, 0f, 0f, (float)Math.PI / 2f);
			var path = UIBezierPath.FromRoundedRect (new CGRect (-50f, -30f, 100f, 50f), 2.5f);
			path.Flatness = 0.1f;
			rug.Geometry = SCNShape.Create (path, 0.05f);
			rug.Geometry.FirstMaterial.LocksAmbientWithDiffuse = true;
			rug.Geometry.FirstMaterial.Diffuse.Contents = ResourceManager.GetResourcePath ("carpet.jpg");
			scene.RootNode.AddChildNode (rug);

			var ball = SCNNode.Create ();
			ball.Position = new SCNVector3 (-5f, 5f, -18f);
			ball.Geometry = SCNSphere.Create (5f);
			ball.Geometry.FirstMaterial.LocksAmbientWithDiffuse = true;
			ball.Geometry.FirstMaterial.Diffuse.Contents = ResourceManager.GetResourcePath ("ball.jpg");
			ball.Geometry.FirstMaterial.Diffuse.ContentsTransform = SCNMatrix4.Scale (2f, 1f, 1f);
			ball.Geometry.FirstMaterial.Diffuse.WrapS = SCNWrapMode.Mirror;
			ball.PhysicsBody = SCNPhysicsBody.CreateDynamicBody ();
			ball.PhysicsBody.Restitution = 0.9f;
			scene.RootNode.AddChildNode (ball);
		}