Hello usd team,
The WWDC 10141 talk mentions documentation comparing RealityKit vs Storm, but I didn’t find it.
is it available already?
thanks!
Post
Replies
Boosts
Views
Activity
Great session!
Will the demo app source code be available?
tks
Hello USD team,
Thanks for the great demo USD and Hydra/Storm demo!
Is it possible to build an app with USD Hydra/Storm -> SwiftUI interactions?
Ex: a car configurator that has:
a car as a USD file
animations desired on the USD file.
SwiftUI button to opens the doors, another button to play a sound, etc?
everything rendered in Hydra/Storm. as the demo app
Thanks.
On Scenekit, using SCNShapewe can create SCN geometry from SwiftUI 2D shapes/beziers:https://developer.apple.com/documentation/scenekit/scnshape
Is there an equivalent in RealityKit?
Could we use the generate(from:) for that?https://developer.apple.com/documentation/realitykit/meshresource/3768520-generate
https://developer.apple.com/documentation/realitykit/meshresource/3768520-generate
Goal:
Rewrite CoreGraphics resizing function from iOS (UIImage) to MacOS (NSImage)
Problem:
Getting error on this line of code: let bytesPerPixel = cgImage.bitsPerPixel / bitsPerComponent
Error: Value of type '(UnsafeMutablePointer?, NSGraphicsContext?, [NSImageRep.HintKey : Any]?) - CGImage?' (aka '(OptionalUnsafeMutablePointer, Optional, OptionalDictionaryNSImageRep.HintKey, Any) - Optional') has no member 'bitsPerPixel'
Question: how can I replace "cgImage.bitsPerPixel" for something that works with NSImage?
iOS: UIImage
extension UIImage {
// Resizeing using CoreGraphics
func resize(to size:CGSize) - UIImage? {
let cgImage = self.cgImage!
let destWidth = Int(size.width)
let destHeight = Int(size.height)
let bitsPerComponent = 8
let bytesPerPixel = cgImage.bitsPerPixel / bitsPerComponent
let destBytesPerRow = destWidth * bytesPerPixel
let context = CGContext(data: nil,
width: destWidth,
height: destHeight,
bitsPerComponent: bitsPerComponent,
bytesPerRow: destBytesPerRow,
space: cgImage.colorSpace!,
bitmapInfo: cgImage.bitmapInfo.rawValue)!
context.interpolationQuality = .high
context.draw(cgImage, in: CGRect(origin: CGPoint.zero, size: size))
return context.makeImage().flatMap { UIImage(cgImage: $0) }
}
}
MacOS: NSImage
extension NSImage {
// Resizeing using CoreGraphics
func resize(to size:CGSize) - NSImage? {
let cgImage = self.cgImage
let destWidth = Int(size.width)
let destHeight = Int(size.height)
let bitsPerComponent = 8
let bytesPerPixel = cgImage.bitsPerPixel / bitsPerComponent
let destBytesPerRow = destWidth * bytesPerPixel
let context = CGContext(data: nil,
width: destWidth,
height: destHeight,
bitsPerComponent: bitsPerComponent,
bytesPerRow: destBytesPerRow,
space: cgImage.colorSpace!,
bitmapInfo: cgImage.bitmapInfo.rawValue)!
context.interpolationQuality = .high
context.draw(cgImage, in: CGRect(origin: CGPoint.zero, size: size))
return context.makeImage().flatMap { NSImage(cgImage: $0) }
}
}
Goal:
export multiple images with .fileExporter
What I did:
Code 1 bellow works fine for MacOS, export multiple files.
Problem:
When I replace for UIImage, it exports only 1 image
Question:
How can I export multiple images using .fileExporter in iOS?
Code 1 bellow works fine for MacOS, export multiple files.
import SwiftUI
class AppContext: ObservableObject {
@Published var fileSaveDialogShown = false
}
@main
struct FocalApp: App {
@StateObject var appContext = AppContext()
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(self.appContext)
.fileExporter(
isPresented: $appContext.fileSaveDialogShown,
documents: [
ImageDocument(image: NSImage(named: "1")),
ImageDocument(image: NSImage(named: "2"))
],
contentType: .jpeg // Match this to your representation in ImageDocument
) { url in
print("Saved to", url) // [URL]
}
}
}
}
import SwiftUI
import UniformTypeIdentifiers
struct ImageDocument: FileDocument {
static var readableContentTypes: [UTType] { [.jpeg, .png, .tiff] }
var image: NSImage
init(image: NSImage?) {
self.image = image ?? NSImage()
}
init(configuration: ReadConfiguration) throws {
guard let data = configuration.file.regularFileContents,
let image = NSImage(data: data)
else {
throw CocoaError(.fileReadCorruptFile)
}
self.image = image
}
func fileWrapper(configuration: WriteConfiguration) throws - FileWrapper {
// You can replace tiff representation with what you want to export
return FileWrapper(regularFileWithContents: image.tiffRepresentation!)
}
}
struct ContentView: View {
@EnvironmentObject var appContext: AppContext
var body: some View {
VStack {
Button(action: {
appContext.fileSaveDialogShown.toggle()
}, label: {
Text("Button")
})
}
.frame(width: 200, height: 200)
}
}
When I replace for UIImage, it exports only 1 image
import SwiftUI
class AppContext: ObservableObject {
@Published var fileSaveDialogShown = false
}
@main
struct FocalApp: App {
@StateObject var appContext = AppContext()
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(self.appContext)
.fileExporter(
isPresented: $appContext.fileSaveDialogShown,
documents: [
ImageDocument(image: UIImage(named: "1")),
ImageDocument(image: UIImage(named: "2"))
],
contentType: .jpeg // Match this to your representation in ImageDocument
) { url in
print("Saved to", url) // [URL]
}
}
}
}
import SwiftUI
import UniformTypeIdentifiers
struct ImageDocument: FileDocument {
static var readableContentTypes: [UTType] { [.jpeg, .png, .tiff] }
var image: UIImage
init(image: UIImage?) {
self.image = image ?? UIImage()
}
init(configuration: ReadConfiguration) throws {
guard let data = configuration.file.regularFileContents,
let image = UIImage(data: data)
else {
throw CocoaError(.fileReadCorruptFile)
}
self.image = image
}
func fileWrapper(configuration: WriteConfiguration) throws - FileWrapper {
// You can replace tiff representation with what you want to export
return FileWrapper(regularFileWithContents: image.jpegData(compressionQuality: 1)!)
}
}
struct ContentView: View {
@EnvironmentObject var appContext: AppContext
var body: some View {
VStack {
Button(action: {
appContext.fileSaveDialogShown.toggle()
}, label: {
Text("Button")
})
}
.frame(width: 200, height: 200)
}
}
When building a SceneKit Project, Xcode cannot save .scn files and gives a warning: “The document “ship.scn” could not be saved. “
1- Create SceneKit project
2- Change anything on ship.scn, like background color for ex
3- build
4- Xcode says “The document “ship.scn” could not be saved.
Is the Playground for Shape Edit code available?
Amazing session! : )
Besides style transfer, is there a way to also train image to image (for ex pix2pix) GAN models?
At wwdc20 session 10031, it’s mentioned that:
‘“To learn more about how best to show data in your app, you can download the code for Shape Edit from developer.apple.com. “
Where is the source code for the app?
thanks
I am trying to build scover "Ray Tracing with Metal" on iMac Pro 2017, but got this error:
2020-06-25 14:29:35.233058+0200 MTLRaytracingSample-macOS[3602:145531] Failed to set (contentViewController) user defined inspected property on (NSWindow): Ray tracing isn't supported on this device
Xcode 12
Big Sur 11.0 Beta (20A4299v)
iMac Pro 2017
3,2 GHz 8-Core Intel Xeon W
32 GB 2666 MHz DDR4
Radeon Pro Vega 56 8 GB
What is the required hardware configuration?
I am trying to build the App example on wwdc20-10037, but get only a "untitled" screen, followed by this error:
2020-06-25 12:26:28.639346+0200 ShapeEdit[2093:54298] [Type Declaration Issues] Type "com.example.ShapeEdit.shapes" was expected to be declared and exported in the Info.plist of ShapeEdit.app, but it was not found.
How can I properly build it?
Edit Shape Code - https://developer.apple.com/forums/content/attachment/759f7b02-e8a7-495b-a4b5-ea41cde9b948
How can I ask questions about Scenekit? Looks like there are no labs?
Should I apply for a Metal or realityKit lab and ask SceneKit questions?
Is it also possible to build Paired image to image translation (like pix2pix) with CreateML?
Paired = ex B&W to color
Unpaired = ex style transfer