[Reproduced] Introduction to the relevant properties of the FBX model imported into Unity3D

This blog post is reproduced from: https://www.jianshu.com/p/e2aa4d898fb7

The blogger originally wanted to write it by himself, but there are unusual details in uppercase, so I will reprint it for learning records.


Model (Mesh)

The use of 3D models in Unity3D mainly relies on Mesh Filtercomponents to load polygonal surface objects (polygon mesh), and then relies on Mesh Renderercomponents to correctly render the Mesh.

Built-in basic 3D model

Unity3D has some basic geometry built-in, which can be created Hierarchyby Createbuttons on the panel or menu selection GameObject > 3D Object:

Name Model
Cube Cube: 1×1 cube
Sphere Sphere
Capsule pill
Cylinder cylinder
Plane Plane: 10×10 plane
Quad Single side: 1×1 single side

These built-in basic geometry is actually the mesh that comes with the engine. It is equivalent to creating a Cube or Plane model externally and then importing it into Unity for use. This is fundamentally different from our use of preset geometry in Maya. The basic geometry of Unity3D does not have any adjustment parameter options.

Import ordinary 3D models into Unity3D

Since the basic geometry is very simple, Unity3D itself does not provide polygon editing tools for us to use (but you can use the
ProBuilder Advance plug-in to do some polygon editing work), so in many cases we need other 3D software to make the model, and then import it to In Unity3D.

Although U3D now supports direct import of Maya .mafiles, it is recommended that you first clean up the model and export it into a .fbxformat, and then import it into U3D, which is easier to manage.

Not all Maya nodes can be imported into Unity3D correctly. In fact, Unity3D only supports the import of Polygon Mesh, Joints, empty nodes, skin information, cameras, and key frame animations, while the commonly used NURBS surface and Curve in Maya Contents such as curves, deformers, IK, and Constraints are not supported.

And, I also suggest that you .fbx“clean up” the Maya file before exporting , check the discovery direction of the model, bake the key frame animation, delete the unnecessary nodes, delete the useless construction history, and put the model in The center position of the coordinate origin, freeze the Transform property (return to zero).

Unity3D can recognize multiple meshes in a single model file, and the Mesh Filter component only supports loading a single mesh, so we can use one file to export all the meshes needed by the game, and then call them one by one in U3D.

Therefore, when making model materials for Unity3D, it is not a good choice to build all the models in the 3D software. Because the recurring model in the 3D software will be recognized as a different mesh after being imported into U3D, loading the entire scene directly will waste a lot of system resources. A more effective production process is to make different "small objects" in 3D software, and then complete the construction of specific scenes in Unity3D.

PS: Terrain, vegetation and other models may be more suitable to be created by using Unity3D's own functional modules!

Setting parameters for model import

Select the corresponding model Asset, and its import parameters will be displayed in the Inspector panel.

The Model column is about the import parameters of the model, the Rig column is about the import parameters of the binding settings, and the Animation column is about the import parameters of the animation data.

unity_model_import_02.png

This model material comes from: "Unity-chan" Model 1.1

  • Scale Factor: Import size scaling (calculated according to actual length)
  • Use File ScaleWhether to retain the zoom properties of the model itself
  • Mesh Compression: The degree of mesh data compression will reduce the number of polygons of the mesh to a certain extent
  • Read/Write Enabled:Whether to directly modify this document
  • Optimize Mesh: Whether to streamline the number of sides of the mesh
  • Import BlendShapes: Whether to import BlendShapes
  • Generate Colliders: Whether to automatically create a collision body
  • Keep Quads: Whether to keep all four sides (not automatically converted to triangles)
  • Weld Vertices: Whether to automatically merge the coincident vertices
  • Swap UVs: Exchange UV groups (usually there are multiple sets of UV groups in the model, and check if the texture is not correct after importing)
  • Generate Lightmap UVs: Whether to automatically create a UV group for lighting baking
  • Normals: How to deal with the normal direction (Import represents the original normal data of the imported model, Calculate represents the Smoothing Angleautomatic smooth calculation with the following parameters, and None represents the complete no smooth discovery setting)
  • Smoothing Angle:The edge of the angle above which degree will be automatically calculated as a smooth boundary
  • Tangents: Tangent calculation settings
  • Import Materials: Whether to import the model shader
  • Material Naming: What name to use to name the shader
  • Material Search: Shader search rules

Set up do not forget to click Applythe button to confirm Oh! ! !

About proportions

