-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfox.py
138 lines (103 loc) · 3.55 KB
/
fox.py
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from objc_util import load_framework, ObjCClass, on_main_thread
from objc_util import UIColor, UIImage, NSData, nsurl
import ui
#import pdbg
load_framework('SceneKit')
SCNScene = ObjCClass('SCNScene')
SCNView = ObjCClass('SCNView')
SCNNode = ObjCClass('SCNNode')
SCNLight = ObjCClass('SCNLight')
SCNCamera = ObjCClass('SCNCamera')
SCNTorus = ObjCClass('SCNTorus')
class GameScene:
def __init__(self):
self.scene: SCNScene
self.setUpScene()
def setUpScene(self):
# --- import
foxmax_URL = nsurl('./assets/character/max.scn')
bkSky_URL = NSData.dataWithContentsOfURL_(
nsurl('./assets/textures/Background_sky.png'))
tex_bks = UIImage.alloc().initWithData_(bkSky_URL)
# --- SCNScene
scene = SCNScene.sceneWithURL_options_(foxmax_URL, None)
scene.background().contents = tex_bks
scene.lightingEnvironment().contents = tex_bks
scene.lightingEnvironment().intensity = 1.24
scene_rootNode_addChildNode_ = scene.rootNode().addChildNode_
foxmaxNode = scene.rootNode().objectInChildNodesAtIndex_(0)
torus = SCNTorus.torusWithRingRadius_pipeRadius_(0.075, 0.02)
torus.ringSegmentCount = 8
torus.pipeSegmentCount = 8
torus.material().lightingModelName = 'SCNLightingModelPhysicallyBased'
torus.firstMaterial().reflective().contents = 0.9
torus.firstMaterial().diffuse().contents = UIColor.yellowColor()
torusNode = SCNNode.nodeWithGeometry_(torus)
torusNode.position = (0.0, 0.55, 0.0)
scene_rootNode_addChildNode_(torusNode)
# --- SCNLight
lightNode = SCNNode.node()
lightNode.light = SCNLight.light()
lightNode.castsShadow = True
lightNode.position = (0.0, 10.0, 10.0)
scene_rootNode_addChildNode_(lightNode)
# --- SCNCamera
camera = SCNCamera.camera()
camera.wantsHDR = True
camera.bloomBlurRadius = 18.0
camera.bloomIntensity = 1.0
camera.bloomThreshold = 1.0
camera.colorFringeIntensity = 4.0
camera.colorFringeStrength = 4.0
camera.motionBlurIntensity = 6
camera.xFov = 35.0
camera.yFov = 35.0
cameraNode = SCNNode.node()
cameraNode.camera = camera
cameraNode.position = (0.0, 0.25, 2.0)
scene_rootNode_addChildNode_(cameraNode)
self.scene = scene
class View(ui.View):
def __init__(self, *args, **kwargs):
ui.View.__init__(self, *args, **kwargs)
self.name = ''
self.bg_color = 'maroon'
self.scene: GameScene
self.scnView: SCNView
self.viewDidLoad()
self.objc_instance.addSubview_(self.scnView)
#@on_main_thread
def viewDidLoad(self):
scene = GameScene()
# --- SCNView
_frame = ((0, 0), (100, 100))
scnView = SCNView.alloc().initWithFrame_(_frame)
scnView.setAutoresizingMask_((1 << 1) | (1 << 4))
scnView.backgroundColor = UIColor.blackColor()
scnView.allowsCameraControl = True
scnView.showsStatistics = True
'''
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)
'''
_debugOptions = ((1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 10))
scnView.debugOptions = _debugOptions
scnView.autorelease()
scnView.scene = scene.scene
self.scene = scene
self.scnView = scnView
def touch_began(self, touch):
pass
if __name__ == '__main__':
view = View()
view.present(style='fullscreen', orientations=['portrait'])