'Get an URL from SCNScene
In the apple example code for ARKit, they provided a VirtualObjectclass that load Scn files from Models.scnassets.
static let availableObjects: [VirtualObject] = {
let modelsURL = Bundle.main.url(forResource: "Models.scnassets", withExtension: nil)!
let fileEnumerator = FileManager().enumerator(at: modelsURL, includingPropertiesForKeys: [])!
return fileEnumerator.compactMap { element in
let url = element as! URL
guard url.pathExtension == "scn" && !url.path.contains("lighting") else { return nil }
return VirtualObject(url: url)
}
}()
Let's say I have a SCNScene that download from a sever, the first question is, this SCNScene is similar to scn files?
if yes, how can I add this SCNScene to the above function, and get its URL to add it in the return VirtualObject(url: url) ? I stuck in this part for days, would be appreciated if anyone can help me.
Solution 1:[1]
Problem solved. See: https://pkg.go.dev/cmd/cgo#hdr-C_references_to_Go
Using //export in a file places a restriction on the preamble: since it is copied into two different C output files, it must not contain any definitions, only declarations. If a file contains both definitions and declarations, then the two output files will produce duplicate symbols and the linker will fail. To avoid this, definitions must be placed in preambles in other files, or in C source files.
Moving the following code into a separate .go file:
/*
typedef void (*int_int)(int, int);
void bridge_int_int(int a, int b, int_int f){
f(a, b);
}
*/
import "C"
and changing it to
/*
typedef void (*int_int)(int, int);
extern bridge_int_int(int a, int b, int_int f);
}
*/
import "C"
...
in the original file solved the problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Robert M. Münch |
