private float search_best_value(string m_name, float wished_measure, HumanModifier human_modifier, string prop) { this.character_data[prop] = 0.5f; this.combine_morphings(human_modifier, false, true); //float measure2 = this.calculate_measures(null, m_name); float measure2 = this.calc_measure_float(m_name, null); string delta_name = human_modifier.name + prop; KeyValuePair <string, float[]> kvp = Utils.GetValueFromList(this.delta_measures, delta_name); float delta1 = kvp.Value[0]; float delta3 = kvp.Value[1]; float measure1 = measure2 + delta1; float measure3 = measure2 + delta3; float xa; float xb; float ya; float yb; float value; if (wished_measure < measure2) { xa = 0f; xb = 0.5f; ya = measure1; yb = measure2; } else { xa = 0.5f; xb = 1f; ya = measure2; yb = measure3; } if (ya - yb != 0) { value = Utils.linear_interpolation_y(xa, xb, ya, yb, wished_measure); if (value < 0) { value = 0; } if (value > 1) { value = 1; } } else { value = 0.5f; } return(value); }
private void init_delta_measures() { for (int i = 0; i < measures_relat_data.Count; i++) { string[] relation = measures_relat_data[i]; string m_name = relation[0]; string modifier_name = relation[1]; for (int j = 0; j < this.categories.Count; j++) { HumanCategory category = this.categories[j]; for (int k = 0; k < category.modifiers.Count; k++) { HumanModifier modifier = category.modifiers[k]; if (modifier.name == modifier_name) { foreach (string prop in modifier.properties) { this.character_data[prop] = 0.0f; this.combine_morphings(modifier, false, true); float measure1 = this.calc_measure_float(m_name, null); this.character_data[prop] = 1.0f; this.combine_morphings(modifier, false, true); float measure3 = this.calc_measure_float(m_name, null); //#Last measure also restores the value to 0.5 this.character_data[prop] = 0.5f; this.combine_morphings(modifier, false, true); float measure2 = this.calc_measure_float(m_name, null); string delta_name = modifier_name + prop; float delta1 = measure1 - measure2; float delta3 = measure3 - measure2; KeyValuePair <string, float[]> kvp = new KeyValuePair <string, float[]>(delta_name, new float[] { delta1, delta3 }); delta_measures.Add(kvp); } } } } } }
private void combine_morphings(HumanModifier modifier, bool refresh_only, bool add_vertices_to_update) { //Dictionary<float, float> values = new Dictionary<float, float>(); List <KeyValuePair <float, float> > values = new List <KeyValuePair <float, float> >(); foreach (string prop in modifier.properties) { float val = this.character_data[prop]; if (val > 1.0f) { val = 1.0f; } if (val < 0f) { val = 0f; } float val1 = function_modifier_a(val); float val2 = function_modifier_b(val); values.Add(new KeyValuePair <float, float> (val1, val2)); } List <float> weights; List <string> names; smart_combo(modifier.name, values, out names, out weights); for (int i = 0; i < names.Count; i++) { if (refresh_only) { Morph.GetFromListByName(this.morph_data, names[i]).morph_values = weights[i]; } else { this.calculate_morph(names[i], weights[i], true); } } }
private void init_character_data() { categories = new List <HumanCategory>(); for (int i = 0; i < this.morph_data.Count; i++) { string morph_name = this.morph_data[i].morph_name; string[] components = morph_name.Split(new Char[] { '_' }); string compCut = components[0]; if (components[0].Length >= 4) { compCut = components[0].Remove(4, components[0].Length - 4); } //erst ab hier die Bastioni Funktion if (!this.no_categories.Contains(compCut)) { if (components.Length == 3) { category_name = components[0]; HumanCategory category = HumanCategory.GetByName(this.categories, category_name); if (category == null) { category = new HumanCategory(); category.name = category_name; this.categories.Add(category); } string modifier_name = components[0] + "_" + components[1]; HumanModifier modifier = HumanModifier.GetByName(category.modifiers, modifier_name); if (modifier == null) { modifier = new HumanModifier(); modifier.name = modifier_name; category.modifiers.Add(modifier); } string[] elements = components[1].Split(new Char[] { '-' }); for (int j = 0; j < elements.Length; j++) { string element = elements[j]; string prop = components[0] + "_" + element; if (!modifier.properties.Contains(prop)) { modifier.properties.Add(prop); } if (character_data.ContainsKey(prop)) { character_data[prop] = 0.5f; } else { character_data.Add(prop, 0.5f); } } } } } }