-
Notifications
You must be signed in to change notification settings - Fork 2
/
__init__.py
216 lines (154 loc) · 8.31 KB
/
__init__.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#Author: Written from scratch, by God Bennett, Cryptosynth Labs founder
#Blender3d addon to enable cryptosynth Ai/GPT2 input and response texts as well as associated 3d behaviour
#How to use:
#1. "I" key : *Initialize* Cryptosynth Aeon being.
#2. Right click anywhere in 3d scene (like beside the synth) to enable Cryptosynth Aeon Communicate.
#3. "T" key : Start Aeon *thinking*/reading cycle.
#4. "R" key : Get *response* from Aeon being.
bl_info = {
"name": "Cryptosynth Aeon Communicate",
"author": "God Bennett",
"version": (1, 0),
"blender": (2, 91, 0),
"location_": "Right click anywhere in scene > Object Context Menu > Cryptosynth Aeon Communicate",
"location" : "[1]'I' key : *Initialize*, [2]Right click anywhere in scene/send message, [3]'T' key start Aeon think cycle, [4]'R' key get Aeon *response*",
"description": "Cryptosynth Aeon is a sequence of artificial intelligence powered 3d beings - Crypto Art NFTs you can actually hold a conversation with.",
"warning": "",
"doc_url": "facebook.com/CryptosynthLabs"
}
########################################################
#BLOCK_A. Conversational Neural Network Module
#Note 1: Setup function is invoked in aeonInitializeBeing (), before 3d model realism is invoked
#Note 2: Neural network/ai response is called in "UserTransmission" class @execute func, where aeon_output variable is updated.
from . import interact_cryptosynth
CONVERSATIONAL_NEURAL_NETWORK = interact_cryptosynth.NeuralNetConversationalModule()
########################################################
#BLOCK_B. Cryptosynth Blender3d Modules
import bpy
def aeonInitializeBeing (context):
CONVERSATIONAL_NEURAL_NETWORK.setup()
bpy.context.scene.render.engine = 'CYCLES'
#B. Enable God Bennett's original "photorealistic" fidelity/graphics
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
space = area.spaces.active
if space.type == 'VIEW_3D':
space.shading.type = 'RENDERED'
def printToBlenderConsole(data):
for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'CONSOLE':
override = {'window': window, 'screen': screen, 'area': area}
bpy.ops.console.scrollback_append(override, text=str(data), type="OUTPUT")
class CryptosynthInitialization(bpy.types.Operator):
bl_idname = "cryptosynth.initialization"
bl_label = "Cryptosynth Aeon Initialization"
bl_options = {'REGISTER', 'UNDO'}
initializationMessage = bpy.props.StringProperty(name="")
def execute(self, context):
aeonInitializeBeing(context)
return {'FINISHED'}
def _aeon_3d_action_begin_read_behaviour():
#simulate reading movement
#A. Prepare model for animation
#Focus on eyes, which animate to do reading action
#...1. Disable rendered mode (Disable God Bennett's original "photorealistic" fidelity/graphics)
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
space = area.spaces.active
if space.type == 'VIEW_3D':
space.shading.type = 'MATERIAL'
#...2. Disable light/focus on overall synth, to place more focus on EYES
bpy.data.objects['Point.002'].data.energy = 0
#...3. Disable skin colour, to place more focus on EYES
bpy.data.images["Std_Skin_Head_Diffuse"].colorspace_settings.name = 'Non-Color'
#B. Start animation
bpy.ops.screen.animation_play()
def _aeon_3d_action_end_read_behaviour ():
#simulate stop reading movement
#A. Restore still state
bpy.ops.screen.animation_cancel(restore_frame=True)
bpy.ops.scene.frame_current = 0 #God Bennett's lucky guess, this reset's animation frame to 0
#Re-focus on entire synth which restores default position prior to animation to do reading action
#...2. Enable rendered mode (Enable God Bennett's original "photorealistic" fidelity/graphics)
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
space = area.spaces.active
if space.type == 'VIEW_3D':
space.shading.type = 'RENDERED'
#...2. Restore point light/focus on synth
bpy.data.objects['Point.002'].data.energy = 100
#...3. Restore default skin colour, to restore focus on entire synth
bpy.data.images["Std_Skin_Head_Diffuse"].colorspace_settings.name = 'sRGB'
def _aeon_3d_action_response_sequence ():
bpy.app.timers.register(_aeon_3d_action_begin_read_behaviour, first_interval=1)
bpy.app.timers.register(_aeon_3d_action_end_read_behaviour, first_interval=7)
class UserTransmission(bpy.types.Operator):
bl_idname = "user.transmission"
bl_label = "User Transmission"
bl_options = {'REGISTER', 'UNDO'}
#initializationMessage = bpy.props.StringProperty(name="")
def execute(self, context):
_aeon_3d_action_response_sequence()
bpy.types.VIEW3D_MT_object_context_menu.prepend(CryptosynthDialogFunc)
wm_c = bpy.context.window_manager
km_c = wm_c.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi_c = km_c.keymap_items.new(CryptosynthDialog.bl_idname, 'R', 'PRESS', ctrl=False, shift=False)
#kmi_c.properties.aeon_output = "wtf!"
#AEON_INPUT = kmi_c.properties.user_input #This does not reflect latest user input!
LATEST_AEON_INPUT = bpy.context.window_manager.operator_properties_last("cryptosynth.dialog")
LATEST_AEON_INPUT = LATEST_AEON_INPUT.user_input
#printToBlenderConsole(AEON_INPUT)
kmi_c.properties.aeon_output = interact_cryptosynth.getNeuralNetConversationalResponse ( LATEST_AEON_INPUT, CONVERSATIONAL_NEURAL_NETWORK )
addon_keymaps_communicate_with_aeon_being.append(km_c)
return {'FINISHED'}
class CryptosynthDialog(bpy.types.Operator):
bl_idname = "cryptosynth.dialog"
bl_label = "Cryptosynth Aeon Dialog"
bl_options = {'REGISTER', 'UNDO'}
user_input = bpy.props.StringProperty(name="User Input", default="<To be sent to Synth-Aeon>")
aeon_output = bpy.props.StringProperty(name="Aeon Output", default="<To be replied by Synth-Aeon>")
def execute(self, context):
pass
return {'FINISHED'}
# store keymaps here to access after registration
addon_keymaps_communicate_with_aeon_being = []
addon_keymaps_init_aeon_being = []
def CryptosynthDialogFunc(self, context):
self.layout.operator(CryptosynthDialog.bl_idname)
def register():
################################
################Communication
bpy.utils.register_class(UserTransmission)
bpy.utils.register_class(CryptosynthDialog)
bpy.types.VIEW3D_MT_object_context_menu.prepend(CryptosynthDialogFunc)
#keymap for communication
wm_c = bpy.context.window_manager
km_c = wm_c.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi_c = km_c.keymap_items.new(UserTransmission.bl_idname, 'T', 'PRESS', ctrl=False, shift=False)
#kmi_c.properties.initializationMessage = "Initialization complete!"
addon_keymaps_communicate_with_aeon_being.append(km_c)
################################
################initialization
bpy.utils.register_class(CryptosynthInitialization)
#keymap for initialization
wm_i = bpy.context.window_manager
km_i = wm_i.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi_i= km_i.keymap_items.new(CryptosynthInitialization.bl_idname, 'I', 'PRESS', ctrl=False, shift=False)
kmi_i.properties.initializationMessage = "Initialization complete!"
addon_keymaps_init_aeon_being.append(km_i)
def unregister():
bpy.utils.unregister_class(CryptosynthDialog)
bpy.types.VIEW3D_MT_object.remove(CryptosynthDialogFunc)
bpy.utils.unregister_class(CryptosynthInitialization)
"""
# handle the keymap
wm = bpy.context.window_manager
for km in addon_keymaps:
wm.keyconfigs.addon.keymaps.remove(km)
# clear the list
del addon_keymaps[:]
"""
if __name__ == "__main__":
register()