Esempio n. 1
0
 def append(
     self,
     structure: Structure,
     location: LocationType,
     scale: ScaleType,
     rotation: RotationType,
 ):
     """Append a structure to the list and activate it."""
     # TODO: update this to support multiple structures
     self.clear()
     self._structures.append(
         RenderStructure(
             self.context_identifier,
             structure,
             self._resource_pack,
             self._texture,
             self._texture_bounds,
             self._resource_pack_translator,
         ))
     self._transforms.append((location, scale, rotation))
     self._transformation_matrices.append(
         transform_matrix(location, scale, rotation))
     if self._active_structure is None:
         self._active_structure = 0
     else:
         self._active_structure += 1
Esempio n. 2
0
 def set_active_transform(self, location: LocationType, scale: ScaleType,
                          rotation: RotationType):
     if self._active_structure is not None:
         self._transforms[self._active_structure] = (location, scale,
                                                     rotation)
         self._transformation_matrices[
             self._active_structure] = transform_matrix(
                 location, scale, rotation)
 def active_transform(self, location_scale_rotation: TransformType):
     """Set the transform for the active object.
     Has no effect if there is no active object.
     :param location_scale_rotation: The location, scale and rotation
     :return:
     """
     if self._active_level is not None:
         location, scale, rotation = location_scale_rotation
         self._transforms[self._active_level] = (location, scale, rotation)
         self._transformation_matrices[self._active_level] = numpy.matmul(
             transform_matrix(scale, rotation, location),
             displacement_matrix(
                 *self._world_translation[self._active_level]),
         )
Esempio n. 4
0
 def active_transform(self, location_scale_rotation: TransformType):
     """Set the transform for the active object.
     Has no effect if there is no active object.
     :param location_scale_rotation: The location, scale and rotation
     :return:
     """
     if self._active_level_index is not None:
         location, scale, rotation = location_scale_rotation
         self._transforms[self._active_level_index] = (location, scale, rotation)
         self._is_mirrored[self._active_level_index] = bool(
             sum(1 for s in scale if s < 0) % 2
         )
         self._transformation_matrices[self._active_level_index] = numpy.matmul(
             transform_matrix(scale, rotation, location),
             displacement_matrix(*self._world_translation[self._active_level_index]),
         )
         self._set_camera_location()
Esempio n. 5
0
 def append(
     self,
     level: BaseLevel,
     dimension: Dimension,
     location: LocationType,
     scale: ScaleType,
     rotation: RotationType,
 ):
     """Append a level to the list and activate it."""
     # TODO: update this to support multiple levels
     self.clear()
     render_level = RenderLevel(
         self.context_identifier,
         self._resource_pack,
         level,
         draw_box=True,
         limit_bounds=True,
     )
     render_level.dimension = dimension
     # the level objects to be drawn
     self.register(render_level)
     # the transforms (tuple) applied by the user
     self._transforms.append((location, scale, rotation))
     self._is_mirrored.append(bool(sum(1 for s in scale if s < 0) % 2))
     self._world_translation.append(
         (
             -(
                 (
                     level.bounds(dimension).min_array
                     + level.bounds(dimension).max_array
                 )
                 // 2
             ).astype(int)
         ).tolist()
     )
     # the matrix of the transform applied by the user
     self._transformation_matrices.append(
         numpy.matmul(
             transform_matrix(scale, rotation, location),
             displacement_matrix(*self._world_translation[-1]),
         )
     )
     if self._active_level_index is None:
         self._active_level_index = 0
     else:
         self._active_level_index += 1
 def append(
     self,
     level: BaseLevel,
     dimension: Dimension,
     location: LocationType,
     scale: ScaleType,
     rotation: RotationType,
 ):
     """Append a level to the list and activate it."""
     # TODO: update this to support multiple levels
     self.clear()
     render_level = RenderLevel(
         self.context_identifier,
         self._resource_pack,
         level,
         draw_floor=False,
         draw_box=True,
     )
     render_level.dimension = dimension
     # the level objects to be drawn
     self._levels.append(render_level)
     # the transforms (tuple) applied by the user
     self._transforms.append((location, scale, rotation))
     self._world_translation.append(
         (-((level.selection_bounds.min + level.selection_bounds.max) //
            2).astype(int)).tolist())
     # the matrix of the transform applied by the user
     self._transformation_matrices.append(
         numpy.matmul(
             transform_matrix(scale, rotation, location),
             displacement_matrix(*self._world_translation[-1]),
         ))
     if self._active_level is None:
         self._active_level = 0
     else:
         self._active_level += 1