Morphing Mesh in M3G
M3G Specification中已有了详细的说明,根据权值对Mesh做简单的变形:
Denoting the base mesh with B, the morph targets with Ti, and the weights corresponding to the morph targets with wi,
the resultant mesh R is computed as follows:
- R = B + sum [ wi (Ti - B) ]
我们只要做简单的变化,
R = B + sum[ wi (Ti - B)]
= B + sum(wi * Ti ) - sum(wi * B)
= [1 - sum(wi )] * B + sum(wi * Ti )
这样就容易理解,根据上式也很容易编码。
==============
Kemulator中,是在每次渲染前,根据上式计算出对应的Mesh,如果顶点数比较多,则需要消耗一定的计算时间。
假如遇到有的手机对Morphing Mesh渲染比较慢,就可以考虑自己封装一个Morphing的实现,
当Mesh需要改变时才计算新的mesh,渲染时就不需要额外的计算了。