Zh/Level Design Introduction (Portal 2)/Your First Level

__TOC__
（刷子）是在Hammer中用Block工具创建的3D物体。Brush用来创建天花板和地板之类大块的表面的。我们将使用brush来创建一个房间。
== 用brush创建地板 ==
# 在左边的Tool工具栏中, 选择 Block Tool.
# 然后，在Top 2D view（顶视图）中，单击左键并向右下拖动。如图所示。
# 你应该可以看到你拖动出来的一个虚线的矩形框。
# 创建一个512x512单位大小的方块.
# 按键盘上的 键创建出brush。
回到选择模式：点击工具栏上的 Selection tool 图标或者按 键.
在选择模式中，选中刚才的那个brush，左键单击边缘的小方块可以改变brush的大小。
现在我们来调整这个brush的厚度(为了用来做地板)，从64单位调整到16。但首先要调整grid（网格）的大小。
=== 关于网格 ===
grid出现在每个2D视图。默认情况下，任何物体都会对齐到网格（grid）。虽然你可以关闭对齐到网格，但是还是留着比较好，以防止在地图中出现泄漏（leak）之类的错误。
默认网格大小是64单位, 也就是说线之间的间隔是64单位。当前网格大小在Hammer窗口的下面状态栏中显示着。
* 点击 Smaller Grid 图标 使网格缩小一倍。也可以用 键调整。
* 点击 Larger Grid 图标 使网格放大一倍。也可以用 键调整。
按 键两次，使网格缩小到16单位。确保Hammer窗口状态栏中显示的是Grid: 16。如果不是的话，按 或 键来调整。
=== 调整地板的大小 ===
现在网格应该足够小了。 
看右下方的视图。鼠标移上去的时候，应该显示Side标签。拖动brush的上边缘，令它的厚度为16单位。
=== 移动brush ===
你可以移动创建出来的brush。选择 Selection Tool （选择工具），鼠标移动到2D视图中的brush上。光标会变成一个四方向箭头，以表示可以移动物体。
在2D视图中点击并拖动brush。一旦释放，brush就移动到新的位置了。
也可以使用方向键移动物体。但首先要设置一下Hammer的选项，方法如下：
# 在 Tools 菜单选择 Options，出现 Configure Hammer 对话框。
# 选择 2D Views 面板.
# 设置选项有很多，无视之。选中 Arrow keys nudge selected object/vertex。
# 按 OK 确认。
现在把这个地板brush，在Side视图中向下移动16单位。（按 一次）
== 在2D视图中导航 ==
* 滚动条可以平移视图。
* 更好的方法是，按住 键，单击左键并平移。
* 使用鼠标滚轮来缩放。
== 材质 ==
要在3D Camera视图中看到贴图, 右击3D Camera视图上 camera 文本，选择 3D Textured。
=== 在3D Camera视图中导航 ===
在3D中移动和2D视图中有所不同：
* 按住 键，并拖动鼠标左键旋转镜头。
* 按住 键，并拖动鼠标右键，用来上下和左右移动镜头。
* 按住 键，并同时按住鼠标左右键进行拖动，来前后移动镜头。
* 按住 键时，也可以用 , , , 和 键，来移动镜头。
* 键，用来开关 "mouse look" 模式。切换到3D Camera视图，并按下 键。就可以像在游戏中那样用鼠标控制镜头了。
在 3D Camera 视图中向上移动，并查看你刚才创建的地板。
你会看到地板的贴图是默认的。 改变贴图的方法是，点击在 Texture 面板的 Browse按钮。
会打开 Texture Browser 窗口。
在底部的 Filter 栏，可以按照名字来过滤贴图。在这个教程中，输入 "dev_measure"（包含下划线）。就会有一堆“开发者”贴图，来辅助创建东西。
选择 dev/dev_measuregeneric01b 并双击。
这应该返回编辑器的4个视图，并将通用的开发人员纹理作为当前的纹理放在Texture面板中。
选择地板brush，如果它还没有被选中，通过在相机视窗点击它。 它应该变红。
选择brush后, 点击Tool面板上的 Apply current texture 图标将当前纹理应用于选区。 灰色开发者纹理应该出现在地板上，如图所示。
== 创建墙壁和天花板 ==
现在让我们来看看如何创建墙壁和天花板。最简单的方法是复制地板brush。
=== 复制 ===
你也可以选择一个现有的brush并复制它来创建它们。
复制:
# 选择您创建的地板brush。
# 将光标移到Side 视图.
# 按住键，并按键创建一个副本，并向上移动一个网格单元。
这将在现有地板的顶部创建与地板完全相同的brush。
现在，您可以更改此新brush的大小和尺寸，以创建一堵墙，抓住brush上的角柄并将其拖动到所需的大小。 让我们将墙高128单位，厚16单位。
现在再将墙壁重复3次以勾勒地板轮廓。
再将地板brush复制一遍，然后将其抬起成为天花板。
== 删除笔刷 ==
要删除一个brush, 用 Selection Tool 选中它并按下 键.
== 多选 ==
您会注意到，在“Camera”视口中，如果您在房间内导航，由于所有的墙壁，地板和天花板都具有相同的纹理，因此很难分辨发生了什么。 接下来，我们将墙壁更改为其他纹理。
通过按住键，你可以在“Camera”视口中每次单击一个来选择所有墙。 您还必须使用键与鼠标左键来控制摄像头旋转，以便可以看到并选择每个墙。
选中所有墙后，单击“Current texture”栏中的“Browse”按钮。 这次，选择当前纹理旁边的橙色纹理，标签为dev/dev_measuregeneric01。双击将其选中，浏览窗口会自动关闭。
使用 Tool 栏中的 工具给墙壁应用橙色纹理。
== 文件保存 ==
To save a level, you can use + or Save from the File menu.
You will need to give the map a file a name and choose the directory to place it in.
For this tutorial, name the map "tutorial01" and save it into the mapsrc directory, located by default at:
 C:\Program Files\Steam\steamapps\common\portal 2\sdk_content\maps\
