Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
91 views
in Technique[技术] by (71.8m points)

Placenote Swift - Wrong position after loading the same map

I have used swift IOS for creating map and loading map. In creating function, I tried to add an object on the map and recorded its SCNVector3 location in Placenote database. After relaunching the app and loading the same map, I place the object on the recorded SCNVector3 location but the object is placed in another position.

The above problem only happens when I restart the app. Does anyone have the same problem? Thanks.

@IBAction func createMap(_ sender: Any) {
      LibPlacenote.instance.startSession()
      self.ptViz?.enablePointcloud()
      self.tapGestureRecognizer?.isEnabled = true

      // handleTap function added the object name & its SCNVector3 location
}

@IBAction func saveMap(_ sender: Any) {
      LibPlacenote.instance.saveMap(
            savedCb: { (mapID: String?) -> Void in
                  LibPlacenote.instance.stopSession()
                  self.ptViz?.clearPointCloud()
                  self.tapGestureRecognizer?.isEnabled = false

                  let metadata = LibPlacenote.MapMetadataSettable()
                  metadata.name = "test"

                  // self.userdata included all the object location
                  metadata.userdata = self.userdata
                        
                  if (!LibPlacenote.instance.setMetadata(mapId: mapID!, metadata: metadata, metadataSavedCb: {(success: Bool) -> Void in})) {
                       print ("Failed to set map metadata")
                  }
}

// Loaded Map
func onLocalized() {
      for item in self.objectList {
            let x = Float(item["userData"]!["x"]!)!
            let y = Float(item["userData"]!["y"]!)!
            let z = Float(item["userData"]!["z"]!)!

            let location = item["userData"]!["location"]!
            let position = SCNVector3(x: x, y: y, z: z)

            self.addLocation(location: location, position: position)
        }
}

Placenote database: enter image description here

question from:https://stackoverflow.com/questions/65920198/placenote-swift-wrong-position-after-loading-the-same-map

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...