使用Blender创建Unity中的可复用角色

本文为摘录笔记,原文

之前已经做过摘录笔记Blender骨骼快速入门
所以关于一些基础操作就不再摘录,只做Unity中可复用角色相关需求,以及Blender对应快捷键,以及个人遇到的一些问题。

Rigging the Character

to be compatible with Unity’s Humanoid Avatar, some key bones are necessary:


UnityAvatar

Unity expects a minimum of 15 bones, which are:

  • Hips (root bone)
  • Lower spine
  • Upper spine
  • Neck
  • Head
  • Two upper arms
  • Two lower arms
  • Two hands
  • Two upper legs
  • Two lower legs

骨骼我们也只要建立一侧,建好后,选中一侧的骨骼, 接着press W and select Symmetrize.


Select Side Bones

Symmetrize

最终得到:


Final Bones

Weight Painting

进入ObjectMode,先选中模型,再选中骨骼。(顺序很重要,虽都是选中,最后一个选中的为ActiveObject)。
Now press CTRL + P to open the Parent menu and choose With Automatic Weights to parent the model to the armature and perform automatic weight painting.
!(Automatic Weights Menu)[https://koenig-media.raywenderlich.com/uploads/2018/08/AutoWeights.png]

自动绑定处理的也不错,但也有一些细节问题,比如:眼睛没绑上.


Automatic Weights Preview

Eye not bind by Automatic Weights

自己绑定眼睛吧,选中模型进入WeightPainting Mode,

在这之前,务必先选择骨骼(Armature),使其进入Pose Mode。(不同类型的对象有不同的模式,骨骼就没WeightPainting Mode, 模型也没有Pose Mode)
如果不这么做的话,后续进入WeightPainting模式后,CTRL+RMB是无法选中骨骼的!

增加或减少Weight是通过Brush进行的,


SelectAddBrush

这里教程的方法很巧妙,先把头部旋转,眼睛没有跟上。用笔刷增加权重后,眼睛就会跟上去了。
然后重置头部的旋转
press Alt (or Option) + R to reset the rotation of the Head bone.(位移,缩放也都是类似的操作,Option(Alt) + G, Option(Alt) + S)

按过R后再按一次,会进入trackball模式。

Note: The rotation above was done using trackball rotation. You can activate this rotation mode by pressing R again after you’ve started to rotate.


HeadMoveOrbital

Adding Accessories

文章中描述了两种不同的Accessories

  • 做到Model中的帽子
  • 独立的模型,挂在骨骼上的棍子

添加帽子

这里就是正常的编辑模型。记录一些文章中用到的快捷键。

EditMode中,CTRL + Tab 唤出Mesh Select Mode的PopupMenu

Press CTRL + L to select all connected vertices。
此时,左边Tools面板会出现Delimit
Now select the UV delimiter by selecting UVs in the bottom left panel.


UV delimiter

Select the edge loop underneath as well by holding Shift and Alt (or Option) and then right-clicking on any of the first horizontal edges below.


SelectEdgeLoop

Now duplicate the selected faces by pressing Shift + D and then pressing Enter.


duplicate selected

holding Alt (or Option) and right-clicking on one of the bottom edges.
这会选中一圈Edges


Select Circle Edges

感到最神奇的是这,设置Z轴上Scale为0,居然可以拉直。。。就好像Sin函数有几何意义一样。。。
Make it straight by press S, Z and 0 in that order.

这里CTRL + L好像没有什么效果啊,并不是全部选中啊。。。手册也看不懂啥意思。
Select the entire hat by selecting any vertex on the hat and then pressing CTRL + L. Change the delimiter to Normal this time to select all of the connected vertices.

Manual:L (or Ctrl-L for all) will add to the selection the cursor’s nearest control point, and all the linked ones, i.e. all points belonging to the same curve. Note that for Bézier, using L with a handle selected will select the whole control point and all the linked ones.

For this hat, you’ll perform one of the easiest unwraps in existence: from the view. Press numpad 1 to get a front view, then press U to open the Unwrap menu and select Project From View.


ProjectFromView

Project From View的结果看看还是挺有意思的。


ProjectFromView UVResult

添加棍子

先建立一个独立的模型吧。
Get into Object mode and press Shift + A to open the Add menu. Select Mesh > Cylinder to add a new cylinder to the scene.


AddCylinder

文中给的设置


AddCylinderOptions

Make the cylinder smooth by pressing the Smooth button in the Shading section in the Tool Shelf on the left.
这个选项不是出现在创建上下文Menu中的,就是Tools里的。之后也可以修改。

image

给棍子材质,选中棍子的状态下,open the Material tab in the Properties panel on the right and select CuteMaterial from the drop-down next to the New button.


SelectCuteMat

To turn the cylinder into a brown staff, you’ll need to unwrap its UVs first. Press Tab to enter Edit mode, press U to open the Unwrap menu and select Project From View.


StaffUVs

不要担心当前这个尴尬的位置,我们下面就会进行处理它/simle


BrownStaff

Open the Constraints tab in the Properties panel. Add a new constraint by clicking the Add Object Constraint drop-down and selecting Child Of.


image

Setting up the constraint is straightforward. Click the Target drop-down and select Armature. Now click the Vertex Group drop-down and select Hand.R.


ChildOfConfig

接下来就是把棍子摆到合适的位置,文中给出的配置:
R, X, 90
G, Y, -0.4


PositionStaff

Pose模式晃晃看:


MovingStaffAround

其实这个时候可以设置下棍子的原点,使其和骨骼的连接点作为原点。旋转不会破坏。
手持点为原点,棍尖向上。

导出

导出格式选择FBX

These default export settings will work with Unity, but there’s a chance they might make a mess in more complex scenes as it will export everything, even lamps and cameras. To make a clean export, make the following changes:
Deselect Camera, Lamp and Other. You can do this by holding down Shift and clicking the options you want to disable.


DeselectOptions

With just these options selected, you won’t get any undesired objects exported. Now check the !EXPERIMENTAL! Apply Transform checkbox right below the options you deselected. This applies the position, rotation and scale of all objects. That means any non-uniform values will be reset; if the rotation was set to (X:23, Y:125, Z:7), for example, it will be set to (X:0, Y:0, Z:0).
这个应该是针对于整体的Object。。。


ApplyTransform

Switch to the Geometries tab by clicking the Geometries button, and uncheck the Use Modifiers Render Setting checkbox. This allows you to keep a high poly count for renders inside Blender, but keep it low for use inside of Unity.
不明白什么意思,导出后不使用Modifiers,应该会导致导出的面数多吧?


SelectGeometries

Next, open the Armatures tab, check Only Deform Bones and uncheck Add Leaf Bones. This prevents Blender from adding extra bones to the armature. Leaf bones are only needed for compatibility with Maya. Non-deform bones like control bones are only needed in the modeling software to make precise adjustments; they’re useless in a game engine like Unity.


SelectArmature

The default Animation options are fine, so you don’t need to tinker with those.

保存这个导出配置
To do this, click the + button next to the Operator Presets drop-down, type a name for the preset in the textbox and click the OK button. For the sake of this tutorial feel free to name it Unity FBX.


SavePreset

关于导出选项中的Forward和Up,感觉指的是在导出的使用场景中,哪个轴是Foward哪个轴是Up。
总之保持-Z Forward,Y Up
在Blender中编辑时,Front视图就是从前往后看,Right视图就是从右往左看。

Avatar Mapping

HumanoidSelect

ConfigureButton

The way Unity uses these bones is by acting like a puppeteer. Instead of straight up using animation files to update the bones every frame, it reads the values and applies those to every humanoid based on their Avatar definition. This allows for flexibility when it comes to body shapes. Take the character you’ve been working on, for instance; its proportions are not realistic, but that doesn’t matter as its skeleton is also adjusted to fit while still having the essential bones like a spine, arms, legs, etc. Some of the bones may be shorter than in most humans, but they’re there.

Muscles&Settings
Muscles 肌肉

You’ll now see three sections:

  • Muscle Group Preview
  • Per-Muscle Settings
  • Additional Settings

The first one has several sliders you can move from left to right to test if the muscles are mapped correctly. Try them out and see what they do. Note that the finger ones won’t have any effect since the character doesn’t have any fingers. Press the Reset All button after every test to reset all preview sliders.


MusclePreviews

使用MusclePreviews可以进行测试,看看会不会出现动画穿透。因为动画时共用的。这里可以对高矮胖瘦不同的模型进行各个部位的转角进行限制,从而避免模型作动画时出现的穿透情况。
The Per-Muscle Settings section contains sub-sections that can be unfolded by clicking the arrow next to them. Every one of these has some more specific previews and allows you to specify the minimum and maximum angles to prevent overlapping for your specific model.


SpecificMuscle

Expand the Left Arm section and try sliding around the Arm Down-Up slider. Notice what happens with the minimum value selected:


ArmIntoBody

The arm is moving through the character’s body. Ouch!

To fix this, set the preview slider to its lowest value and change the minimum angle of Arm Down-Up to -20.


MinArmUpDown

Do the same for Right Arm > Arm Down-Up.


RightDownUp

That concludes the tweaking of the muscles. There are more muscles you can tweak to prevent overlapping, but for the sake of this tutorial leave it at the arms up and down movement.

Press the Apply button at the bottom-right to save the changes to the Avatar and press Done to close the mapping mode.


ApplyDone

如何在Unity3D中进行播放就不记录了,相关文档非常多。

后记

发现一个问题,模型的朝向和缩放都是正常的。
不过Armature(骨骼)的缩放和旋转不是identity。
缩放xyz均为100,旋转x=-90

解决xyz为100的方法:
导出时main tab中 Apply Scalings: 改为FBX All。

旋转没找到什么方法解决。
如果武器需要挂接到骨骼上,可以设置rotation x=90

有遇到一种情况,同事在3DMax中做好的模型动作,放入Unity3D中动作和建模软件中不一样,会有一定倾斜角度。查看动作模型导入选项Rig中的的Avatar,其T-Pose有倾斜,看了下根节点,旋转角度调整下就可以了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,732评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,496评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,264评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,807评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,806评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,675评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,029评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,683评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,704评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,666评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,773评论 1 332
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,413评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,016评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,978评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,204评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,083评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,503评论 2 343

推荐阅读更多精彩内容