/// <summary> /// 体型レシピを読み込みます。 /// </summary> /// <param name="source_file">ファイル名</param> /// <returns>体型レシピ</returns> public static TPOConfig Load(string source_file) { XmlReader reader = XmlReader.Create(source_file); XmlSerializer serializer = new XmlSerializer(typeof(TPOConfig)); TPOConfig config = serializer.Deserialize(reader) as TPOConfig; reader.Close(); return(config); }
/// <summary> /// フィギュアを生成します。 /// </summary> public Figure() { tmo = new TMOFile(); nodemap = new Dictionary <TSONode, TMONode>(); matrixStack = new MatrixStack(); tpo_list.SetProportionList(ProportionList); string config_file = GetTPOConfigPath(); if (File.Exists(config_file)) { TPOConfig config = TPOConfig.Load(config_file); tpo_list.SetRatiosFromConfig(config); } }
/// <summary> /// フィギュアを生成します。 /// </summary> public Figure() { tmo = new TMOFile(); nodemap = new Dictionary <TSONode, TMONode>(); matrixStack = new MatrixStack(); tpo_list.Load(); string config_file = GetTPOConfigPath(); if (File.Exists(config_file)) { TPOConfig config = TPOConfig.Load(config_file); tpo_list.SetRatiosFromConfig(config); } LightDirection = new Vector3(0.0f, 0.0f, -1.0f); }
/// <summary> /// 体型レシピから変形比率を設定します。 /// </summary> /// <param name="config">体型レシピ</param> public void SetRatiosFromConfig(TPOConfig config) { Dictionary <string, Proportion> proportion_map = new Dictionary <string, Proportion>(); foreach (Proportion proportion in config.Proportions) { proportion_map[proportion.ClassName] = proportion; } foreach (TPOFile tpo in files) { Debug.Assert(tpo.Proportion != null, "tpo.Proportion should not be null"); Proportion proportion; if (proportion_map.TryGetValue(tpo.ProportionName, out proportion)) { tpo.Ratio = proportion.Ratio; } } }
/// <summary> /// 体型レシピから変形比率を設定します。 /// </summary> /// <param name="config">体型レシピ</param> public void SetRatiosFromConfig(TPOConfig config) { Dictionary<string, Proportion> proportion_map = new Dictionary<string, Proportion>(); foreach (Proportion proportion in config.Proportions) proportion_map[proportion.ClassName] = proportion; foreach (TPOFile tpo in files) { Debug.Assert(tpo.Proportion != null, "tpo.Proportion should not be null"); Proportion proportion; if (proportion_map.TryGetValue(tpo.ProportionName, out proportion)) tpo.Ratio = proportion.Ratio; } }