Your directory may be slightly different, depending upon where you have installed Steam.
== 示例地图 ==
When you went to save your map, you may have noticed other directories underneath the mapsrc path. The Portal 2 Authoring Tools come with some example maps to help you.
Directory 	Contents
maps\mp_coop_doors 	简单的合作地图。
maps\mp_coop_paint_red_racer	带有推进凝胶的合作地图。
maps\sp_a2_column_blocker 	带有强光桥和一些其他的东西的单人地图。
maps\sp_a2_trust_fling 	Single Player map with Aerial Faith Plates.
maps\sp_a3_speed_ramp 	Single Player map with Propulsion Gel.
maps\sp_a4_laser_catapult 	Single Player map with Tractor Beams, Lasers and an Aerial Faith Plate.
maps\zoo_mechanics 	Contains most of the the gameplay mechanics used in Portal 2.
== 放置实体 ==
Next we'll place an entity in our level:
# Select the Entity Tool on the Tool Bar.
# Once the Entity Tool is enabled, the Entity selection list on the Object bar becomes active.
# Keep the Categories entry as Entities.
# Click the arrow on the Objects drop down list and select info_player_start.
# Now, navigate in the Camera viewport to the middle of the inside of the room.
# left-click on the floor to place the entity.
This will place an info_player_start entity in the middle of the room.
=== 放置一个光源 ===
现在我们将在地图上放置一个光源:
# 再次选择 Entity Tool 
# Select light from the Objects drop down list on the Object bar.
# This time, place the light on the ceiling (above the player's head).
# Go back into selection mode by clicking on the Selection tool in the Tool Bar or by pressing the key.
Next we'll change some settings on the light. Bring up the light's properties by double-clicking it in the Camera viewport or by selecting it (left-clicking on it) and then pressing the + keys. This will bring up the Object Properties dialog box.
From the Object Properties, you can change various properties of the entity. For example, you can change the Brightness of this light. Click on the Brightness row under Keyvalues and you will see a set of numbers on the drop down menu on the right side. The default setting for the brightness of a light is 255 255 255 200. The first three numbers represent the RGB values (color) and the last number represents the intensity of the light. 
You can click on the Pick Color button to select a color rather than input values for it.
Simply click on the color you want the light to be and click OK.
This will bring you back to the Object Properties dialog box for the light. You should see any changes you made to the brightness on the Brightness row and the drop down field on the right side if the Brightness row is selected.
Click the Apply button to set your changes to the entity and close the dialog box by clicking on the "X" at the upper right side of the window.
=== 放置一个 prop_static ===
Entities also consist of props like furniture, decoration, and complex parts of architecture. There are a variety of different kinds of props. Prop_static entities are props that are static – they don't move, animate, turn on or turn off. There are also prop_dynamic entities that can move, animate, be enabled and disabled. There are also prop_physics entities which the player can interact with and behave physically as they would in the real world.
To place a prop:
# Select on the Entity Tool again.
# Go to the Object bar and change the Objects field to prop_static.
# Point to the floor in front of the model of Francis and left-click to place a prop_static. You will see a red cube that represents the prop_static before a model is attached to it.
# Go back into selection mode by clicking on the Selection tool in the Tool Bar or by pressing the key.
# Double-click on the red cube to open the properties.
# Double-click on the World Model field to open the Model Browser.
=== Selecting the model ===
# In the Filter field at the bottom of the dialog box, type in "paint". This will show all the models that have the word "paint" in their name.
# Scroll down to the one named:
#: "props_underground\underground_paintdropper.mdl".
#: It should look like the image shown.
# Click OK to select it and close the browser and return to the Object Properties dialog box. You should see the name of the model now in the World Model row.
# Click the Apply button to set your changes to the entity.
# Close the Properties box.
You will see the table that you just placed in the room in any of the viewports in the editor.
== 移动实体 ==
You can move entities like our paintdropper the same way you can move brushes. Click and drag inside the bounding box of the selected entity to move it around with your mouse or put your mouse over any of the viewports and use the arrow keys on your keyboard to move them around. 
== 旋转 entity ==
To rotate an object , you simply select the object you wish to rotate using the Selection Tool , then click once on the object. You should see the object surrounded at the corners with circles. Mouse over a circle in any 2D view, then click and drag to rotate the object.
Use your mouse wheel to zoom into the Front viewport and click once inside the bounding box of the paintdropper model to make its four corners highlight with circles around each one.
Left-click and drag in a counter-clockwise motion to rotate the paintdropper so that it can drop paint from the ceiliing. 
== 在游戏中加载场景 ==
You have saved your map, but you will also need to compile it before it can be played in the game engine.
When a map is compiled, it is converted from the raw .VMF file that you just saved, into the .BSP format used by the game engine. The geometry is processed and the proper lighting and shadows are pre-calculated with several compile programs.
* Open the File menu, and choose Run Map... or press the key.
* The Run Map dialog will open.
* This dialog is used to set some basic compile parameters.
*# Make sure that Normal is set under the Run BSP, Run VIS, and Run RAD settings.
*# Under Additional game parameters:, make sure these settings are present, and type them in if not:
*#: -toconsole -dev -console +sv_lan 1
*# Now click the OK button to start the map compile process.
The Compile Process Window will show the progress of the compile. When the compilation is done, the game you are mapping for will automatically launch, and load your map in the engine.
Your level in the game should load up after compiling. It may take a minute or two.
== 开发者控制台 ==
Making levels for Portal 2 sometimes involves using commands typed into the window. The console can also be used to do things like spawn cubes and turrets to test your level.
If you haven't already, make sure the console is enabled in the game:
# Press the key in the game.
# Click on Options, then Keyboard/Mouse.
# Click on the Allow Developer Console and select "Enabled".
# Click on the Done Button.
# Click on Return to Game.
Using the developer console:
# Bring down your developer console (tilde).
# Type any console command and press the key.
# Hide the console again with .
== 穿墙模式 ==
One console command you'll find constantly useful is noclip mode. This is a mode that let's you fly around the level without being stopped ("clipped") by anything in the level. It's useful to get around large levels quickly.
To enter noclip mode:
* Press to enter the console.
* Type noclip in the console and press .
* Fly around the level.
* Type noclip again to leave noclip and walk around the level normally.
* You can toggle noclip with the press of a button with the bind console command. For example, bind mouse3 noclip for the middle mouse button.
== 一些有用的控制台命令 ==
有很多可以使用的控制台指令，下面是一些例子：
; sv_cheats 1
: 打开作弊，这样就可以使用很多平时不能使用的指令。
; map <地图名>
: 打开一个地图。
; changelevel <地图名>
: 在已有的会话（通俗点说就是不关闭服务器）的情况下更换地图。
; god 1
: 开启/关闭无敌。
; noclip
: 开启/关闭穿墙飞行。