The SetPositionAndRotation() method will be used by both the Add and Update anchors, so we need to define it before creating the handlers for the events that will be raised by ARKit. Let's set this up by going through the following steps:
- In the WhackABox.iOS project, open the Game.cs file.
- Add the SetPositionAndRotation() method to the class, as shown in the following code block:
private void SetPositionAndRotation(ARPlaneAnchor anchor, PlaneNode
node)
{
arkitComponent.ApplyOpenTkTransform(node, anchor.Transform,
true);
node.ExtentX = anchor.Extent.X;
node.ExtentZ = anchor.Extent.Z;
var position = new Vector3(anchor.Center.X, anchor.Center.Y, -
anchor.Center.Z);
UpdateSubPlane(node, position);
}
The method takes two parameters. The first is an ARPlaneAnchor object defined by ARKit, and the second is the PlaneNode...