-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharkit.py
More file actions
109 lines (80 loc) · 2.75 KB
/
Copy patharkit.py
File metadata and controls
109 lines (80 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from objc_util import load_framework, ObjCClass
from objc_util import UIColor
import ui
#import pdbg
load_framework('ARKit')
ARSCNView = ObjCClass('ARSCNView')
ARWorldTrackingConfiguration = ObjCClass('ARWorldTrackingConfiguration')
SCNScene = ObjCClass('SCNScene')
SCNNode = ObjCClass('SCNNode')
SCNAction = ObjCClass('SCNAction')
SCNBox = ObjCClass('SCNBox')
class GameScene:
def __init__(self):
self.scene: SCNScene
self.setUpScene()
def setUpScene(self):
scene = SCNScene.scene()
scene_rootNode_addChildNode_ = scene.rootNode().addChildNode_
box = SCNBox.boxWithWidth_height_length_chamferRadius_(0.5, 0.5, 0.5, 0.08)
box.firstMaterial().diffuse().contents = UIColor.blueColor()
geometryNode = SCNNode.nodeWithGeometry_(box)
geometryNode.position = (0, -1.0, -1.0)
geometryNode.runAction_(
SCNAction.repeatActionForever_(
SCNAction.rotateByX_y_z_duration_(0.0, 0.2, 0.1, 0.3)))
scene_rootNode_addChildNode_(geometryNode)
self.scene = scene
class ViewController:
def __init__(self):
self.sceneView: ARSCNView
self.scene: GameScene
self.viewDidLoad()
self.viewWillAppear()
def viewDidLoad(self):
scene = GameScene()
_frame = ((0, 0), (100, 100))
sceneView = ARSCNView.alloc().initWithFrame_(_frame)
sceneView.autoresizingMask = (1 << 1) | (1 << 4)
sceneView.autoenablesDefaultLighting = True
sceneView.showsStatistics = True
''' debugOptions
OptionNone = 0
ShowPhysicsShapes = (1 << 0)
ShowBoundingBoxes = (1 << 1)
ShowLightInfluences = (1 << 2)
ShowLightExtents = (1 << 3)
ShowPhysicsFields = (1 << 4)
ShowWireframe = (1 << 5)
RenderAsWireframe = (1 << 6)
ShowSkeletons = (1 << 7)
ShowCreases = (1 << 8)
ShowConstraints = (1 << 9)
ShowCameras = (1 << 10)
ARSCNDebugOptionShowFeaturePoints = (1 << 30)
ARSCNDebugOptionShowWorldOrigin = (1 << 32)
'''
_debugOptions = (1 << 1) | (1 << 30) | (1 << 32)
sceneView.debugOptions = _debugOptions
sceneView.scene = scene.scene
sceneView.autorelease()
self.scene = scene
self.sceneView = sceneView
def viewWillAppear(self):
self.resetTracking()
def viewWillDisappear(self):
self.sceneView.session().pause()
def resetTracking(self):
configuration = ARWorldTrackingConfiguration.new()
self.sceneView.session().runWithConfiguration_(configuration)
class View(ui.View):
def __init__(self, *args, **kwargs):
ui.View.__init__(self, *args, **kwargs)
self.bg_color = 'maroon'
self.vc = ViewController()
self.objc_instance.addSubview_(self.vc.sceneView)
def will_close(self):
self.vc.viewWillDisappear()
if __name__ == '__main__':
view = View()
view.present(style='fullscreen', orientations=['portrait'])