3

I've got an image that im trying to add to the current camera location of the Screenview ARSCNView session. Whatever I do it seems to put the image behind the current location of the phone camera and i have to move it back to see it. I have the following code:

var currentFrame = SceneView.Session.CurrentFrame;

if (currentFrame == null) return;

var threeVector = new SCNVector3(currentFrame.Camera.Transform.Column3.X + 0.005f, 
       currentFrame.Camera.Transform.Column3.Y - 0.02f, 
       currentFrame.Camera.Transform.Column3.Z - 0.05f);

var scaleFactor = imgToAdd.Size.Width / 0.05;
float width = float.Parse((imgToAdd.Size.Width / scaleFactor).ToString());
float height = float.Parse((imgToAdd.Size.Height / scaleFactor).ToString());

var box = new SCNPlane {
    Width = width,
    Height = height
};

var cubeNode = new SCNNode {
    Position = threeVector,
    Geometry = box
};
var mat = new SCNMaterial();
mat.Diffuse.Contents = imgToAdd;
mat.LocksAmbientWithDiffuse = true;
cubeNode.Geometry.Materials = new[] { mat };
SceneView.Scene.RootNode.AddChildNode(cubeNode);

Just trying to execute a simple idea of the ARKit paint apps that you see all over the app store now. So the imgToAdd is a snapshot of the scribble that the user has already put onto the screen and this event is fired at the touchended after an image is created from the view scribbled on.

Any ideas on what I need to change to get it to line up with the current view of the camera on the phone?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Matt
  • 3,305
  • 11
  • 54
  • 98
  • Is it always happening the same way irrespective of how far/near you put the node you're trying to add? Have you tried it with say, the currentFrame.Camera.Transform.Column3.Z -/+ 1.00f for example? If it's always coming out the same, then the issue would be with how you're determining the position. – Alan Oct 20 '17 at 07:16
  • Have you checked official sample https://developer.xamarin.com/samples/monotouch/ios11/ARKitSample/ ? – ColeX Oct 23 '17 at 06:19

0 Answers0