예제 #1
0
        //============================================================
        public void UnserializeWeight(IInput input)
        {
            // 读取顶点坐标
            int boneCount = input.ReadInt32();

            for (int n = 0; n < boneCount; n++)
            {
                FDrVertexWeight weight = new FDrVertexWeight();
                weight.Unserialize(input);
                _weights.Push(weight);
            }
            // 排序权重内容
            if (!_weights.IsEmpty)
            {
                _weights.Sort(FDrVertexWeight.Comparer);
                if (_weights.Count > _maxWeightCount)
                {
                    float total = 0;
                    for (int n = 0; n < _maxWeightCount; n++)
                    {
                        total += _weights[n].Weight;
                    }
                    for (int n = 0; n < _maxWeightCount; n++)
                    {
                        FDrVertexWeight weight = _weights[n];
                        weight.Weight = weight.Weight / total;
                    }
                }
            }
        }
예제 #2
0
 //============================================================
 // <T>加载配置信息。</T>
 //
 // @param config 配置信息
 //============================================================
 public void LoadWeightConfig(FXmlNode config)
 {
     // 读取权重信息
     foreach (FXmlNode node in config.Nodes)
     {
         if (node.IsName("Bone"))
         {
             FDrVertexWeight weight = new FDrVertexWeight();
             weight.LoadConfig(node);
             _weights.Push(weight);
         }
     }
     // 排序权重内容
     if (!_weights.IsEmpty)
     {
         _weights.Sort(FDrVertexWeight.Comparer);
         if (_weights.Count > _maxWeightCount)
         {
             float total = 0;
             for (int n = 0; n < _maxWeightCount; n++)
             {
                 total += _weights[n].Weight;
             }
             for (int n = 0; n < _maxWeightCount; n++)
             {
                 FDrVertexWeight weight = _weights[n];
                 weight.Weight = weight.Weight / total;
             }
         }
     }
 }