-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMesh.py
More file actions
140 lines (119 loc) · 3.68 KB
/
Mesh.py
File metadata and controls
140 lines (119 loc) · 3.68 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
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
139
140
import weakref
class Engine:
ANIMATIONCONTROLLER = 0
ANIMATIONTRACK = 1
APPEARANCE = 2
BACKGROUND = 3
CAMERA = 4
COMPOSITINGMODE = 5
FOG = 6
GRAPHICS3D = 7
GROUP = 8
IMAGE2D = 9
KEYFRAMESEQUENCE = 10
LIGHT = 11
LOADER = 12
MATERIAL = 13
MESH = 14
MORPHINGMESH = 15
PLASMAIMAGE = 16
POLYGONMODE = 17
RAYINTERSECTION = 18
SKINNEDMESH = 19
SPRITE3D = 20
STAGESET = 21
TEXTURE2D = 22
TRANSFORM = 23
TRIANGLESTRIPARRAY = 24
VERTEXARRAY = 25
VERTEXBUFFER = 26
WORLD = 27
UNKNOWN = 28
OBJECT3D_FID = 0
GRAPHICS3D_FID = 1
LOADER_FID = 2
RAYINTERSECTION_FID = 3
TRANSFORM_FID = 4
peer_table = {}
XOT = []
XOT_length = 0
tmp_XOT = None
clean_peer_table = False
lookup = None
@staticmethod
def get_version_major():
pass # Native method placeholder
@staticmethod
def get_version_minor():
pass # Native method placeholder
@staticmethod
def get_revision_major():
pass # Native method placeholder
@staticmethod
def get_revision_minor():
pass # Native method placeholder
@staticmethod
def get_branch_number():
pass # Native method placeholder
@staticmethod
def release_handle(handle):
pass # Native method placeholder
@staticmethod
def get_handle_type(handle):
pass # Native method placeholder
@staticmethod
def get_handle_size(handle):
pass # Native method placeholder
@staticmethod
def instantiate_java_peer(handle):
if handle == 0:
return None
success = False
try:
peer = Engine.get_java_peer(handle)
if peer is not None:
return peer
handle_type = Engine.get_handle_type(handle)
peer = {
Engine.ANIMATIONCONTROLLER: lambda: AnimationController(handle),
Engine.ANIMATIONTRACK: lambda: AnimationTrack(handle),
Engine.APPEARANCE: lambda: Appearance(handle),
Engine.BACKGROUND: lambda: Background(handle),
Engine.CAMERA: lambda: Camera(handle),
# ... continue for other handle types ...
}.get(handle_type, lambda: None)()
if peer is None:
raise ValueError("Invalid handle type")
Engine.add_java_peer(handle, peer)
success = True
return peer
finally:
if not success:
Engine.release_handle(handle)
@staticmethod
def clean_up_peer_table():
for key, ref in list(Engine.peer_table.items()):
if ref() is None:
del Engine.peer_table[key]
@staticmethod
def add_java_peer(handle, peer):
if Engine.clean_peer_table:
Engine.clean_up_peer_table()
Engine.clean_peer_table = False
Engine.peer_table[handle] = weakref.ref(peer)
@staticmethod
def get_java_peer(handle):
if Engine.clean_peer_table:
Engine.clean_up_peer_table()
Engine.clean_peer_table = False
ref = Engine.peer_table.get(handle)
return ref() if ref else None
@staticmethod
def add_xot(obj):
if obj and (obj.ii or obj.uo is not None):
if obj in Engine.XOT:
return
if len(Engine.XOT) == Engine.XOT_length:
Engine.XOT.extend([None] * (len(Engine.XOT) or 2))
Engine.XOT[Engine.XOT_length] = obj
Engine.XOT_length += 1