Zh/Source 2/Docs/Modeling/Exporting a mesh from Blender: Difference between revisions

From Valve Developer Community
< Zh‎ | Source 2‎ | Docs‎ | Modeling
Jump to navigation Jump to search
Line 37: Line 37:
[[File:Blender shading smooth.png]]
[[File:Blender shading smooth.png]]


== Material setup ==
== 材质建立 ==
=== Adding two materials ===
=== 加入两种不同的材质 ===
First, switch your renderer to Cycles in Blender’s header. This is not needed to create materials - however, as the Blender Renderer will be discontinued in the future and has been removed from Blender 2.8 you should switch it to Cycles, so you can continue working on old props seamlessly when updating to the new Blender version.
首先,将渲染器切换到 Blender 内置中的 Cycles。这不是创建材质所必需的 - 但是,由于 Blender Renderer 已从 Blender 2.8 中删除,您应该将其切换到 Cycles,以便您在更新到新的 Blender 版本时可以继续无缝地处理旧道具.
 
 




Line 45: Line 47:




We will create two different materials, a red and a blue one. Navigate to the Material tab in the Properties and click on New to create a new material.
我们将创建两种不同的材质,一种红色和一种蓝色。导航到“属性”中的“材料”选项卡,然后单击“新建”以创建新材料。
 




Line 51: Line 54:




Click on the + icon to create a new empty material slot. Select this slot and press the big new button again to create a second material. Rename the materials to red and blue.
单击 + 图标创建一个新的空材质槽。选择此插槽并再次按下新的大按钮以创建第二个材质。将材质重命名为红色和蓝色。
 




Line 57: Line 61:




The material name you enter here is not relevant or tied to the material name used by Hammer. But for the sake of consistency it is advised to use the same material name as in the engine.
您在此处输入的材质名称与 Hammer 使用的材质名称无关或关联。但为了保持一致性,建议使用与引擎中相同的材料名称。
 


=== Material properties ===
=== Material properties ===
Hammer can’t read the materials unless you add a so called Custom Property to them that points to the correct material name and path used in Hammer.
Hammer 无法读取材料,除非您向它们添加一个所谓的自定义属性,该属性指向 Hammer 中使用的正确材料名称和路径。


Select the red material. For this tutorial we’re going to assume that you have created a material called red.vmt in the folder “materials/models/props_items” of your project with Hammer’s material editor. If you didn't, thats fine too. You can create the materials after finishing this tutorial. There's a link in this article's conclusion that will help you to do so.
选择红色材质。对于本教程,我们将假设您已使用 Hammer 的材质编辑器在项目的“materials/models/props_items”文件夹中创建了一个名为 red.vmt 的材质。如果你没有,那也很好。完成本教程后,您可以创建材料。本文的结论中有一个链接可以帮助您这样做。


There’s a Custom Properties category in the material menu. If you can’t see the big Add button in it, click the Custom Properties text to expand it. Make sure your red material is selected and click the Add button. A new property with the Property Name prop and Property Value of 1 will be created. Click the Edit button and change the name to FBX_vmatPath and the value to materials/models/props_items/red.
材料菜单中有一个自定义属性类别。如果您看不到其中的大添加按钮,请单击自定义属性文本以将其展开。确保选择了红色材质,然后单击“添加”按钮。将创建一个属性名称属性和属性值为 1 的新属性。单击“编辑”按钮并将名称更改为 FBX_vmatPath,将值更改为 materials/models/props_items/red。


{{Note|Make sure to spell FBX_vmatPath with the right capitalizations. This property is case sensitive and does not export correctly if the capitalizations are wrong.}}
{{Note|确保使用正确的大小写拼写 FBX_vmatPath。此属性区分大小写,如果大小写错误,则无法正确导出。.}}




Line 80: Line 85:


[[File:Blender material color.png]]
[[File:Blender material color.png]]


== Mesh export ==
== Mesh export ==

Revision as of 17:29, 11 July 2021

Note.png注意:本教程以 Blender 2.79b 版本为蓝本制作. 也适用于 Blender 2.8 或更高的正式版本.

简介

本教程解释了如何将一个模型从 Blender 导出到 Source 2。虽然 懂得 blender 基础操作对理解此文章很有帮助,但如果你是新手遵循教程指引也能轻松完成导入工作。您将学习如何为您的模型设置正确的缩放比例、如何以 Hammer 可读的方式分配材质以及导出时使用的设置。

如果你的电脑上没有Blender这款软件, 你可以在 (icon) blender.org/download 官方网站上免费下载.

Blender是一款开源,免费的建模软件,您可以在Steam或官方网站上获取或对源码进行自编译后使用

单位设置

在开始处理网格之前,请确保正确设置 Blender 的场景选项中参数正确无误。为此,请切换到“属性”菜单中的“场景”选项卡,然后选择“英寸”预设或将长度设置为“无”。


