def __init__(
        self,
        context_identifier: Any,
        opengl_resource_pack: OpenGLResourcePack,
        level: "BaseLevel",
        draw_floor=True,
        draw_box=False,
    ):
        OpenGLResourcePackManager.__init__(self, opengl_resource_pack)
        ContextManager.__init__(self, context_identifier)
        self._level = level
        self._camera_location: CameraLocationType = (0, 150, 0)
        # yaw (-180 to 180), pitch (-90 to 90)
        self._camera_rotation: CameraRotationType = (0, 90)
        self._dimension: Dimension = "overworld"
        self._render_distance = 5
        self._garbage_distance = 10
        self._draw_box = draw_box
        self._draw_floor = draw_floor
        self._selection = GreenRenderSelectionGroup(
            context_identifier, self.resource_pack,
            self.level.selection_bounds)
        self._chunk_manager = ChunkManager(self.context_identifier,
                                           self.resource_pack)

        self._last_rebuild_camera_location: Optional[
            numpy.ndarray] = None  # x, z camera location
        self._needs_rebuild = (
            True  # Should we go back to the beginning and re-find chunks to rebuild
        )
        self._chunk_rebuilds = self._rebuild_generator()
        self._rebuild_time = 0
示例#2
0
    def __init__(
        self,
        context_identifier: str,
        resource_pack: OpenGLResourcePack,
        selection: SelectionGroup = None,
    ):
        ContextManager.__init__(self, context_identifier)
        OpenGLResourcePackManagerStatic.__init__(self, resource_pack)

        self._boxes: List[RenderSelection] = []

        if selection:
            self.selection_group = selection
示例#3
0
 def __init__(
     self,
     context_identifier: Any,
     resource_pack: OpenGLResourcePack,
 ):
     OpenGLResourcePackManager.__init__(self, resource_pack)
     ThreadedObjectContainer.__init__(self)
     ContextManager.__init__(self, context_identifier)
     self._objects: List[RenderLevel] = []
     self._transforms: List[TransformType] = []
     self._world_translation: List[LocationType] = []
     self._transformation_matrices: List[numpy.ndarray] = []
     self._active_level: Optional[int] = None
     self._camera_location: LocationType = (0.0, 100.0, 0.0)
示例#4
0
 def __init__(self, context_identifier: str, texture: int):
     """Create a new TriMesh.
     The object can be created from another thread so OpenGL
     variables cannot be set from here"""
     ContextManager.__init__(self, context_identifier)
     self._vao = None  # vertex array object
     self._vbo = None  # vertex buffer object
     self._shader = None  # the shader program
     self._transform_location = (
         None  # the reference within the shader program of the transformation matrix
     )
     self._texture_location = None  # the location of the texture in the shader
     self._texture = texture
     self.verts = self.new_empty_verts()  # the vertices to draw
     self.draw_start = 0
     self.draw_count = 0  # the number of vertices to draw
    def __init__(
        self,
        context_identifier: Any,
        opengl_resource_pack: OpenGLResourcePack,
        level: "BaseLevel",
        draw_box=False,
        draw_floor=False,
        draw_ceil=False,
        limit_bounds=False,
    ):
        """
        Create a new RenderLevel instance.

        :param context_identifier: The identifier for the opengl context.
        :param opengl_resource_pack: The resource pack to use for models and textures.
        :param level: The level to pull data from.
        :param draw_box: Should the box around the level be drawn.
        :param draw_floor: Should the floor below the level be drawn.
        :param draw_ceil: Should the ceiling above the level be drawn.
        :param limit_bounds: Should the chunks be limited to the bounds of the level.
        """
        OpenGLResourcePackManager.__init__(self, opengl_resource_pack)
        ContextManager.__init__(self, context_identifier)
        self._level = level
        self._camera_location: CameraLocationType = (0, 150, 0)
        # yaw (-180 to 180), pitch (-90 to 90)
        self._camera_rotation: CameraRotationType = (0, 90)
        self._dimension: Dimension = level.dimensions[0]
        self._render_distance = 5
        self._garbage_distance = 10
        self._draw_box = draw_box
        self._draw_floor = draw_floor
        self._draw_ceil = draw_ceil
        self._limit_bounds = limit_bounds
        self._selection = GreenRenderSelectionGroup(
            context_identifier, self.resource_pack,
            self.level.bounds(self.dimension))
        self._chunk_manager = ChunkManager(self.context_identifier,
                                           self.resource_pack)

        self._last_rebuild_camera_location: Optional[
            numpy.ndarray] = None  # x, z camera location
        self._needs_rebuild = (
            True  # Should we go back to the beginning and re-find chunks to rebuild
        )
        self._chunk_rebuilds = self._rebuild_generator()
        self._rebuild_time = 0