Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello β I'm @olemoritz on Twitter.
SceneKit wrapper available
-
Greetings!
I have finished a sceneKit wrapper for Pythonista. It is available for installation together with 15 sample scripts (several of which was inspired by the forum community).
The wrapper is rather comprehensive and can be used according to the official SceneKit documentation, with some deviations described in the README.
Have fun and let me know if something is broken.
Peter
-
@pulbrich, wow! I sure do appreciate the effort that went into this, documentation and all.
Have to take a look at the examples and how you implemented the wrapping. Did you use any βautomationβ in the wrapping, or is it all manually coded?
-
ππππππππππ
-
@mikael Thanks!
Itβs neither. Each call is individually coded but I didnβt type this much, used macros. Since I didnβt fully comprehend at the beginning what might come I wanted to be in full control. It was a good decision even-though the resulting source code of the wrapper is not going to win any beauty award.
-
I didn't check your code in details, but do you know you can also set as material photo, a video, even a camera, like in this kind of code I use in a script
@on_main_thread def set_material(self,face_no,type_material,val): Material = SCNMaterial.material() if type_material == 'color': if type(val) is tuple: r,g,b = val else: rgb = getrgb(val) r,g,b = tuple(c/255.0 for c in rgb) Material.contents = ObjCClass('UIColor').colorWithRed_green_blue_alpha_(r,g,b,1.0) elif type_material == 'photo': Material.contents = ObjCInstance(val.get_ui_image()) elif type_material == 'video': video_objc = ObjCInstance(val) video_url = ObjCClass('AVURLAsset').alloc().initWithURL_options_(video_objc.ALAssetURL(),None) AVPlayer = ObjCClass('AVPlayerItem').playerItemWithAsset_(video_url) p = ObjCClass('AVPlayer').playerWithPlayerItem_(AVPlayer) Material.contents = p p.play() elif type_material == 'front camera': inputDevice = ObjCClass('AVCaptureDevice').devices()[1] Material.contents = inputDevice elif type_material == 'rear camera': inputDevice = ObjCClass('AVCaptureDevice').devices()[0] Material.contents = inputDevice self.faces[face_no] = (type_material,val) return Material
-
@cvp thanks! Color and image is covered but video and camera not. If it is as easy I will incorporate it in the next release.
-
-
I have added one more demo script to the sceneKit wrapper repo, the translation of the 2014 original Apple SceneKit Vehicle Demo into Pythonista.
It was an interesting, relatively unproblematic mechanical transcript. Fun to look at the result.
(Needs the Gestures module)
βPeter
-
@pulbrich, very impressive! Good lighting and textures go a long way.
I can make the car go forward, but not turn. :-) And scenekit seems to share some of the issues with clean-up I see with the spritekit wrapper - crashes every second run.
Looked at the code, right. 1 finger forward, 2 fingers reverse, 3 fingers to put on the brakes, and tilt to turn.
-
@mikael Thanks for trying it out!
You cannot turn the car by tilting your device?
The crashes I am investigating. My current suspect is the integration with the ui modul.
-
@pulbrich, no, no issues with the car controls - once I realized what they were.
-
Hopefully solved the crashes.
Please reinstall the package and the demo script from the repo, if interested in a (more?) stable version.
There were two problems: needed a new call to properly clean up before exit and the playSound action eventually crashes if called asynchronously. The first issue I understand, the second much less.