Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement BlendShape of MAYA in Unity3d

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to implement the BlendShape of MAYA in Unity3d, aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Next, we will describe in detail the specific export settings and how to control them after import. First of all, popular science under BlendShape (only for people who have come into contact with 3D animation, if you are very familiar with, please skip it directly). Originally wanted to find a relatively official explanation on Baidu, but found that du Niang was not willing to tell, but had no choice but to go to the foreigner to search for some information. Sure enough, the emperor lived up to his heart, and I really found it. However, it is necessary to embarrass those friends who are not very good at English, because the original text is in English, Ben Xiaobai has been a little busy recently, and a translation will be presented to you later. BlendShape related materials. Generally speaking, BlendShape is a special way to deform objects. It is often used to do facial expression animation in the field of 3D animation. Of course, it can also be used to do some unconventional animation effects.

First open MAYA and create a CUBE (here the model is relatively simple, just use CUBE and simply adjust the position of the point, mainly to illustrate the principles and steps. This Xiaobai believes that all the great viewing artists will be able to produce much better results than this Xiaobai. CRTL+D (copy) a copy and adjust the vertices of the copy. The screenshot is as follows.

Then first select the Deformable object, and then select the Base object (the order here is very important, be sure to select the deformation object first, select the basic object, otherwise the deformation effect created later will also be reversed) Click the menu bar Create Deformers > BlendShape (if you do not have this menu, please switch to the Animation module and try again), this step screenshot is as follows.

After the creation is successful, select the basic object (that is, non-deformable object) and execute File > ExportSelection Select FBX format. There are several points to be explained about the options: 1) activate the Animation option; 2) activate the Deformed Models; under it 3) continue to look at the activation Deformed Models and its under the Skins and Blenshapes, and finally select Export. Details of the settings are shown in the following figure.

Then switch to U3D, create a new project, and import the FBX file we exported from MAYA. Select the model to set the appropriate ScaleFactor in ImportSettings, and the remaining options can be temporarily left by default or adjusted according to your needs. Ben Xiaobai is lazy, so he keeps it by default. And then the key came. Drag the imported model from Projec to Hierachy, and you can see that in the Skinned Mesh Renderer component of Inspector (Xiaobai doesn't quite understand why it is called Skinned Mesh Renderer here, it is clear that the model does not contain Bone. Will U3D treat all non-Transform animations as Skinned Mesh? But we don't worry about these things), there will be a default attribute under BlendShapes. This rookie is called "blendShape1.pCube2", which is the default attribute name of U3D. Ben Xiaobai is lazy here again, so he hasn't changed it. I hope you will forgive me. You can now adjust this property to see the effect of BlendShape in Viewport. For the OK who have a relatively weak foundation, you can see it here. For those who have a strong thirst for knowledge, please go on to read on. With the above steps, we can control the BlendShape through properties. So the question is, can we change it dynamically while the game is running? The answer must be in the affirmative, otherwise you will be playing rookies. Xiaobai can think of two ideas: 1) through the combination of Keyframe animation and animation state machine to control BlendShape. (it seems enough for a non-programmer like Xiaobai, but as a high-end place like CSDN, there is only interface operation and no program does not seem to be so high-end, so go on and study the script); 2) use script dynamic control. As the rookie uses JS, I would like to ask you to make up for it by yourself. The script is as follows (excuse me for not figuring out how to add a script for the first time in such a high-end place as CSDN).

Using UnityEngine; using System.Collections; public class BlendShape: MonoBehaviour {/ / here to control the speed of convergence public float blendSpeed = 1; / / define BlendShape-related components private SkinnedMeshRenderer skinMesh; private Mesh mesh; void Awake () {/ / get BlendShape-related components skinMesh = GetComponent (); mesh = skinMesh.sharedMesh / / Debug.Log (skinMesh.GetBlendShapeWeight (0)); / / Debug.Log (mesh.blendShapeCount);} void Update () {/ / gradient if of BlendShape weights through a simple Lerp function (skinMesh.GetBlendShapeWeight (0))

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report