feat(rcf): selected object
This commit is contained in:
48
draw.py
48
draw.py
@ -102,32 +102,39 @@ class HUD(object):
|
|||||||
|
|
||||||
def draw_selected_object(self):
|
def draw_selected_object(self):
|
||||||
clients = self.client.get("Client")
|
clients = self.client.get("Client")
|
||||||
# if values.mtype == "clientObject":
|
|
||||||
# indices = (
|
|
||||||
# (0, 1), (1, 2), (2, 3), (0, 3),
|
|
||||||
# (4, 5), (5, 6), (6, 7), (4, 7),
|
|
||||||
# (0, 4), (1, 5), (2, 6), (3, 7)
|
|
||||||
# )
|
|
||||||
|
|
||||||
# if values.body['object'] in bpy.data.objects.keys():
|
for client in clients:
|
||||||
# ob = bpy.data.objects[values.body['object']]
|
name = client[0].split('/')[1]
|
||||||
# else:
|
local_username = bpy.context.scene.session_settings.username
|
||||||
# return
|
|
||||||
# bbox_corners = [ob.matrix_world @ mathutils.Vector(corner) for corner in ob.bound_box]
|
|
||||||
|
|
||||||
# coords = [(point.x, point.y, point.z)
|
if name != local_username and client[1]['active_objects']:
|
||||||
# for point in bbox_corners]
|
for select_ob in client[1]['active_objects']:
|
||||||
|
indices = (
|
||||||
|
(0, 1), (1, 2), (2, 3), (0, 3),
|
||||||
|
(4, 5), (5, 6), (6, 7), (4, 7),
|
||||||
|
(0, 4), (1, 5), (2, 6), (3, 7)
|
||||||
|
)
|
||||||
|
|
||||||
# shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
if select_ob in bpy.data.objects.keys():
|
||||||
|
ob = bpy.data.objects[select_ob]
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
# color = values.body['color']
|
bbox_corners = [ob.matrix_world @ mathutils.Vector(corner) for corner in ob.bound_box]
|
||||||
# batch = batch_for_shader(
|
|
||||||
# shader, 'LINES', {"pos": coords}, indices=indices)
|
coords = [(point.x, point.y, point.z)
|
||||||
|
for point in bbox_corners]
|
||||||
|
|
||||||
|
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||||
|
|
||||||
|
color = client[1]['color']
|
||||||
|
|
||||||
|
batch = batch_for_shader(
|
||||||
|
shader, 'LINES', {"pos": coords}, indices=indices)
|
||||||
|
|
||||||
|
self.d3d_items["{}/{}".format(client[0],select_ob)]=(shader, batch, color)
|
||||||
|
|
||||||
# self.draw_items.append(
|
|
||||||
# (shader, batch, (None, None), color))
|
|
||||||
|
|
||||||
# index_object += 1
|
|
||||||
|
|
||||||
def draw_clients(self):
|
def draw_clients(self):
|
||||||
clients = self.client.get("Client")
|
clients = self.client.get("Client")
|
||||||
@ -183,4 +190,5 @@ class HUD(object):
|
|||||||
if self.client:
|
if self.client:
|
||||||
# Draw clients
|
# Draw clients
|
||||||
self.draw_clients()
|
self.draw_clients()
|
||||||
|
self.draw_selected_object()
|
||||||
|
|
||||||
|
15
helpers.py
15
helpers.py
@ -11,9 +11,9 @@ def refresh_window():
|
|||||||
import bpy
|
import bpy
|
||||||
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
|
||||||
|
|
||||||
def get_selected_objects(view_layer):
|
def get_selected_objects(scene):
|
||||||
selected_objects = []
|
selected_objects = []
|
||||||
for obj in view_layer.objects:
|
for obj in scene.objects:
|
||||||
if obj.select_get():
|
if obj.select_get():
|
||||||
selected_objects.append(obj.name)
|
selected_objects.append(obj.name)
|
||||||
|
|
||||||
@ -69,12 +69,20 @@ def resolve_bpy_path(path):
|
|||||||
|
|
||||||
|
|
||||||
def load_client(client=None,data=None):
|
def load_client(client=None,data=None):
|
||||||
|
C = bpy.context
|
||||||
|
D = bpy.data
|
||||||
if client and data:
|
if client and data:
|
||||||
|
# localy_selected = get_selected_objects(C.scene)
|
||||||
# Draw client
|
# Draw client
|
||||||
|
|
||||||
#Load selected object
|
#Load selected object
|
||||||
if data['active_objects']:
|
if data['active_objects']:
|
||||||
print("toto")
|
for obj in C.scene.objects:
|
||||||
|
if obj.name in data['active_objects']:
|
||||||
|
D.objects[obj.name].hide_select = True
|
||||||
|
else:
|
||||||
|
print(data['active_objects'])
|
||||||
|
D.objects[obj.name].hide_select = False
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -358,6 +366,7 @@ def dump_datablock_attibute(datablock, attributes, depth=1):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def init_client(key=None):
|
def init_client(key=None):
|
||||||
client_dict = {}
|
client_dict = {}
|
||||||
client_dict['location'] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
|
client_dict['location'] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
|
||||||
|
@ -413,6 +413,7 @@ def ordered(updates):
|
|||||||
uplist.sort(key=itemgetter(0))
|
uplist.sort(key=itemgetter(0))
|
||||||
return uplist
|
return uplist
|
||||||
|
|
||||||
|
|
||||||
def is_dirty(updates):
|
def is_dirty(updates):
|
||||||
global client_keys
|
global client_keys
|
||||||
|
|
||||||
@ -426,6 +427,7 @@ def is_dirty(updates):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def depsgraph_update(scene):
|
def depsgraph_update(scene):
|
||||||
global client_instance
|
global client_instance
|
||||||
|
|
||||||
@ -446,6 +448,7 @@ def depsgraph_update(scene):
|
|||||||
if updated_data.is_updated_transform or updated_data.is_updated_geometry:
|
if updated_data.is_updated_transform or updated_data.is_updated_geometry:
|
||||||
client_instance.set("{}/{}".format(updated_data.id.bl_rna.name, updated_data.id.name))
|
client_instance.set("{}/{}".format(updated_data.id.bl_rna.name, updated_data.id.name))
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
|
12
server.py
12
server.py
@ -66,18 +66,6 @@ class RCFServerAgent():
|
|||||||
request = msg[1]
|
request = msg[1]
|
||||||
|
|
||||||
if request == b"SNAPSHOT_REQUEST":
|
if request == b"SNAPSHOT_REQUEST":
|
||||||
# client_key = "Client/{}".format(identity.decode())
|
|
||||||
|
|
||||||
# if client_key not in self.property_map.keys():
|
|
||||||
# logger.info("New user:{}".format(identity.decode()))
|
|
||||||
|
|
||||||
# client_dict = {}
|
|
||||||
# client_dict['location'] = [[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
|
|
||||||
# client_dict['color'] = [0,1,1,1]
|
|
||||||
# client_dict['active_object'] = ''
|
|
||||||
# client_store = message.RCFMessage(key=client_key, id=identity,body=client_dict)
|
|
||||||
# logger.info(client_store)
|
|
||||||
# client_store.store(self.property_map)
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
logger.info("Bad snapshot request")
|
logger.info("Bad snapshot request")
|
||||||
|
Reference in New Issue
Block a user