1

How do I get the 2d points to plot on to uiview from 3d SCNNode.

Suppose I have following SCNNodes

pos(1.002163 -0.524722 -0.770023)
pos(1.174463 -0.765098 -0.607172)
pos(0.668790 -0.744061 -0.696863)
pos(0.781208 -0.744061 -1.228943)

And I need 2d points from above. I am new to Arkit.

halfer
  • 19,824
  • 17
  • 99
  • 186
Yogesh Dalavi
  • 73
  • 4
  • 15

1 Answers1

2

You are looking for projectPoint

let projectedPoint = sceneView.projectPoint(pos)
Alok Subedi
  • 1,601
  • 14
  • 26
  • hi..alok i have tried your suggestion but sometimes it gives negative points so how to deal with it? – Yogesh Dalavi Jun 12 '18 at 05:35
  • can you explain more? points may come outside of frame if node is not seen on screen. – Alok Subedi Jun 12 '18 at 06:08
  • I have converted the nodes from projectPoint() to 2d points and those are like below pos(332.943787 1097.237915 0.998662) pos(478.228455 1085.898193 0.998638) pos(486.574646 1085.392700 0.998639) pos(332.155975 1095.047607 0.998632) i got "x" and "y" and ignore the "z" . But some times the x and y are negative and that was problem for me .? – Yogesh Dalavi Jun 12 '18 at 06:24
  • I want to draw a frame on uiview like square from the four scnnode points. so help me regarding the same. – Yogesh Dalavi Jun 12 '18 at 06:35
  • 1
    https://stackoverflow.com/questions/49443228/creating-path-using-cgmutablepath-creates-line-to-wrong-cgpoint – Alok Subedi Jun 12 '18 at 07:31
  • And you need to overlay spriteScene with frame size equal to ARSceneView in the link above – Alok Subedi Jun 12 '18 at 08:04
  • Are those points get from projectPoint method are real uiview compatible points? – Yogesh Dalavi Jun 21 '18 at 07:20
  • Yes as far as I know. The project in link I mentioned needed to track 3d point on real time and it gave great result. – Alok Subedi Jun 22 '18 at 05:39
  • hi @YogeshDalavi you got 2d coordinates (332.943787 1097.237915 0.998662). But an iPhone x max has only height less than 1000. So how did you manage 1097. Do we need to do any convertion ? – jpulikkottil Jun 19 '19 at 12:34
  • Yes you need to convert it to your scale so that it fit to your screen. – Yogesh Dalavi Jun 21 '19 at 04:38
  • @AlokSubedi Can you please help on using project point with face-tracking SCNodes? – swiftlearneer Aug 01 '20 at 23:18
  • 1
    @swiftlearneer I am sorry, I cant. I have iPhone 8 so no truedepth camera. – Alok Subedi Aug 03 '20 at 06:34