LevelStream 实现超大无缝地图--官方文档学习
The Level Streaming feature makes it possible to load and unload map files into memory as well as toggle their visibility all during play. This makes it possible to have worlds broken up into smaller chunks so that only the relevant parts of the world are taking up resources and being rendered at any point. If done properly, this allows for the creation of very large, seamless levels that can make the player feel as if they are playing within a world that dwarfs them in size.
关卡流(LevelStreaming)使得我们在游戏运行的整个过程中动态的加载、卸载地图,这样以来,使得通过“把大地图分成许多小的部分,只有与当前状态有关的地图部分资源加载”的思路来创建无缝超大地图成为了可能。
World Composition User Guide 世界组合使用指南
On this page:这页将会涉及
Overview概述
Activating World Composition 激活世界组合功能
Levels Hierarchy 关卡层级关系
Levels Composition关卡组合
Layers层
Minimap小地图
UI KeyUI交互与提示
Level Details层详细信息
Tile Settings瓦片设置
LOD SettingsLOD设置
World Origin Shifting 世界原点
Big Worlds and Multiplayer 超大世界和多玩家
Creating Landscape Levels 创建地形关卡
Tiled Landscape Import 导入瓦片地形
Overview 概述:
World Composition has been designed to simplify managing large worlds. One of the goals is to avoid using a persistent level to store streaming information as it becomes a bottleneck when a team of level designers want to work on levels simultaneously. The persistent level does not store any streaming information and instead scans a folder and treats all found levels as streaming levels. Each streaming level has information stored in the package header, which World Composition can read without loading the level into memory. Initially, all levels except the persistent level are unloaded in World Composition. You can load or unload any part of the world manually at any time.
World Composition relies on a world origin shifting feature which, when used with distance based level streaming, allows you to create worlds which are not limited to the WORLD_MAX constant value hard-coded into the engine.
世界组合(World Composition)这个功能的设计是为了简化对大地图管理。目标之一是,不至于因为只能使用一个持续的关卡来存储流数据,而使得“当关卡设计团队想要水平工作同时设计关卡“这样的想法成为瓶颈、不可能的想法。持续的关卡不存储任何信息流,相反,只会一次性扫描整个文件夹并且找到所有的关卡作为关卡流。每个关卡流的信息存储在包的头部,这些信息可以被世界组合(World Composition)功能来直接读取而不用提前把这些蓝图存放到内存中。最开始的时候,除了持续关卡其他所有的关卡都会存储在世界组合(World Composition)中,你可以在任何时刻加载或者卸载世界任何的一部分。
世界的组成(World Composition)依赖于世界原始的转移特性,当通过使用基于距离的关卡流,允许你可以创建出不局限于引擎中设定好的世界最大值 WORLD_MAX constant这个常量。
Activating World Composition 激活“世界组合”功能
World Composition managed worlds can be activated by switching on Enable World Composition flag in World Settings.
You can also disable world origin shifting by switching off Enable World Origin Rebasing flag in World Settings.
被”世界组合“(World Composition)管理的世界可以通过勾选在世界设置中的Enable World Composition布尔值。
当然你也可以通过不勾选世界设置中的Enable World Origin Rebasing 布尔值来不使用世界原始转移特性。
勾选Enable World Composition时,系统会自动扫描大地图所在文件夹,如果当大地图所在文件夹存在有其他地图的时候,系统会提示
Levels Hierarchy 关卡的层次
After you have activated World Composition, all the levels in your project will be visible in the Levels window. To open this window, click on theWindows menu, and then select Levels.
The entries in the Levels window represent your world hierarchy.
当你激活了世界组合的命令后,你可以在关卡面板(英文:Level)中看到你项目中的所有关卡。关卡面板可以windows菜单的
levels里打开
在关卡窗口的条目代表你的世界的层次结构。
The level with its name in blue text is the current level. Currently loaded levels will have their names in white text, while levels that are unloaded have grayed-out names.
To load a level in the world composition, just double-click its name. Using drag-and-drop, you can establish relationships between individual levels. Child levels store position relative to the parent level, so when you change the parent level's position all child levels will recalculate their position accordingly.
In the Levels window, you can lock and save levels, as well as open the Level Blueprint for each level, with buttons to the right of the level name.
窗口中名字为蓝色的关卡是当前的关卡,当前加载的关卡(如图中:SmallMap1)的名字为白色,卸载了的关卡(图中:SmallMap2)的名字为灰色。
只需要通过在窗口中双击关卡的名字你就可以把它加载到世界组合( world composition)中,加载完成后你可以观察一下关卡名字的颜色变化哦!可以通过拖拽的形式来建立关卡之间的父子关系。这里注意,子关卡存储的是相对位置!即相对于父关卡的位置,所以一旦你改变了父关卡的位置时,对应的所有子关卡的位置也会因此发生改变。
在关卡窗口中,你可以锁定或者保存关卡,也可以直接打开每一个关卡的关卡蓝图。
这里注意一下吧,一旦加载了一个地图后,可以观察到永久性关卡有许多属性发生了变化:
Levels Composition 关卡组合:
When Enable World Composition is on, there is a button to open World Composition at the top of the Levels window.
当勾选了Enable World Composition时,可以通过下面这个按钮来打开世界组合窗口
Here, you can see the layout of your world.
在这里,你可以看到你的世界的布局
Layers 层
By default, all levels are assigned to an Uncategorized layer. Layers hold information about streaming distances, so levels assigned to a particular layer will inherit that streaming distance. Levels assigned to a layer with streaming distance disabled will be excluded from distance streaming, and can instead be controlled using Blueprints.
You can create new layers by clicking the + button to the right of the existing layer names. Each level can only be assigned to one layer at a time.
Layers can not be deleted or edited, so if you would like to change streaming distance settings, create a new layer with your desired settings and assign levels to it. Layers which have no assigned levels will be deleted automatically the next time you open a level.
You can filter your levels by layer by clicking on the layer name above the minimap. You can toggle multiple layers by using Control+Mouse Click. When there are no layers toggled on, no filtering is performed.
默认情况下,所有的关卡被分配到 未分类(Uncategorized )这一层。各个层都保存了关卡流的距离信息,所以被分配到一个特定的层的关卡会继承这个关卡流的距离信息。分配层的流媒体远程禁用将被排除在距离流水平,并可控制使用的蓝图。被分派到一个禁用了关卡流距离的层中将会排除掉关卡流距离的影响,并且可以被蓝图所控制。
可以通过点击已经存在的层的名字右边的+按钮来创建新的层,记住,每一个关卡同一时刻只能被指定到一个层。
特别注意!层不能被删除或编辑的,所以如果你想改变关卡流的距离设置,用你需要的设计来创建一个新的层,并且给它分配对应的关卡。没有指定关卡的层将会在你下一次你打开关卡的时候被自动删除。
你可以通过层来过滤关卡,方法是在小地图上单击层的名字。您可以通过Ctrl+Mouse单击切换多个层。当没有层打开的时候,不会存在过滤。
Minimap 小地图
Each level except the persistent level has an image and position in the world, which are displayed in the minimap. The image of the level is updated every time content in the level is changed. This map allows you to preview your world from the top and arrange the position of levels by dragging them. When dragging levels, they will snap to the edges of other levels. Holding the Control key will cause the level movement to use the Level Editor's snapping settings. Note that level position is stored as integer coordinates, so for exact matching of adjacent level tiles, your levels must have integer bounds sizes.
除了永久的关卡,其他所有的关卡都会在小地图中有一个图片和一个在世界中的位置。当关卡里面的内容发生改变时关卡的这张图片也会更新。小地图允许你在顶视图预览你的世界,并且通过拖拽各个关卡来设定他们的位置。当拖动关卡的时候,他们将会捕捉在其他关卡的边缘。按住Control键会使得水平运动时使用关卡编辑器的捕捉设置功能。注意关卡位置存储为整数坐标,所以当需要精确的调整关卡瓦片(瓦片地图)位置的时候,你的关卡必须有整数范围大小。
Levels based on Landscape Actors have snapping based on the base landscape component size. This is done to enable seamless editing between Landscape Actors in different levels.
基于 Landscape Actors 地形物体的关卡的边缘是基于父类landscape 地形组件的尺寸的。这样做是为了在不同Landscape Actors地形物体不层次间无缝启用编辑。
All Landscape Actors will have tranformations disabled in the Editor Viewport to ensure that the landscape can not be moved by an arbitrary amount and lose its ability to be aligned with other landscape levels.
所有的Landscape Actors地形物体都可以在编辑器试图中禁用transform的属性,来确保l地形andscape 不能通过任意量来移动并且也不能被和其他关卡中的地形landscape 对齐。
The first time a level is loaded in World Composition, a new Level Bounds Actor is automatically created in the level. The Level Bounds Actor is used to calculate the size of the level.
By default, the Level Bounds Actor automatically resizes to include all Actors found in the level. However, some Actors, like skyboxes, can have very large bounding boxes, which will result in overly large level tiles in the world minimap. If you have Actors like this that you do not want to include in the level bounds calculations, you can disable automatic level bounds calculations and set a fixed size for the Level Bounds Actor.
一个关卡在第一次被加载到世界组合World Composition时,一个新的叫做关卡边界(Level Bounds Actor)的物体 将会被自动在这个关卡中创建。 关卡边界物体(Level Bounds Actor) 物体是用来计算关卡的大小的,可以在世界大纲试图中搜索找到他!
默认情况下,关卡边界物体会自动调整当前关卡中的所有物体的大小。然而,一些物体,比如天空盒,可以有一个非常大的边界盒子,这将导致在世界地图中存在过大的瓦片关卡。如果你有一些这样的不想要被关卡边界计算的物体,你可以禁止自动关卡边界计算并且给关卡边界物体设置一个固定大小的值。
urrently, realtime must be enabled in the viewports for the Level Bounds Actor to function.
目前来说,realtime 必须在视图中启用 Level Bounds Actor这样才会起到作用。
The minimap has a yellow square indicating the safe edit area. The safe edit area's size is equal to the WORLD_MAX contant in the engine. Levels outside of this area will be hidden automatically, and their level images will reflect this. World Composition tries to keep levels you are working on close to the Editor world origin. This feature is called "focusing" and may shift the current world origin to a new position if you begin editing a level outside of the safe edit area. Shifted levels still preserve their Actors' original transformations when they are saved, so saving a level that is currently shifted will not change the Actors' absolute positions.
小地图上有一个黄色的正方形区域,表示这里是安全编辑区域。安全编辑区域的大小等于引擎中的world_max常数。本区外的关卡将被自动隐藏,他们的关卡图像反映了这个。世界组成World Composition试图保持你正在编辑的关卡接近引擎编辑器世界的原点。这一特性称为“聚焦”,如果你开始在安全编辑区域外编辑一个关卡可能会改变目前的世界原点到一个新的位置,转移关卡仍然保持他们的物体的原始transform属性,当他们被保存了时,因此保存一个正在转移的关卡并不会改变物体的绝对位置。
UI Key UI的值
Level Details
To see the details for any level in the Level window, select it and then click on the magnifying glass icon in the toolbar. This will summon theLevel Details window, where you can also swap between available levels' information with a dropdown menu.
如果想要查看关卡窗口里面任意关卡的详细信息,选择他,点击就行了。注意,这里还有一个小技巧,就是可以在关卡详细信息窗口中可以切换到其他关卡,点击上面那个下拉框即可。
LOD Settings 细节设置(Levels of Detail)
Each level in the world composition can have up to 4 LOD streaming levels. LOD streaming levels are similar to mesh LOD. Depending on streaming distance settings streaming level will be replaced with corresponding LOD level. LOD levels automatically discovered by World Composition using pattern _LOD#. Where number should be from 1 to 4. LOD levels can be created manually or with automatic LOD map generator which requires Simplygon.
世界组合中的每一个关卡都可以拥有最多4个LOD关卡流,LOD关卡流和普通的LOD网格很相似。根据流距离的设置关卡流将会被相应的LOD关卡所取代。LOD关卡会通过世界组合中使用的LOD# 来被查询到。
这个数值的取值范围时1--4.LOD关卡可以被手动创建,或者使用LOD地图生成器来自动创建,注意,后者需要Simplygon技术。
Unreal Engine 4 ships with a Simplygon integration, but you will need a license from Simplygon to use it.
虚幻四引擎整合了Simplygon ,但是如果你想要使用它的话,需要取得一个证书认证才可以
World Origin Shifting 世界原点的偏移
The World Composition editor supports shifting of the world origin by some arbitrary amount. Shifting the world origin results in adding an offset vector to all registered Actors in the world. Each Actor has an ApplyWorldOffset function which can be overridden in the child classes to do additional things. In case you have created a new AActor derived class and store absolute position values in it, you have to override ApplyWorldOffset function to make it work correctly with world origin changes and shift your absolute values in it. Rendering and physics primitives will be shifted in parallel to Actors in game thread.
世界组成编辑器支持移动世界原点到任意位置。移动世界原点将会导致在世界中注册的所有Actor物体添加一个偏移量。每一个Actor物体都有一个ApplyWorldOffset ()函数,当添加一些其他的事情时,他会被在子类里重载。如果你已经创建了一个新的AActor派生类并且存储了它的绝对位置值,你必须重写applyworldoffset函数,使它与世界的原点的改变正常的变化。渲染和物理元素将被转移在平行于游戏中的线程的一个Actor物体中。
Big Worlds and Multiplayer 超大地图和多玩家
Right now world origin shifting is not supported in the multiplayer games. Here are two solutions that can be implemented for your specific needs:
Implement your own server solution. MMO licensees mostly do this.
Implement some layer between clients and unreal dedicated servers which will transform shifted absolute positions from the clients and route them to the right dedicated server, which only holds part of the world where client is.
However if you disable world origin, shifting you can run a tiled world with a dedicated server. Dedicated servers will load all distance dependent levels, and each connected client will work as usual loading only level that satisfy streaming distance settings. A server holds a list of visible levels for each client and filters Actor replication by this list.
目前为止,世界的原点偏移将不在多人游戏中支持。但是这里有两个解决方案,可以实现为您的特定需求:
实现你自己的服务器解决方案。网络游戏授权大多做这个。
实现客户和虚幻的专用服务器,将转移的绝对位置从客户和路由到正确的服务器之间的一些层,只能装的世界里,客户端部分。
Creating Landscape Levels 创建地形关卡
Right-clicking on a level tile, to summon the context menu, which has a Landscape Actor inside will bring an options for adding adjacent levels with landscape proxy Actors in them. This requires the adjacent levels landscapes have size equal to source Landscape size.
右键一个关卡瓦片,召唤一个有着Landscape Actor 地形物体的上下文菜单,将会给你提供一个增添相邻的关卡的选项并在其中有一个代表性的actor物体。这需要相邻的关卡地形的大小一致。
Tiled Landscape Import 瓦片地形的载入
In the Levels panel toolbar you can find an option for importing tiled landscape. Tiled landscapes are created from a tiled heightmap, where each heightmap tile will represent a level with a landscape Actor in it. Tiled heightmaps/weightmaps can be exported from an application like World Machine. Adjacent heightmaps tiles should share border vertices ("Share edge vertices" in World Machine). And, each tile resolution should follow the recommendations from this page Creating Landscapes.
在关卡工具栏中,你可以找到一个载入瓦片地形的选项。瓦片地形从一个瓦片高度图中创建,每一个高度图瓦片将会代表一个有地形的关卡。瓦片地形高度图可以被一些其他的工具到处,比如worldmachine。相邻的瓦片高度图应该分享边界最高点(在worldmachine中叫做”"Share edge vertices"“), 并且每一个瓦片地图高度图的分辨率最好和这一章节创建地形Creating Landscapes.匹配。