Create Images Exibition with ARPortal using Augmented reality in iOS












0















I'm working on an app that create picture/images exhibition room using Augmented Reality. Till now referencing from tutorials i'm able to make a ARPortal(room) .scn file, which looks good. next i want to add number of node having content as image inside that room. As, .scn file i created in xcode and loads after horizontal plane detects. Also i tried with adding box and adding images as SCNmaterial after scn loads. But it doesn't seems to be working as expected. Any guide would be really apreciated. Below is my code



func addExibitionRoom(hitResult : ARHitTestResult) {

let scn = SCNScene(named: "art.scnassets/Gallery.scn")
guard let portalNode = scn?.rootNode.childNode(withName: "portal", recursively: false) else {
print("portal node not found")
return}
let tranform = hitResult.worldTransform
let planeXPosition = tranform.columns.3.x
let planeYPosition = tranform.columns.3.y
let planeZPosition = tranform.columns.3.z
portalNode.position = SCNVector3(planeXPosition,planeYPosition,planeZPosition)
self.sceneView.scene.rootNode.addChildNode(portalNode)
addWall(nodeName: "doorwallleft", parent: portalNode, image: "sideDoorA")
addWall(nodeName: "doorwallright", parent: portalNode, image: "sideDoorB")
addWall(nodeName: "sidewallleft", parent: portalNode, image: "sideA")
addWall(nodeName: "sidewallright", parent: portalNode, image: "sideB")
addWall(nodeName: "backwall", parent: portalNode, image: "back")
addPlaneContent(nodeName: "top", parent: portalNode, image: "top")
addPlaneContent(nodeName: "floor", parent: portalNode, image: "bottom")
addImagesToExibition(node: portalNode)
}
func addImagesToExibition(node : SCNNode){
//getting floor node
let childNode = node.childNode(withName: "floor", recursively: true)
let photoRingNode = SCNNode()
photoRingNode.geometry?.firstMaterial?.diffuse.contents = UIColor.white
photoRingNode.position = SCNVector3Make(0, 0, -0.9)
childNode?.addChildNode(photoRingNode)
let photoW: CGFloat = 1.8
let photoH: CGFloat = photoW * 0.618
let imageArray = [UIImage(named: "image001.png"),UIImage(named: "image002.png"),UIImage(named: "image003.png"),UIImage(named: "image004.png"),UIImage(named: "image005.png"),UIImage(named: "image006.png"),UIImage(named: "image007.png")]
let boxW: CGFloat = 0.36
var materials: [SCNMaterial] =

for image in imageArray {
let box = SCNBox(width: boxW, height: boxW, length: boxW, chamferRadius: 0)
let material = SCNMaterial()
material.multiply.contents = image
materials.append(material)
box.materials = materials
let boxNode = SCNNode(geometry: box)
let photo = SCNPlane(width: photoW, height: photoH)
photoRingNode.addChildNode(boxNode)
}
}









