feat(user interface): started to play with some shader
This commit is contained in:
parent
d52dd668c5
commit
1504c0a5f2
@ -249,7 +249,6 @@ class Client():
|
|||||||
self.pull_sock.close()
|
self.pull_sock.close()
|
||||||
self.task.cancel()
|
self.task.cancel()
|
||||||
|
|
||||||
|
|
||||||
class Server():
|
class Server():
|
||||||
def __init__(self, context=zmq.Context(), id="admin"):
|
def __init__(self, context=zmq.Context(), id="admin"):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
@ -5,6 +5,8 @@ import logging
|
|||||||
import mathutils
|
import mathutils
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
import gpu
|
||||||
|
from gpu_extras.batch import batch_for_shader
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -19,9 +21,10 @@ NATIVE_TYPES = (
|
|||||||
bpy.types.StringProperty,
|
bpy.types.StringProperty,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RNAFactory(net_components.RCFFactory):
|
class RNAFactory(net_components.RCFFactory):
|
||||||
def load_getter(self,data):
|
def load_getter(self, data):
|
||||||
get,set = match_supported_types(data)
|
get, set = match_supported_types(data)
|
||||||
|
|
||||||
|
|
||||||
def on_scene_evalutation(scene):
|
def on_scene_evalutation(scene):
|
||||||
@ -30,6 +33,7 @@ def on_scene_evalutation(scene):
|
|||||||
# TODO: Scene representation
|
# TODO: Scene representation
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def randomStringDigits(stringLength=6):
|
def randomStringDigits(stringLength=6):
|
||||||
"""Generate a random string of letters and digits """
|
"""Generate a random string of letters and digits """
|
||||||
lettersAndDigits = string.ascii_letters + string.digits
|
lettersAndDigits = string.ascii_letters + string.digits
|
||||||
@ -153,20 +157,10 @@ def patch_scene(msg):
|
|||||||
logger.debug('no need to update scene on our own')
|
logger.debug('no need to update scene on our own')
|
||||||
|
|
||||||
|
|
||||||
def vector2array(v):
|
|
||||||
return [v.x, v.y, v.z]
|
|
||||||
|
|
||||||
|
|
||||||
def array2vector(a):
|
|
||||||
logger.debug(mathutils.Vector((a[0], a[1], a[2])))
|
|
||||||
return mathutils.Vector((a[0], a[1], a[2]))
|
|
||||||
|
|
||||||
|
|
||||||
recv_callbacks = [patch_scene]
|
recv_callbacks = [patch_scene]
|
||||||
post_init_callbacks = [refresh_window]
|
post_init_callbacks = [refresh_window]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class session_join(bpy.types.Operator):
|
class session_join(bpy.types.Operator):
|
||||||
bl_idname = "session.join"
|
bl_idname = "session.join"
|
||||||
bl_label = "join"
|
bl_label = "join"
|
||||||
@ -306,7 +300,8 @@ class session_stop(bpy.types.Operator):
|
|||||||
|
|
||||||
|
|
||||||
class session_settings(bpy.types.PropertyGroup):
|
class session_settings(bpy.types.PropertyGroup):
|
||||||
username = bpy.props.StringProperty(name="Username", default="user_{}".format(randomStringDigits()))
|
username = bpy.props.StringProperty(
|
||||||
|
name="Username", default="user_{}".format(randomStringDigits()))
|
||||||
ip = bpy.props.StringProperty(name="localhost")
|
ip = bpy.props.StringProperty(name="localhost")
|
||||||
port = bpy.props.IntProperty(name="5555")
|
port = bpy.props.IntProperty(name="5555")
|
||||||
buffer = bpy.props.StringProperty(name="None")
|
buffer = bpy.props.StringProperty(name="None")
|
||||||
@ -315,6 +310,19 @@ class session_settings(bpy.types.PropertyGroup):
|
|||||||
name="update_frequency", default=0.008)
|
name="update_frequency", default=0.008)
|
||||||
|
|
||||||
|
|
||||||
|
camera_coords = [(-1, 1, 0), (1, 1, 0), (1, 1, 0),
|
||||||
|
(1, -1, 0), (1, -1, 0), (-1, -1, 0),
|
||||||
|
(-1, -1, 0), (-1, 1, 0)]
|
||||||
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||||
|
batch = batch_for_shader(shader, 'LINES', {"pos": camera_coords})
|
||||||
|
|
||||||
|
|
||||||
|
def draw_client():
|
||||||
|
shader.bind()
|
||||||
|
shader.uniform_float("color", (1, 1, 0, 1))
|
||||||
|
batch.draw(shader)
|
||||||
|
|
||||||
|
|
||||||
# TODO: Rename to match official blender convention
|
# TODO: Rename to match official blender convention
|
||||||
classes = (
|
classes = (
|
||||||
session_join,
|
session_join,
|
||||||
@ -333,7 +341,9 @@ def register():
|
|||||||
|
|
||||||
bpy.types.Scene.session_settings = bpy.props.PointerProperty(
|
bpy.types.Scene.session_settings = bpy.props.PointerProperty(
|
||||||
type=session_settings)
|
type=session_settings)
|
||||||
|
|
||||||
|
bpy.types.SpaceView3D.draw_handler_add(
|
||||||
|
draw_client, (), 'WINDOW', 'POST_VIEW')
|
||||||
# bpy.app.handlers.depsgraph_update_post.append(on_scene_evalutation)
|
# bpy.app.handlers.depsgraph_update_post.append(on_scene_evalutation)
|
||||||
|
|
||||||
|
|
||||||
@ -342,6 +352,7 @@ def unregister():
|
|||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
unregister_class(cls)
|
unregister_class(cls)
|
||||||
|
|
||||||
|
# bpy.types.SpaceView3D.draw_handler_remove(draw_client, (),'WINDOW')
|
||||||
# bpy.app.handlers.depsgraph_update_post.remove(on_scene_evalutation)
|
# bpy.app.handlers.depsgraph_update_post.remove(on_scene_evalutation)
|
||||||
|
|
||||||
del bpy.types.Scene.session_settings
|
del bpy.types.Scene.session_settings
|
||||||
@ -349,4 +360,3 @@ def unregister():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user