private void RemapInputs(Model.SubModel sub, ModelSettings settings) { if (settings.channels.Count <= 0) { return; } List <Model.SourceInput> newInputs = new List <Model.SourceInput>(); foreach (ModelSettings.Channel channel in settings.channels) { Model.SourceInput input = sub.inputList.FirstOrDefault((i) => i.semantic == channel.semantic && i.set == channel.set); if (input == null && !channel.useDefault) { continue; } Model.SourceInput newInput = new Model.SourceInput(); newInput.name = channel.name; newInput.data = (input != null)?input.data:null; newInput.semantic = channel.semantic; newInput.set = channel.set; newInput.offset = (input != null)?input.offset:channel.def; if (newInput.data != null) { newInput.data.semantic = newInput.name; } newInputs.Add(newInput); } sub.inputList = newInputs; }
private int ReadInputs(Model model, Model.SubModel sub, XElement xSub) { int numOffsets = 0; List <Model.SourceInput> list = new List <Model.SourceInput>(); foreach (XElement xInput in xSub.Elements(parent.ns + "input")) { int offset = (int)xInput.Attribute("offset"); if (offset + 1 > numOffsets) { numOffsets = offset + 1; } Model.SourceInput source = new Model.SourceInput(); source.name = ((string)xInput.Attribute("source")).Substring(1); source.data = model.accessorList.FirstOrDefault((s) => s.name == source.name); source.semantic = (string)xInput.Attribute("semantic"); if (xInput.Attribute("set") != null) { source.set = (string)xInput.Attribute("set"); } source.offset = offset; list.Add(source); } foreach (Model.SourceInput source in list) { if (source.data != null) { source.name = source.semantic + source.set; source.data.semantic = source.name; sub.inputList.Add(source); } foreach (Model.SourceAccessorRef item in model.mapAccessorToInput.Where((k) => k.name == source.name)) { Model.SourceInput source2 = new Model.SourceInput(); source2.name = item.semantic; source2.data = item.accessor; source2.semantic = item.semantic; source2.set = ""; source2.offset = source.offset; while (char.IsDigit(source2.semantic.Last())) { source2.set = source2.semantic.Last().ToString() + source2.set; source2.semantic = source2.semantic.Substring(0, source2.semantic.Length - 1); } if (source2.data != null) { source2.data.semantic = source2.name; } sub.inputList.Add(source2); } } return(numOffsets); }