void UpdateAnchor(Node node, ARAnchor anchor) { return; // waits fix for https://bugzilla.xamarin.com/show_bug.cgi?id=58648 if (anchor is ARPlaneAnchor planeAnchor) { Node planeNode = null; if (node == null) { var id = planeAnchor.Identifier.ToString(); node = AnchorsNode.CreateChild(id); planeNode = node.CreateChild("SubPlane"); var plane = planeNode.CreateComponent <StaticModel>(); planeNode.Position = new Vector3(); plane.Model = CoreAssets.Models.Plane; plane.Material = ResourceCache.GetMaterial("Materials/PlaneTileMat.xml"); } else { planeNode = node.GetChild("SubPlane"); } ApplyTransform(node, planeAnchor.Transform); planeNode.Scale = new Vector3(planeAnchor.Extent.X, 0.1f, planeAnchor.Extent.Z); planeNode.Position = new Vector3(planeAnchor.Center.X, planeAnchor.Center.Y, -planeAnchor.Center.Z); Debug.WriteLine($"ARPlaneAnchor Extent({planeAnchor.Extent}), Center({planeAnchor.Center}), Position({planeAnchor.Transform.Row3}"); } }
void UpdateAnchor(Node node, ARAnchor anchor) { if (anchor is ARPlaneAnchor planeAnchor) { Material tileMaterial = null; Node planeNode = null; if (node == null) { var id = planeAnchor.Identifier.ToString(); node = AnchorsNode.CreateChild(id); planeNode = node.CreateChild("SubPlane"); var plane = planeNode.CreateComponent <StaticModel>(); planeNode.Position = new Vector3(); plane.Model = CoreAssets.Models.Plane; tileMaterial = new Material(); tileMaterial.SetTexture(TextureUnit.Diffuse, ResourceCache.GetTexture2D("Textures/PlaneTile.png")); var tech = new Technique(); var pass = tech.CreatePass("alpha"); pass.DepthWrite = false; pass.BlendMode = BlendMode.Alpha; pass.PixelShader = "PlaneTile"; pass.VertexShader = "PlaneTile"; tileMaterial.SetTechnique(0, tech); tileMaterial.SetShaderParameter("MeshColor", Color.White); tileMaterial.SetShaderParameter("MeshAlpha", 0.8f); // set 0.0f if you want to hide them tileMaterial.SetShaderParameter("MeshScale", 15.0f); var planeRb = planeNode.CreateComponent <RigidBody>(); planeRb.Friction = 1.5f; CollisionShape shape = planeNode.CreateComponent <CollisionShape>(); shape.SetBox(Vector3.One, Vector3.Zero, Quaternion.Identity); plane.Material = tileMaterial; } else { planeNode = node.GetChild("SubPlane"); tileMaterial = planeNode.GetComponent <StaticModel>().Material; } ApplyTransform(node, planeAnchor.Transform); planeNode.Scale = new Vector3(planeAnchor.Extent.X, 0.1f, planeAnchor.Extent.Z); planeNode.Position = new Vector3(planeAnchor.Center.X, planeAnchor.Center.Y, -planeAnchor.Center.Z); var animation = new ValueAnimation(); animation.SetKeyFrame(0.0f, 0.8f); animation.SetKeyFrame(0.3f, 0.0f); tileMaterial.SetShaderParameterAnimation("MeshAlpha", animation, WrapMode.Once, 1.0f); Debug.WriteLine($"ARPlaneAnchor Extent({planeAnchor.Extent}), Center({planeAnchor.Center}), Position({planeAnchor.Transform.Row3}"); } }