• pulbrich

    Instead of using the time function that I suggested, put Scene.t (mind the capital S)

    Scene.dt is not directly suitable for your case; it gives you the time lapsed since the last call to update().

    posted in Pythonista read more
  • pulbrich

    Check if you don’t have 2 packages of matplotlib installed by coincidence.

    posted in Pythonista read more
  • pulbrich

    The iPad Pro’s screen size is not yet supported by the current version of Pythonista. The next update will fix this, as far as I know.

    posted in Pythonista read more
  • pulbrich

    @Vile :

    import time #this module is needed to get the system time
    

    In your set-up code:

    self.last_update = time.process_time()
    

    In your update method:

    current_time = time.process_time()
    if current_time - self.last_update > 0.125:
        self.last_update = current_time
        modify_the_sprite
    

    posted in Pythonista read more
  • pulbrich

    Move the sprite changing code to the update method of your scene; and do the change only when enough time passed since the last change.

    Scene.update()
    Performs any scene-specific updates that need to occur before scene actions are evaluated.

    posted in Pythonista read more
  • pulbrich

    @JonB : you are probably right; I ended up with this approach (init/alloc) because I was unable to make the long initializer work (returns None) and thought I will add the properties one after the other to see which breaks. It puzzles me since the parameters to the long init method look ok on their own right yet no skinner is returned. Will keep trying.

    posted in Pythonista read more
  • pulbrich

    Would a kind soul look at this skeleton code and give me some directions where to search. I tried to run this on the main thread, in the background, no difference. It also doesn’t matter which instance method I call; neither if I initialize the Skinner with the convenience init.

    The fault happens in objc_util in the message send call. Other classes work as they should.

    from objc_util import * 
    from ctypes import *
    import ctypes
    
    load_framework('SceneKit')
    
    SCNSkinner = ObjCClass('SCNSkinner')
    aSkinner = SCNSkinner.alloc().init()
    
    print(aSkinner)
    #results in: <SCNSkinner: 0x281ba1bf0>
    
    a = aSkinner.wantsCPUSkinning()
    
    #results in:
    #Fatal Python error: Segmentation fault
    #
    #Current thread 0x000000016da43000 (most recent call first):
    #  File "/var/containers/Bundle/Application/5405B521-0286-438F-821B-436B80F5E060/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 897 in __call__
    #  File "/var/containers/Bundle/Application/5405B521-0286-438F-821B-436B80F5E060/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 803 in __call__
    #  File "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/SceneKit/x-sample.py", line 13 in <module>
    

    Thanks, Peter

    posted in Pythonista read more
  • pulbrich

    @JonB

    Here:

    from objc_util import * 
    from ctypes import *
    import ctypes
    
    lb = 24
    def printHex(buf):
      print( ":".join("{:02x}".format(c) for c in buf))
    
    load_framework('SceneKit')
    
    simd_float3 = c_uint32 * 3
    
    SCNNode = ObjCClass('SCNNode')
    aNode = SCNNode.alloc().init()
    
    p5 = aNode.simdScale(restype=simd_float3, argtypes=[])
    
    buf = string_at(byref(p5), lb)
    printHex(buf)
    
    print('p5[0]-[2] = ', p5[0], p5[1], p5[2])
    
    #results in:
    #80:0d:52:80:02:00:00:00:dc:26:de:01:00:00:00:00:00:00:00:00:00:00:00:00
    #
    #p5[0]-[2] =  2152861056 2 31336156
    
    

    encoding: b'16@0:8' i.e., restype: void/int

    The first 8 bytes of the result buffer looks like an address, if (for curiosity) you invoke ObjCInstance on it it returns the Node object aNode. Why???

    The only reason I am trying to make the simd properties work is that the old ones might get phased out at some point in the future. Of course until then I can simply redirect the simd calls to the non-simd siblings.

    posted in Pythonista read more
  • pulbrich

    @JonB : With the proposed function ctypes_alloc_aligned I can get an aligned memory chunk but I cannot tell simdScale to write the result into it, methinks.

    posted in Pythonista read more
  • pulbrich

    Other values are also wrong. I will look later at your proposal, I am now not at my desk. But thanks!

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!