def _method_reply(cls, path, source, target, data): msg = Message(path) if target: msg.add(*target) if data: msg.add(*data) bge.logic.server.send(source.url, msg)
def update_projectionmatrix(self, camera): data = camera.data # operators seems much slower, we add a classmedthod to call the code directly for internal use (see handler.py) bundle = Bundle() e = 1.0 / math.tan(data.angle / 2.0) a = bpy.context.scene.game_settings.resolution_y / bpy.context.scene.game_settings.resolution_x n = data.clip_start f = data.clip_end msg_matrix = Message('/bge/scene/cameras/projection_matrix') msg_matrix.add(camera.name, e, 0.0, 2.0 * data.shift_x, 0.0, 0.0, e / a, 2.0 * data.shift_y / a, 0.0, 0.0, 0.0, (f + n) / (n - f), (2 * f * n) / (n - f), 0.0, 0.0, -1.0, 0.0) perspective = 1 if data.type == 'ORTHO': perspective = 0 msg_persp = Message('/bge/scene/cameras/perspective') msg_persp.add(camera.name, perspective) bundle.add(msg_persp) bundle.add(msg_matrix) Client().send(bundle)
def update_projectionmatrix(self, camera): data = camera.data # operators seems much slower, we add a classmedthod to call the code directly for internal use (see handler.py) bundle = Bundle() e = 1.0/math.tan(data.angle/2.0) a = bpy.context.scene.game_settings.resolution_y/bpy.context.scene.game_settings.resolution_x n = data.clip_start f = data.clip_end msg_matrix = Message('/bge/scene/cameras/projection_matrix') msg_matrix.add(camera.name, e, 0.0, 2.0*data.shift_x, 0.0, 0.0, e/a, 2.0*data.shift_y/a, 0.0, 0.0, 0.0, (f+n)/(n-f), (2*f*n)/(n-f), 0.0, 0.0, -1.0, 0.0 ) perspective = 1 if data.type == 'ORTHO': perspective = 0 msg_persp = Message('/bge/scene/cameras/perspective') msg_persp.add(camera.name, perspective) bundle.add(msg_persp) bundle.add(msg_matrix) Client().send(bundle)
def _reply(cls, typehandler, path, args, types, source, user_data): obj, attr = cls._get_instance(path, args) data = typehandler.get(obj, attr) target = cls._parse_instance(args) msg = Message(path) if target: msg.add(*target) if data: msg.add(*data) bge.logic.server.send(source.url, msg)
def _reply(cls, typehandler, path, args, types, source, user_data): try: obj, attr = cls._get_instance(path, args) data = typehandler.get(obj, attr) target = cls._parse_instance(args) msg = Message(path) if target: msg.add(*target) if data: msg.add(*data) bge.logic.server.send(source.url, msg) except BLiveError as err: bge.logic.server.send(source.url, "/bge/error", err.reason, source.url)
def execute(self): # test if first arg contains '/' (path) if self.msg.split(' ')[0].count('/'): msg = Message(self.msg.split(' ')[0]) for i in self.msg.split(' ')[1:]: # digits are ints if i.isdigit(): msg.add(int(i)) # try convert args with '.' to float otherwise stays string elif i.count('.') == 1: try: msg.add(float(i)) except ValueError: msg.add(i) # all other args parsed as strings else: msg.add(i) Client().send(msg)
def execute(self, context): debug = context.window_manager.blive_debug # test if first arg contains '/' (path) if debug.message.split(' ')[0].count('/'): msg = Message(debug.message.split(' ')[0]) for i in debug.message.split(' ')[1:]: # digits are ints if i.isdigit(): msg.add(int(i)) # try convert args with '.' to float otherwise stays string elif i.count('.') == 1: try: msg.add(float(i)) except ValueError: msg.add(i) # all other args parsed as strings else: msg.add(i) Client().send(msg) return{'FINISHED'} else: return{'CANCELLED'}
def execute(self, context): debug = context.window_manager.blive_debug # test if first arg contains '/' (path) if debug.message.split(' ')[0].count('/'): msg = Message(debug.message.split(' ')[0]) for i in debug.message.split(' ')[1:]: # digits are ints if i.isdigit(): msg.add(int(i)) # try convert args with '.' to float otherwise stays string elif i.count('.') == 1: try: msg.add(float(i)) except ValueError: msg.add(i) # all other args parsed as strings else: msg.add(i) Client().send(msg) return {'FINISHED'} else: return {'CANCELLED'}