share|improve this question



























    0















    I'm working on an app that create picture/images exhibition room using Augmented Reality. Till now referencing from tutorials i'm able to make a ARPortal(room) .scn file, which looks good. next i want to add number of node having content as image inside that room. As, .scn file i created in xcode and loads after horizontal plane detects. Also i tried with adding box and adding images as SCNmaterial after scn loads. But it doesn't seems to be working as expected. Any guide would be really apreciated. Below is my code



    func addExibitionRoom(hitResult : ARHitTestResult) {

    let scn = SCNScene(named: "art.scnassets/Gallery.scn")
    guard let portalNode = scn?.rootNode.childNode(withName: "portal", recursively: false) else {
    print("portal node not found")
    return}
    let tranform = hitResult.worldTransform
    let planeXPosition = tranform.columns.3.x
    let planeYPosition = tranform.columns.3.y
    let planeZPosition = tranform.columns.3.z
    portalNode.position = SCNVector3(planeXPosition,planeYPosition,planeZPosition)
    self.sceneView.scene.rootNode.addChildNode(portalNode)
    addWall(nodeName: "doorwallleft", parent: portalNode, image: "sideDoorA")
    addWall(nodeName: "doorwallright", parent: portalNode, image: "sideDoorB")
    addWall(nodeName: "sidewallleft", parent: portalNode, image: "sideA")
    addWall(nodeName: "sidewallright", parent: portalNode, image: "sideB")
    addWall(nodeName: "backwall", parent: portalNode, image: "back")
    addPlaneContent(nodeName: "top", parent: portalNode, image: "top")
    addPlaneContent(nodeName: "floor", parent: portalNode, image: "bottom")
    addImagesToExibition(node: portalNode)
    }
    func addImagesToExibition(node : SCNNode){
    //getting floor node
    let childNode = node.childNode(withName: "floor", recursively: true)
    let photoRingNode = SCNNode()
    photoRingNode.geometry?.firstMaterial?.diffuse.contents = UIColor.white
    photoRingNode.position = SCNVector3Make(0, 0, -0.9)
    childNode?.addChildNode(photoRingNode)
    let photoW: CGFloat = 1.8
    let photoH: CGFloat = photoW * 0.618
    let imageArray = [UIImage(named: "image001.png"),UIImage(named: "image002.png"),UIImage(named: "image003.png"),UIImage(named: "image004.png"),UIImage(named: "image005.png"),UIImage(named: "image006.png"),UIImage(named: "image007.png")]
    let boxW: CGFloat = 0.36
    var materials: [SCNMaterial] =

    for image in imageArray {
    let box = SCNBox(width: boxW, height: boxW, length: boxW, chamferRadius: 0)
    let material = SCNMaterial()
    material.multiply.contents = image
    materials.append(material)
    box.materials = materials
    let boxNode = SCNNode(geometry: box)
    let photo = SCNPlane(width: photoW, height: photoH)
    photoRingNode.addChildNode(boxNode)
    }
    }









    share|improve this question

























      0












      0








      0








      I'm working on an app that create picture/images exhibition room using Augmented Reality. Till now referencing from tutorials i'm able to make a ARPortal(room) .scn file, which looks good. next i want to add number of node having content as image inside that room. As, .scn file i created in xcode and loads after horizontal plane detects. Also i tried with adding box and adding images as SCNmaterial after scn loads. But it doesn't seems to be working as expected. Any guide would be really apreciated. Below is my code



      func addExibitionRoom(hitResult : ARHitTestResult) {

      let scn = SCNScene(named: "art.scnassets/Gallery.scn")
      guard let portalNode = scn?.rootNode.childNode(withName: "portal", recursively: false) else {
      print("portal node not found")
      return}
      let tranform = hitResult.worldTransform
      let planeXPosition = tranform.columns.3.x
      let planeYPosition = tranform.columns.3.y
      let planeZPosition = tranform.columns.3.z
      portalNode.position = SCNVector3(planeXPosition,planeYPosition,planeZPosition)
      self.sceneView.scene.rootNode.addChildNode(portalNode)
      addWall(nodeName: "doorwallleft", parent: portalNode, image: "sideDoorA")
      addWall(nodeName: "doorwallright", parent: portalNode, image: "sideDoorB")
      addWall(nodeName: "sidewallleft", parent: portalNode, image: "sideA")
      addWall(nodeName: "sidewallright", parent: portalNode, image: "sideB")
      addWall(nodeName: "backwall", parent: portalNode, image: "back")
      addPlaneContent(nodeName: "top", parent: portalNode, image: "top")
      addPlaneContent(nodeName: "floor", parent: portalNode, image: "bottom")
      addImagesToExibition(node: portalNode)
      }
      func addImagesToExibition(node : SCNNode){
      //getting floor node
      let childNode = node.childNode(withName: "floor", recursively: true)
      let photoRingNode = SCNNode()
      photoRingNode.geometry?.firstMaterial?.diffuse.contents = UIColor.white
      photoRingNode.position = SCNVector3Make(0, 0, -0.9)
      childNode?.addChildNode(photoRingNode)
      let photoW: CGFloat = 1.8
      let photoH: CGFloat = photoW * 0.618
      let imageArray = [UIImage(named: "image001.png"),UIImage(named: "image002.png"),UIImage(named: "image003.png"),UIImage(named: "image004.png"),UIImage(named: "image005.png"),UIImage(named: "image006.png"),UIImage(named: "image007.png")]
      let boxW: CGFloat = 0.36
      var materials: [SCNMaterial] =

      for image in imageArray {
      let box = SCNBox(width: boxW, height: boxW, length: boxW, chamferRadius: 0)
      let material = SCNMaterial()
      material.multiply.contents = image
      materials.append(material)
      box.materials = materials
      let boxNode = SCNNode(geometry: box)
      let photo = SCNPlane(width: photoW, height: photoH)
      photoRingNode.addChildNode(boxNode)
      }
      }









      share|improve this question














      I'm working on an app that create picture/images exhibition room using Augmented Reality. Till now referencing from tutorials i'm able to make a ARPortal(room) .scn file, which looks good. next i want to add number of node having content as image inside that room. As, .scn file i created in xcode and loads after horizontal plane detects. Also i tried with adding box and adding images as SCNmaterial after scn loads. But it doesn't seems to be working as expected. Any guide would be really apreciated. Below is my code



      func addExibitionRoom(hitResult : ARHitTestResult) {

      let scn = SCNScene(named: "art.scnassets/Gallery.scn")
      guard let portalNode = scn?.rootNode.childNode(withName: "portal", recursively: false) else {
      print("portal node not found")
      return}
      let tranform = hitResult.worldTransform
      let planeXPosition = tranform.columns.3.x
      let planeYPosition = tranform.columns.3.y
      let planeZPosition = tranform.columns.3.z
      portalNode.position = SCNVector3(planeXPosition,planeYPosition,planeZPosition)
      self.sceneView.scene.rootNode.addChildNode(portalNode)
      addWall(nodeName: "doorwallleft", parent: portalNode, image: "sideDoorA")
      addWall(nodeName: "doorwallright", parent: portalNode, image: "sideDoorB")
      addWall(nodeName: "sidewallleft", parent: portalNode, image: "sideA")
      addWall(nodeName: "sidewallright", parent: portalNode, image: "sideB")
      addWall(nodeName: "backwall", parent: portalNode, image: "back")
      addPlaneContent(nodeName: "top", parent: portalNode, image: "top")
      addPlaneContent(nodeName: "floor", parent: portalNode, image: "bottom")
      addImagesToExibition(node: portalNode)
      }
      func addImagesToExibition(node : SCNNode){
      //getting floor node
      let childNode = node.childNode(withName: "floor", recursively: true)
      let photoRingNode = SCNNode()
      photoRingNode.geometry?.firstMaterial?.diffuse.contents = UIColor.white
      photoRingNode.position = SCNVector3Make(0, 0, -0.9)
      childNode?.addChildNode(photoRingNode)
      let photoW: CGFloat = 1.8
      let photoH: CGFloat = photoW * 0.618
      let imageArray = [UIImage(named: "image001.png"),UIImage(named: "image002.png"),UIImage(named: "image003.png"),UIImage(named: "image004.png"),UIImage(named: "image005.png"),UIImage(named: "image006.png"),UIImage(named: "image007.png")]
      let boxW: CGFloat = 0.36
      var materials: [SCNMaterial] =

      for image in imageArray {
      let box = SCNBox(width: boxW, height: boxW, length: boxW, chamferRadius: 0)
      let material = SCNMaterial()
      material.multiply.contents = image
      materials.append(material)
      box.materials = materials
      let boxNode = SCNNode(geometry: box)
      let photo = SCNPlane(width: photoW, height: photoH)
      photoRingNode.addChildNode(boxNode)
      }
      }






      ios augmented-reality arkit






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 10:10









      Nitisha SharmaNitisha Sharma

      236




      236
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54004436%2fcreate-images-exibition-with-arportal-using-augmented-reality-in-ios%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54004436%2fcreate-images-exibition-with-arportal-using-augmented-reality-in-ios%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]