private Source GetSource <T>(string name, IList <T> data, Func <T, IEnumerable <float> > func) { var source = new Source { Id = name, Name = name }; var sourceArray = new Float_Array { Id = $"{name}-array", Count = (ulong)data.Count * 3, Value = string.Join(" ", data.SelectMany(func).Select(v => v.ToString(CultureInfo.InvariantCulture))) }; source.Float_Array = sourceArray; source.Technique_Common = new SourceTechnique_Common { Accessor = new Accessor { Source = $"#{name}-array", Count = (ulong)data.Count, Stride = 3 } }; source.Technique_Common.Accessor.Param.Add(new Param() { Name = "X", Type = "float" }); source.Technique_Common.Accessor.Param.Add(new Param() { Name = "Y", Type = "float" }); source.Technique_Common.Accessor.Param.Add(new Param() { Name = "Z", Type = "float" }); return(source); }
public Source(XPathNodeIterator iterator, string uri) { XPathNodeIterator attributeIterator; attributeIterator = iterator.Current.Select("@" + XmlCollada.Source.id); if (attributeIterator.Count > 0) { attributeIterator.MoveNext(); _id = attributeIterator.Current.Value; } attributeIterator = iterator.Current.Select("@" + XmlCollada.Source.name); if (attributeIterator.Count > 0) { attributeIterator.MoveNext(); _name = attributeIterator.Current.Value; } XPathNodeIterator float_arrayNodesIterator = iterator.Current.SelectChildren(XmlCollada.Float_Array.root, uri); if (float_arrayNodesIterator.MoveNext()) { _floatArray = new Float_Array(float_arrayNodesIterator, uri); } XPathNodeIterator technique_commonNodesIterator = iterator.Current.SelectChildren(XmlCollada.Technique_Common.root, uri); if (technique_commonNodesIterator.MoveNext()) { _techniqueCommon = new Technique_Common(technique_commonNodesIterator, uri); } _value = iterator.Current.Value; }
public Source(string id, string name, Technique_Common techniqueCommon, Float_Array floatArray, string value) { _id = id; _name = name; _techniqueCommon = techniqueCommon; _floatArray = floatArray; _value = value; }