omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    scenekit wrapper
    3
    12
    5313
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pulbrich
      pulbrich last edited by

      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

      mikael 1 Reply Last reply Reply Quote 2
      • mikael
        mikael @pulbrich last edited by

        @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?

        pulbrich 1 Reply Last reply Reply Quote 0
        • cvp
          cvp last edited by cvp

          ๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘

          1 Reply Last reply Reply Quote 0
          • pulbrich
            pulbrich @mikael last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • cvp
              cvp last edited by

              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
              
              pulbrich 1 Reply Last reply Reply Quote 0
              • pulbrich
                pulbrich @cvp last edited by

                @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.

                cvp 1 Reply Last reply Reply Quote 1
                • cvp
                  cvp @pulbrich last edited by

                  @pulbrich Not so easy but you can find here a never finished little script I wrote for testing.
                  Tap geometry, select one, tap โœ…
                  Tap faces, select one, select content

                  1 Reply Last reply Reply Quote 0
                  • pulbrich
                    pulbrich last edited by

                    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

                    mikael 1 Reply Last reply Reply Quote 1
                    • mikael
                      mikael @pulbrich last edited by mikael

                      @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.

                      pulbrich 1 Reply Last reply Reply Quote 0
                      • pulbrich
                        pulbrich @mikael last edited by

                        @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.

                        mikael 1 Reply Last reply Reply Quote 0
                        • mikael
                          mikael @pulbrich last edited by

                          @pulbrich, no, no issues with the car controls - once I realized what they were.

                          1 Reply Last reply Reply Quote 0
                          • pulbrich
                            pulbrich last edited by

                            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.

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Powered by NodeBB Forums | Contributors