天道酬勤,学无止境

arkit

How to find the user position on a 2d floor plan if other coordinates (3 or more points) are given in unity?

Is it possible to find the position of user if the coordinates of A,B and c are known which is taken as A(floorpointx1,floorpointy1),B(floorpointx2,floorpointy2)and C(floorpointx3,floorpointy3) .D1,D2 and D3 can also be provided.With all these details can we find the user's position[User(floorpoint_x,floorpoint_y)]? float D1 = Vector3.Distance(userposition, PointAPosition); float D2 = Vector3.Distance(userposition, PointBPosition); float D3 = Vector3.Distance(userposition, PointCPosition);

2021-09-24 08:44:17    分类:问答    unity3d   arkit   euclidean-distance

Implement a crosshair kind behaviour in RealityKit

What I want to achieve: Attach a sphere to the camera position (so that it always stay at the center of the screen as the device move) and detect when it is on top of other AR objects - to trigger other actions/behaviour on the AR objects. Approach: I have created the sphere and attached to the center of the screen as shown below @IBOutlet var arView: ARView! override func viewDidLoad() { super.viewDidLoad() let mesh = MeshResource.generateSphere(radius: 0.1) let sphere = ModelEntity(mesh: mesh) let anchor = AnchorEntity(.camera) sphere.setParent(anchor) arView.scene.addAnchor(anchor) sphere

2021-09-24 07:03:10    分类:问答    swift   augmented-reality   arkit   realitykit   reality-composer

How to Center the Pivot Point of a Model in SceneKit Editor

Is there anyway to center the pivot of a model? Currently (by default) it is set to the bottom left. I want to set to the center. How can I do that? Here is the image: UPDATE: I added another node and added the chair as a child. So, now it works better but it does not rotate all the way and it resets the position if I continue to rotate. Here is the code for the panned operation: @objc func panned(recognizer :UIPanGestureRecognizer) { var newAngleY :Float = 0.0 if recognizer.state == .changed { let sceneView = recognizer.view as! ARSCNView let touchPoint = recognizer.location(in: sceneView)

2021-09-23 21:57:30    分类:问答    ios   scenekit   arkit

Using ARKit anchor to place RealityKit Scene

I am currently struggling to add an RealityKit Scene to an ARKit anchor. As my previous question, it is not possible to directly add the RealityKit Scene to an ARKit Anchor Node. But how can I use the ARKit Anchor to place my Scene? For example, I want to find an object in the room, and depending on which object I found, I want to use different scenes and anchor them in the room depending on the recognised objects position. Thanks for the help. Current try: func makeUIView(context: Context) -> ARView { let arView = ARView(frame: .zero) // Load the "Box" scene from the "Experience" Reality File

2021-09-09 05:00:17    分类:问答    swift   swiftui   augmented-reality   arkit   realitykit

Error "OBJ file has no faces"

I want to place an obj-3D-Model with ARKit and SceneKit. That's the model I'm using: https://free3d.com/3d-model/chest-50529.html I'm using the following code: private func createChestFromScene(_ position: SCNVector3) -> SCNNode? { guard let url = Bundle.main.url(forResource: "art.scnassets/Models/chest", withExtension: "obj") else { NSLog("Could not find door scene") return nil } guard let node = SCNReferenceNode(url: url) else { return nil } node.load() // Position scene node.position = position return node } However, I get the following error: OBJ file has no faces. Why? - Thanks.

2021-09-08 05:46:14    分类:问答    ios   swift   scenekit   arkit

How to capture image in ARKit and send Binary data?

I want to make a capture image in ARKit and send byte array to TCP server. Well This is my code. @IBOutlet weak var sceneView: ARSCNView! @IBAction func sendButtonAction(_ sender: Any) { let captureImage:UIImage = self.sceneView.snapshot() } I can get image by snapshot but i don't know how convert it to Byte Array (include pixel R,G,B Data.) I tried to change UIImage to binary data like this. let imageData: NSData = UIImagePNGRepresentation(captureImage)! as NSData but this is not correct because imageData's size is mutable whenever i snapshot :( My purpose is to make a captureImage's Byte

2021-09-07 18:36:39    分类:问答    ios   uiimage   arkit

how to re-render the scanned mesh content with realityKit's ARView?

I can modify the line color of the mesh using the following code. extension ARMeshClassification { var description: String { switch self { case .ceiling: return "Ceiling" case .door: return "Door" case .floor: return "Floor" case .seat: return "Seat" case .table: return "Table" case .wall: return "Wall" case .window: return "Window" case .none: return "None" @unknown default: return "Unknown" } } var color: UIColor { switch self { case .ceiling: return .red case .door: return .green case .floor: return .blue case .seat: return .cyan case .table: return .magenta case .wall: return .yellow case

2021-09-07 18:31:54    分类:问答    ios   arkit   realitykit   lidar

Hide area of an SCNMaterial

I'm using SceneKit and ARKit 1.5, once a surface has been mapped I apply a material to it. I would like to only show what's under the camera in a certain radius with an alpha effect. I want to keep the material static meaning that it does not move when the camera moves, only the radius shape will move. What kind of technique could I use for this ? ArCore by Google does this perfectly. Actual rendering: Desired Rendering: ARCore example: (click to see GIF) Thank you!

2021-09-07 08:42:02    分类:问答    shader   scenekit   mask   arkit   scnmaterial

RealityKit – Stored Entities & Load the Scene Aynchronously from the URL

Here is Apple Documentation: 1.Loading Reality Composer Files Manually Without Generated Code and I used the "Load the Scene Aynchronously from the URL" code: func loadRealityComposerSceneAsync (filename: String, fileExtension: String, sceneName: String, completion: @escaping (Swift.Result<(Entity & HasAnchoring)?, Swift.Error>) -> Void) { guard let realityFileSceneURL = createRealityURL(filename: filename, fileExtension: fileExtension, sceneName: sceneName) else { print("Error: Unable to find specified file in application bundle") return } let loadRequest = Entity.loadAnchorAsync(contentsOf

2021-09-07 06:43:00    分类:问答    swift   asynchronous   arkit   realitykit   reality-composer

Adding CIFilter to SCNNode turns node into white box

I'd like to add a CIGaussianBlur to a SCNNode that is being displayed in ARKit. However, adding that filter turns the node into "a white box". Here is the node without and with filter. No CIFilter With CIFilter Here is the relevant code: let gaussianBlurFilter = CIFilter(name: "CIGaussianBlur")! gaussianBlurFilter.name = "blur" node.filters = [gaussianBlurFilter] let material = node.geometry?.firstMaterial material?.diffuse.contents = UIColor.blue node.position = SCNVector3(x: 0, y: 0, z: -0.39) camera.addChildNode(node) Previous Stack Overflow questions have suggested that adding a CIFilter

2021-09-04 19:13:11    分类:问答    ios   scenekit   arkit