The size ratio is very important in Unity3D, because many Unity3D operations rely on physics calculations, and physical calculations will show very different results due to the different size ratios of objects. The behavior of a large rock 100 meters high and a small rock 1 cm high falling from the air to the ground is obviously very different.

The default distance of 1 unit = 1 meter in Unity3D.

Since the default setting in Maya is 1 unit distance = 1 cm, the Maya model is exported to .fbx and then imported into Unity3D. The scale must be set to 0.01, otherwise it will become super large.

Summarize the technical requirements of the imported model:

  • The normals must be correct: the normal direction of the polygon cannot be modified in Unity3D, so if it is wrong, you must return to Maya to modify and re-import;
  • The ratio should be correct: If the default value of 1 unit is 1 cm in Maya, the height of 1 meter in Maya should be 100 units, and it should be Scale Factorset to 0.01 when importing ;
  • Pivot Point should be set in advance;
  • The zero displacement position must be at the origin of the coordinate (but the initial position does not have to be at the origin);
  • There can be no construction history (the construction history will be automatically cleared when exporting FBX, so there should not be any changes that depend on the construction history);
  • UV are all placed in the (0,1) quadrant, and the UV positive direction is maintained (in Maya, it is displayed as blue as the positive direction);
  • Do not overlap the UV of a single mesh;
  • Only use smooth bind for binding;
  • Animation must all be controlled by animation curve keyframes;
  • The bone naming is best done in advance.

Binding (Rig)

The settings under the Rig column are relatively simple, the most important is the settings Animation Type:

  • Legacy: This method is old-fashioned, does not support Avatar, and calls animation through the Animation component
  • Generic: This method is more commonly used now, the call to the animation is mainly done through the Animator component
  • Humanoid: This method is similar Generic, it is also used with Animator, but specifically for humanoid skeletons, you can click the Configure...button to enter the detailed settings of the humanoid skeleton Avatar

The so-called Avatar, in my opinion, is a standardized description of bone structure to facilitate the free application of animation data between different models. For example, the Humanoid type of Avatar standardizes the key bones of humanoid creatures to specific names, so no matter what naming convention the animation data is based on, as long as the animation data fbx file and the target model fbx file are standardized to the humanoid Avatar, You can freely apply the animation data to the new model.

Sharp-eyed students should be able to find that this concept is very similar to HumanIK in Maya.

In the Mappingpanel shown in the picture below , we can manually specify the scene node corresponding to each key bone point, and even set the details of the head and fingers, which is very convenient:

unity_model_rig_avatar1.png

Muscles & SettingsI haven't used the panel much, so I will add it when I need it later.

The basic process of binding the model can be summarized as follows:

  • For very, very simple animated objects, you can choose Legacyhow to set them (but I still don’t recommend it)
  • For standard humanoid objects, the selection Humanoidmethod Avatar Definitioncan be direct Create From This Model, that is, create a new Avatar based on this model
    • If you are not satisfied with the automatically created Avatar, click to Configure...enter the Mappingpanel to set it yourself
    • If you have already set up the same Avatar, you can Avatar Definitionchoose among them Copy From Other Avatarto avoid duplication of work
  • For non-standard humanoid objects, the selection Genericmethod is the Avatar Definitionsame as above
    • GenericThe method also needs to specify one Root Node, that is, the "root" node. This node is the starting point of all animations. Usually you can specify the top joint of the bone chain, or the parent object node of the bone chain, etc.
  • **Click the Applybutton to confirm! ! !

Drag the set .fbxresources into the scene, the components of this game object will be displayed in the Inspector

You can see that a Animatorcomponent (animator) has been attached , and its Avatarparameters have been added, but the Controllerparameters are still empty. At this time, the model will not play animation in the scene.

If Legacythe Rig mode is selected before , the game object will be automatically attached to the Animationcomponent. The Animationparameters are also empty (because the fbx model itself is not animated!).

Beginners will mostly think "passionately", shouldn't the animation of the fbx model with animation be automatically played when it is imported into Unity3D? This is not the case. If it is Legacyimported and the model has its own animation, it may be automatically played, but the components Legacyand Animationcomponents have been gradually abandoned by everyone, and if used Animator, no Controlleranimation will be played without adding them .


Animation

The Unity-chan material and animation file used above are separate from the model file. If you select the model .fbxfile to open the Animationspanel, you will see a blank:

If you also use this resource, you can UnityChan > Animationsfind .fbxfiles with animation in the directory.

