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

			// Allow tap gesture
			EnableGestureTapped = true;

			// Create a bucket
			bucketNode = Scene.CreateChild();
			bucketNode.SetScale(0.1f);

			// Create instructions
			textNode = bucketNode.CreateChild();
			var text3D = textNode.CreateComponent<Text3D>();
			text3D.HorizontalAlignment = HorizontalAlignment.Center;
			text3D.VerticalAlignment = VerticalAlignment.Top;
			text3D.ViewMask = 0x80000000; //hide from raycasts
			text3D.Text = "Place on a horizontal\n  surface and click";
			text3D.SetFont(CoreAssets.Fonts.AnonymousPro, 26);
			text3D.SetColor(Color.White);
			textNode.Translate(new Vector3(0, 3f, -0.5f));

			// Model and Physics for the bucket
			var bucketModel = bucketNode.CreateComponent<StaticModel>();
			bucketMaterial = Material.FromColor(validPositionColor);
			bucketModel.Model = ResourceCache.GetModel("Models/bucket.mdl");
			bucketModel.SetMaterial(bucketMaterial);
			bucketModel.ViewMask = 0x80000000; //hide from raycasts
			bucketNode.CreateComponent<RigidBody>();
			var shape = bucketNode.CreateComponent<CollisionShape>();
			shape.SetTriangleMesh(bucketModel.Model, 0, Vector3.One, Vector3.Zero, Quaternion.Identity);

			// Material for spatial surfaces
			spatialMaterial = new Material();
			spatialMaterial.SetTechnique(0, CoreAssets.Techniques.NoTextureUnlitVCol, 1, 1);

			// make sure 'spatialMapping' capabilaty is enabled in the app manifest.
			var spatialMappingAllowed = await StartSpatialMapping(new Vector3(50, 50, 10), 1200);
		}