3 Replies
      Latest reply: Sep 30, 2017 7:46 PM by TonyPham RSS
      hotmeatballsoup Level 1 Level 1 (0 points)

        I'm trying to understand how to manipulate *.scn asset files in ARKit, which as I understand it, is the file format for 3D models that we wish to "inject" into the camera's view of the world (hence augmenting reality). So given a particular *.scn file (model), I'm wondering:

         

        • How does one position and orient the asset/3D model inside the world coordinates at a specific coordinate of their choosing, say, (x,y,z) : (10, 15, -5)?
        • What ARKit/SCNKit API methods can I use to update model position at any given time?

         

        For example, given the following some_tree.scn file that provides a 3D model (and its texture) of a tree:

         

            sceneView.delegate = self

            let scene = SCNScene(named: "art.scnassets/some_tree.scn")!

            sceneView.scene = scene

         

        It is my understanding that the SCN file itself will contain some default coordinates to render inside the scene at; if this is true, how can I override these default coordinates so that I can render the tree on a set of coordinates of my own choosing (again, say (10,15,-5))? But again, the main question from above is:

         

        • What API does ARKit provide for positioning & orienting an SCN asset file in any location/position I want?
        • What API does ARKit provide for me to update this position at any given point in time?

         

        Thanks in advance for any and all help!

        • Re: ARKit APIs for updating SCN asset positions
          TonyPham Level 2 Level 2 (80 points)

          My few cents:

          - our 2D (SpriteKit) / 3D (SceneKit) objects are not "injected" into camera view. They are actually shown in front of camera's view

          - loading a scn is loading a scene. That scene may contains some models. If you don't want to use default positioned models, you may re-locate them. First you need to get the root node of a model. Typically we do that via model's name (use the function scene.rootNode.childNode(withName: recursively: ). Once you got model node you may remove it from that scene and then add to your main or other scene (that is also the way we load models from multi scn files to show in one scene), and/or reposition it to where you want

          - to update positions manually, the best place is in function renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval)

            • Re: ARKit APIs for updating SCN asset positions
              hotmeatballsoup Level 1 Level 1 (0 points)

              Thanks for you input @TonyPham, a few followup questions if you don't mind!

               

              1) What is the proper term to use when I say "camera view"? Viewport maybe? I'm just looking to use the correct terminology when referring to the "world" as the camera sees/understands it.

               

              2) Is a "scene" the same as the concept of a "scene graph" from 3D gaming? If so, I assume its something like a k-node tree? And am I correct in guessing that a SCN file is just a file that describes to SCNKit how to display the scene at startup (default positions, relationships between parent + child nodes, etc.)?

               

              3) What I'm really/ultimately after is a way to detect flat surfaces (horizontal planes), get their coordinates/locations in the camera view, and then render my scene models at those locations (so that my 3D models appear to be standing on these flat surfaces). Any ideas what API methods are available to me for this type of plane detection?

               

              Thanks again so much!

                • Re: ARKit APIs for updating SCN asset positions
                  TonyPham Level 2 Level 2 (80 points)

                  1) + 2) I won't answer since many people are much better than me in both English and knowledge

                   

                  3) What you need is very basic. I suggest you to download and study the main Example code (PlaceObjects). In that example you may learn how to load a scn file directly into a SCNNode (as a rootNode of a model), detect plane / anchor and then add the loaded model (model's node) to that.

                  Happy coding