Blender units setup.png


Note.png注意:只要某物大于 12 英寸,Blender 2.79b 就会将英寸转换为英尺。这使得在 Blender 和 Hammer 之间比较对象的大小有点困难。这种行为在 Blender 2.8 中发生了变化,无论对象的大小如何,单位都以英寸为单位。由于这个问题,使用通用单位更容易。.

网格比例和方向

我们将使用默认的 Suzanne 猴头作为本教程的示例道具。按 Shift+A → Mesh → Monkey 将其添加到您的场景中。您可以通过按 N 打开 3D 视口的右侧菜单并查看“变换”类别中的尺寸来检查尺寸。在本教程中,我们将放大 Suzanne,直到 Z 尺寸大约为 6.5 英尺或 78 英寸/通用单位。为此,请按 S 并将光标从猴头上移开以将其放大。用鼠标左键确认。

Note.png注意:缩放量与鼠标光标和对象之间的距离有关。当您按 S 时,光标离对象越近,比例因子就越高。如果在缩放猴子头时遇到问题,请在按 S 之前将鼠标光标移得更远。.

通过按 Ctrl+A → 旋转和缩放来应用网格的缩放。养成在将网格导出到 Hammer 之前始终应用缩放和旋转的习惯。

你的网格应该在 Blender 中朝南,以便与 Hammer 的坐标正确对齐,猴子头默认这样做。


Blender suzanne size.png


使用 T 打开 3D 视口的左侧菜单,然后单击“平滑”将 Suzanne 更改为平滑着色。

Blender shading smooth.png

材质建立

加入两种不同的材质

首先,将渲染器切换到 Blender 内置中的 Cycles。这不是创建材质所必需的 - 但是,由于 Blender Renderer 已从 Blender 2.8 中删除,您应该将其切换到 Cycles,以便您在更新到新的 Blender 版本时可以继续无缝地处理旧道具.



Blender cycles.png


我们将创建两种不同的材质,一种红色和一种蓝色。导航到“属性”中的“材料”选项卡,然后单击“新建”以创建新材料。


Blender new material.png


单击 + 图标创建一个新的空材质槽。选择此插槽并再次按下新的大按钮以创建第二个材质。将材质重命名为红色和蓝色。


Blender add material.png


您在此处输入的材质名称与 Hammer 使用的材质名称无关或关联。但为了保持一致性,建议使用与引擎中相同的材料名称。


Material properties

Hammer 无法读取材料,除非您向它们添加一个所谓的自定义属性,该属性指向 Hammer 中使用的正确材料名称和路径。

选择红色材质。对于本教程,我们将假设您已使用 Hammer 的材质编辑器在项目的“materials/models/props_items”文件夹中创建了一个名为 red.vmt 的材质。如果你没有,那也很好。完成本教程后,您可以创建材料。本文的结论中有一个链接可以帮助您这样做。

材料菜单中有一个自定义属性类别。如果您看不到其中的大添加按钮,请单击自定义属性文本以将其展开。确保选择了红色材质,然后单击“添加”按钮。将创建一个属性名称属性和属性值为 1 的新属性。单击“编辑”按钮并将名称更改为 FBX_vmatPath,将值更改为 materials/models/props_items/red。

Note.png注意:确保使用正确的大小写拼写 FBX_vmatPath。此属性区分大小写,如果大小写错误,则无法正确导出。.


Blender material custom properties.png


Repeat the same steps for the blue material, but change the value to materials/models/props_items/blue.

Assigning materials

Choose a Viewport Color in the Settings category of both materials. Switch to Edit Mode by pressing Tab and assign the two materials to different faces by using the Assign button in the material editor.


Blender material color.png

Mesh export

Click on File → Export → FBX to export you mesh as FBX. For this tutorial we’ll assume that you project has a models\props_items\fbx\ folder.


Blender fbx export.png


Selected Objects Tick this box if your scene contains more than one prop. Make sure to select the right prop before opening the export dialogue.
Apply Scalings Choose FBX All.
Forward / Up This does not seem to affect the mesh’s orientation in Hammer. For the sake of consistency with Hammer’s coordination system it’s set to X Forward and Z Up.
Custom Properties Make sure to tick this box or your materials will not be recognized in Hammer.

You can safely ignore the tabs Geometries, Armatures and Animation for regular props. Enter a prop name in the upper toolbar and click on Export FBX in the upper right to export your mesh.

If you'd like to save your settings as a preset, click on the + button to the right side of the Operator Presets list and enter a name. You can select the new preset by clicking on the Operator Presets button. Remember to always select the preset before exporting in a new Blender session, as the selected preset is reset when Blender is closed.

Conclusion

With your FBX exported to the right folder you're ready to import your prop into Hammer. Check out the Model Editor tutorial to find out how. If you need help creating your materials, the material creation tutorials will help you getting started.