Blender tutorial:zh-cn

From Valve Developer Community
< SteamVR‎ | Environments
Revision as of 17:26, 11 July 2021 by Wtrace3zh (talk | contribs) (Created page with "{{Note|本教程以 Blender 2.79b 版本为蓝本制作. 也适用于 Blender 2.8 或更高的正式版本.}} == 简介 == 本教程解释了如何将一个模型从 Blender...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Note.png Note: 本教程以 Blender 2.79b 版本为蓝本制作. 也适用于 Blender 2.8 或更高的正式版本.


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

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


Units setup

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

Blender units setup.png

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


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

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

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

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

Blender suzanne size.png

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

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.png

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.

Blender new material.png

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.

Blender add material.png

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.

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.

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.

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.

Note.png 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.

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.


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.