Exemplo n.º 1
0
 def deserialise(self, coords):
     vertices_children = self._vertices.children
     try:
         for i, coord in enumerate(zip(*(iter(coords),)*3)):
             vertices_children[name_of_vertex(i)].localPosition = coord
     except KeyError:
         raise SerialisedDataUnmatched
Exemplo n.º 2
0
 def deserialise(self, coords):
     vertices_children = self._vertices.children
     try:
         for i, coord in enumerate(zip(*(iter(coords), ) * 3)):
             vertices_children[name_of_vertex(i)].localPosition = coord
     except KeyError:
         raise SerialisedDataUnmatched
Exemplo n.º 3
0
    def on_communication(self, states):
        # Local reference
        surface = self.surface
        # Prepare and send data
        data = []
        for identifier, vertex in surface.selected():
            vertex_position = vertex.localPosition
            data.append((index_of_vertex(vertex.name),
                         vertex_position[0],
                         vertex_position[1],
                         vertex_position[2]))

        # Receive data and act based on it
        for vertex in surface.unlock_all():
            vertex.color = COLOR_UNLOCKED
        try:
            received_data = self._connection.transfer(data)
            for i, x, y, z in received_data:
                vertex_name = name_of_vertex(i)
                surface[vertex_name].localPosition = x, y, z
                surface.lock(vertex_name).color = COLOR_LOCKED
            surface.update()
        # If 'NoneType|int' object is not iterable
        except TypeError:
            if received_data == COMM_RESTART:
                raise RestartApplication
Exemplo n.º 4
0
 def serialise(self) -> 'list':
     coords = []
     vertices_children = self._vertices.children
     try:
         for i in count():
             coords.extend(vertices_children[name_of_vertex(i)].localPosition)
     except KeyError:
         return coords
Exemplo n.º 5
0
 def serialise(self) -> 'list':
     coords = []
     vertices_children = self._vertices.children
     try:
         for i in count():
             coords.extend(
                 vertices_children[name_of_vertex(i)].localPosition)
     except KeyError:
         return coords
Exemplo n.º 6
0
    def on_communication(self, states):
        # Local reference
        surface = self.surface
        # Prepare and send data
        data = []
        for identifier, vertex in surface.selected():
            vertex_position = vertex.localPosition
            data.append((index_of_vertex(vertex.name), vertex_position[0],
                         vertex_position[1], vertex_position[2]))

        # Receive data and act based on it
        for vertex in surface.unlock_all():
            vertex.color = COLOR_UNLOCKED
        try:
            received_data = self._connection.transfer(data)
            for i, x, y, z in received_data:
                vertex_name = name_of_vertex(i)
                surface[vertex_name].localPosition = x, y, z
                surface.lock(vertex_name).color = COLOR_LOCKED
            surface.update()
        # If 'NoneType|int' object is not iterable
        except TypeError:
            if received_data == COMM_RESTART:
                raise RestartApplication
Exemplo n.º 7
0
# Import plastey modules
path.insert(0, '.')
from utils import load_from_file, name_of_vertex
from const import INT_PERMANENT_FOLDER, OBJ_GEOMETRY

#------------------------------------------------------------------------------#
FILE_NAME = '.bz2'
SURF_TYPE = 0 # plane=0, sphere=1


#------------------------------------------------------------------------------#
coords = load_from_file(join(INT_PERMANENT_FOLDER, FILE_NAME))
try:
    # Adjust locations of the dots
    for i, coord in enumerate(zip(*(iter(coords),)*3)):
        bpy.data.objects[name_of_vertex(i)].location = coord

    # Deselect everything
    bpy.ops.object.select_all(action='DESELECT')
    # Get and surface object
    surface = bpy.data.objects[OBJ_GEOMETRY]
    surface.select = True
    bpy.context.scene.objects.active = surface

    # If surface is a plane
    if not SURF_TYPE:
        modifier = surface.modifiers.new('Solidify', 'SOLIDIFY')
        modifier.thickness = 1.2
        modifier.use_quality_normals = True

    # Apply modifiers