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.
3D in pythonista
-
Hi everyone, I’m wondering about potentially create a game in 3D with Pythonista, and after some researchs I saw that it was possible to import SceneKit in objC. I have some questions:
- how can I use this objC module in pythonista ? Cause I Didn’t understood anything from @omz 3D exemple which is 2 years old...
- can I import blender objects or so with this module ?
- if not, is there any other way/module to do 3D in pythonista ?
- Is it hard to make my own 3D engine ? Which base knowledge do I need to make it ?
Thanks in advance for all of your answers, and Happy New Year !
-
@SmartGoat Have à look
here
And
here -
@SmartGoat you can import .scn file with
scene = SCNScene.sceneWithURL_options_(nsurl('double-cheese-burger.scn'),None)
-
from objc_util import * import ctypes import ui import math from ImageColor import getrgb import os load_framework('SceneKit') SCNView, SCNScene, SCNBox, SCNNode, SCNSceneSource, SCNMaterial, SCNCamera, SCNLight, SCNAction, SCNLookAtConstraint = map(ObjCClass, ['SCNView', 'SCNScene', 'SCNBox', 'SCNNode', 'SCNSceneSource', 'SCNMaterial', 'SCNCamera', 'SCNLight', 'SCNAction', 'SCNLookAtConstraint' ]) @on_main_thread def demo(): main_view = ui.View() w, h = ui.get_screen_size() main_view.frame = (0,0,w,h) main_view_objc = ObjCInstance(main_view) scene_view = SCNView.alloc().initWithFrame_options_(((0, 0),(w, h)), None).autorelease() # transparent scene_view background, thus we see main_view background scene_view.setBackgroundColor_(ObjCClass('UIColor').clearColor()) scene_view.setAutoresizingMask_(18) scene_view.setAllowsCameraControl_(True) main_view_objc.addSubview_(scene_view) main_view.name = 'SceneKit Demo' scene = SCNScene.sceneWithURL_options_(nsurl('double-cheese-burger.scn'),None) scene_view.setScene_(scene) rotate_action = SCNAction.repeatActionForever_(SCNAction.rotateByX_y_z_duration_(0, math.pi*2, 0, 10)) root_node = scene.rootNode() for node in root_node.childNodes(): if str(node.name()) != 'camera': node.runAction_(rotate_action) main_view.present(hide_title_bar=True) demo()
-
Thanks @cvp for this, now I know we can import files and load them in pythonista. Although, I encounter a problem of shader rendering with original @omz example:
[http://imgur.com/D2OOKtE]
Does anyone know how to fix it ?
Thanks in advance -
@SmartGoat comment this line or try another type like directional
#light.setType_('spot')
-
-
Thanks @cvp, last question (maybe):
Is it possible to use SceneKit in the Scene module or only in ui ? -
@SmartGoat I'm sorry but I'll leave other (a lot smarter) guys answer, I have never used Scene in my own scripts...
-
@SmartGoat Ha, also, I've tried to load a .dae file in Pythonista SceneKit, but without any success. As soon I try to get the scene.rootNode, I get an error because scene is None 😢
#scene = SCNScene.sceneWithURL_options_(nsurl('double-cheese-burger.scn'),None) scene = SCNScene.sceneWithURL_options_(nsurl('deer.dae'),None) scene_view.setScene_(scene) root_node = scene.rootNode()
-
@SmartGoat, you can use views in a scene, see the scene docs, ”Integration with the ui Module”.