【Unity 优化】Skinned-Mesh 能动态合并嘛？

919人阅读 评论(0)

===================2017.9.16
I’v tryed to combine the skinned meshes today.
I can combine all the skinned meshes to one now.And they looks like at the right position and with the right uvs. However , It’s just a static mesh,it can not do any animation.I checked the API of Unity, I found that ,mybe it is not possible to combine all meshes with animation. The reseaon is here:
- Every mesh has huge vertices and boneWeights , one boneWeight per one vertex.The boneWeight contains up to 4 indexes and weights relative to the bindPose list.
- The bindPose list is a array of Matrixes , every Matrix means a trasformation relative to the skinned-mesh’s rootBone.
- The boneWeights are just used as weight-calculation of up to 4 bindPose matrixes , the result is one average matrix relative to the skinned-mesh’s rootBone.
At last , we can think out the calculation process of the vertex’s position.
vertex world transformation <= weight-calculated matrix to the rootBone <= rootBone’s transformation is animated by the animation
This is the relation process. Then, for example, one animation contains 5 bones, and 7 skinned-meshes , the 7 skinned-meshes are relative to diffrent bones, even we’ve combined the meshes ,we just got the static mesh, one mesh can’t rely on 5 rootBones, so it lost the animation feature.
So, I think maybe it is the result: we only can get the static mesh , with no animation.

===================2017.9.17
I’m glad to tell you that the baking does work now.And all problems are resolved.
I think there are 4 key points:
1、The rootBone is not important ,even maybe it is not need.
2、All mesh points all calculated relative to the bones,and when using the Unity’s Combination,it combine all the bones together to a new big bones set.
So, every thing is ok,bones are still work.
3、We juse need to collect all the bones in original skinned-meshes,and give the array of bones to the new created Skinned-Mesh(set the bones).
4、Before do out combination, we need to set all skinned-meshes to standard state (with no scal,tranlate or rotate), and move the animation node to world center, with no scal and rotation, then do the combination,when finished,we can take the animation node back to old state.
That’s it. I think it works now. I will update my plug-in tomorrow.

0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：87007次
• 积分：1277
• 等级：
• 排名：千里之外
• 原创：24篇
• 转载：1篇
• 译文：1篇
• 评论：43条
关于Andrew
Unity游戏开发程序员，
开源游戏引擎Cyclone2D作者，
我最近在开发一款3D赛车游戏
热爱图形学、物理学、架构等研究，
有兴趣的同学加群：528266922。
博客专栏
 Unity3D游戏编程 文章：19篇 阅读：55607
阅读排行
最新评论