I choose a unitychan_WALK00_F.fbxfile for demonstration, click the small arrow on the right side of the .fbxfile, and the entire content of the file can be displayed . We can see that there are only some meshes that look like faces, an Avatar, and a WALK00_Ffile.

This .fbxfile actually only contains animation data. The reason why these meshes appear is because the animations on these meshes are not realized by bone binding, but blendshape or direct transform animation, so the animation data must be retained. The nodes, that is, these meshes.

And this WALK00_Ffile is the file where the animation data is stored (the file extension on the hard disk is .anim).

.fbxFiles with animation have content under the Animations panel.

unity_model_animation_2.png

  • Bake Animation: I have never used this option. It should mean baking IK animations into key frame animations, but it is not safe to do all the baking work in the 3D software.

  • Anim. Compression: Whether to streamline and compress the animation curve, of course you can choose Off.

  • Clips: Here you can cut the animation curve, click on the +number to add a fragment, and specify the Startframe and Endframe for this fragment . Each Clip corresponds to an animation file seen before. The default is to make the entire animation curve into a large Clip. That is WALK00_F. We can do all the required animations in one file, and then manually split them when importing. I personally recommend this approach.

    It should be noted that the clips file after manual division will actually appear on the hard disk. The animation file that you can see when you expand the fbx file is actually contained in the fbx file and cannot be found on the hard disk.

  • Loop Time:Whether the clip is played in loop by default

In fact, starting from setting the name of the clip, all subsequent settings are detailed parameters for a particular clip, so I won’t go into details here.

There are two Warningwarnings in this picture , indicating that this model actually has a little problem. I checked it and there should be a Spine bone a bit crooked, but it doesn't affect the overall situation, just ignore it.

In the preview box at the bottom, you can see that this way of exporting animation files separately is really not good. Because there is no physical model, all the animation files are not visible when previewing. Click play and you will see a white face. Dangling there.

The solution is to use the mouse to drag the model fbx file into this preview window, so that the original model is replaced, and you can see that the animation clip is played gracefully on the correct model.

Animator Controller

Let's make this model move.

unity_animation_1.png

If you use the old-fashioned Animation component, you only need to drag the clip of the animation clip to the Animationbar. This clip is equivalent to the "current animation clip" and will automatically start playing when the game object is loaded. If loop is set, then It will keep looping.
In Animationsone column, you can add as many clips as you like. These clips are "backup animation clips", which can be called for playback through scripts in the future.

The problem with the old Animation component is that the switching between animation clips in the game is very frequent and complicated. In this way, all animation switching must be implemented through scripts, which becomes a burden on the programmer. So of course, those programmers who write game engines have to find a way to give up this job to artists, so they developed the Animator system behind, and designed the switching logic of animation clips to "visualize".

unity_animator_1.png

The new Animator component needs to call one Controller, we can create a new one in Assets, let's name ACit for now.

Drag this ACto the Controllercolumn of the Animator component , and then double-click the ACfile to open the Animator panel.

This panel is now empty with three buttons-like things, we can drag these "buttons" to lay out at will.

unity_animator_controller_1.png

Drag the animation file onto this panel, you can see that the animation clip becomes a larger orange strip, and then Entryan arrow extends from the strip to point to the newly added clip strip.

unity_animator_controller_2.png

unity_animator_controller_3.png

In fact, the Animator Controller is a "state machine" (for an explanation of the state machine, see here ), and the Animator panel "visualizes" the design of this state machine. PlayMaker, which we will learn later, is also a state machine-based interactive design plug-in.

These different colored "bars" represent different "states", and the "arrows" represent states that can change from one end to the other. So the above picture can be explained like this: when the object "enters" the scene, the object animation state becomes WALK00_F, which means "once loaded, the model will play WALK00_Fanimation".

Click WALK00_F, and we can see the WALK00_Fcontent displayed in the Inspector panel that is different from when you click the animation clip file in the Project panel :

unity_animator_controller_4.png

Here we can set which animation segment to play in this "animation state" ( Motion), what speed ( Speed) to play, whether to reverse the animation ( Mirror) and so on.

When you click the WALK00_Fanimation clip file in the Project panel, the content displayed in the Inspector panel is like this:

It is grayed out because I clicked on fbxthe clip contained in the file, so it is not editable. We can Ctrl+Dcopy it into a separate clip file and then modify it.

 

Guess you like

Origin blog.csdn.net/Mr_Sun88/article/details/91356840