public ColladaVisualScene(Collada.ColladaRoot collada, XElement node) : base(collada, node, "-ColladaVisualScene") { foreach (XElement node2 in node.Elements(Collada.ColladaRoot.Namespace + "node")) { this.Nodes.Add(new Collada.ColladaNode(collada, node2)); } }
public ColladaVertices(Collada.ColladaRoot collada, XElement node) : base(collada, node, "") { XElement xelement = node.Element(Collada.ColladaRoot.Namespace + "input"); this.Semantic = xelement.Attribute("semantic").Value; this.Source = (Collada.ColladaSource)collada.ObjectsById[xelement.Attribute("source").Value.Substring(1)]; }
public ColladaNode(Collada.ColladaRoot collada, XElement node) : base(collada, node, "") { foreach (XElement xelement in node.Elements()) { if (xelement.Name == Collada.ColladaRoot.Namespace + "matrix") { float[] array = Enumerable.ToArray <float>(Enumerable.Select <string, float>(xelement.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries), (string s) => float.Parse(s, CultureInfo.InvariantCulture))); this.Transform = Matrix.Transpose(new Matrix(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10], array[11], array[12], array[13], array[14], array[15])) * this.Transform; } else if (xelement.Name == Collada.ColladaRoot.Namespace + "translate") { float[] array2 = Enumerable.ToArray <float>(Enumerable.Select <string, float>(xelement.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries), (string s) => float.Parse(s, CultureInfo.InvariantCulture))); this.Transform = Matrix.CreateTranslation(array2[0], array2[1], array2[2]) * this.Transform; } else if (xelement.Name == Collada.ColladaRoot.Namespace + "rotate") { float[] array3 = Enumerable.ToArray <float>(Enumerable.Select <string, float>(xelement.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries), (string s) => float.Parse(s, CultureInfo.InvariantCulture))); this.Transform = Matrix.CreateFromAxisAngle(new Vector3(array3[0], array3[1], array3[2]), array3[3] / 180f * 3.1415927f) * this.Transform; } else if (xelement.Name == Collada.ColladaRoot.Namespace + "scale") { float[] array4 = Enumerable.ToArray <float>(Enumerable.Select <string, float>(xelement.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries), (string s) => float.Parse(s, CultureInfo.InvariantCulture))); this.Transform = Matrix.CreateScale(array4[0], array4[1], array4[2]) * this.Transform; } } foreach (XElement node2 in node.Elements(Collada.ColladaRoot.Namespace + "node")) { this.Nodes.Add(new Collada.ColladaNode(collada, node2)); } foreach (XElement xelement2 in node.Elements(Collada.ColladaRoot.Namespace + "instance_geometry")) { this.Geometries.Add((Collada.ColladaGeometry)collada.ObjectsById[xelement2.Attribute("url").Value.Substring(1)]); } }
public ColladaLibraryGeometries(Collada.ColladaRoot collada, XElement node) { foreach (XElement node2 in node.Elements(Collada.ColladaRoot.Namespace + "geometry")) { this.Geometries.Add(new Collada.ColladaGeometry(collada, node2)); } }
public ColladaLibraryVisualScenes(Collada.ColladaRoot collada, XElement node) { foreach (XElement node2 in node.Elements(Collada.ColladaRoot.Namespace + "visual_scene")) { this.VisualScenes.Add(new Collada.ColladaVisualScene(collada, node2)); } }
public static ModelData Load(Stream stream) { ModelData modelData = new ModelData(); Collada.ColladaRoot colladaRoot = new Collada.ColladaRoot(XElement.Load(stream)); if (colladaRoot.Scene.VisualScene.Nodes.Count > 1) { ModelBoneData modelBoneData = new ModelBoneData(); modelData.Bones.Add(modelBoneData); modelBoneData.ParentBoneIndex = -1; modelBoneData.Name = string.Empty; modelBoneData.Transform = Matrix.Identity; using (List <Collada.ColladaNode> .Enumerator enumerator = colladaRoot.Scene.VisualScene.Nodes.GetEnumerator()) { while (enumerator.MoveNext()) { Collada.ColladaNode node = enumerator.Current; Collada.LoadNode(modelData, modelBoneData, node, Matrix.CreateScale(colladaRoot.Asset.Meter)); } goto IL_104; } } foreach (Collada.ColladaNode node2 in colladaRoot.Scene.VisualScene.Nodes) { Collada.LoadNode(modelData, null, node2, Matrix.CreateScale(colladaRoot.Asset.Meter)); } IL_104: foreach (ModelBuffersData modelBuffersData in modelData.Buffers) { Collada.IndexVertices(modelBuffersData.VertexDeclaration.VertexStride, modelBuffersData.Vertices, out modelBuffersData.Vertices, out modelBuffersData.Indices); } return(modelData); }
public ColladaGeometry(Collada.ColladaRoot collada, XElement node) : base(collada, node, "") { XElement xelement = node.Element(Collada.ColladaRoot.Namespace + "mesh"); if (xelement != null) { this.Mesh = new Collada.ColladaMesh(collada, xelement); } }
public ColladaMesh(Collada.ColladaRoot collada, XElement node) { foreach (XElement node2 in node.Elements(Collada.ColladaRoot.Namespace + "source")) { this.Sources.Add(new Collada.ColladaSource(collada, node2)); } XElement node3 = node.Element(Collada.ColladaRoot.Namespace + "vertices"); this.Vertices = new Collada.ColladaVertices(collada, node3); foreach (XElement node4 in Enumerable.Concat <XElement>(Enumerable.Concat <XElement>(node.Elements(Collada.ColladaRoot.Namespace + "polygons"), node.Elements(Collada.ColladaRoot.Namespace + "polylist")), node.Elements(Collada.ColladaRoot.Namespace + "triangles"))) { this.Polygons.Add(new Collada.ColladaPolygons(collada, node4)); } }
public ColladaPolygons(Collada.ColladaRoot collada, XElement node) { foreach (XElement node2 in node.Elements(Collada.ColladaRoot.Namespace + "input")) { this.Inputs.Add(new Collada.ColladaInput(collada, node2)); } foreach (XElement xelement in node.Elements(Collada.ColladaRoot.Namespace + "vcount")) { this.VCount.AddRange(Enumerable.Select <string, int>(xelement.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries), (string s) => int.Parse(s, CultureInfo.InvariantCulture))); } foreach (XElement xelement2 in node.Elements(Collada.ColladaRoot.Namespace + "p")) { this.P.AddRange(Enumerable.Select <string, int>(xelement2.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries), (string s) => int.Parse(s, CultureInfo.InvariantCulture))); } }
public ColladaAccessor(Collada.ColladaRoot collada, XElement node) { this.Source = (Collada.ColladaFloatArray)collada.ObjectsById[node.Attribute("source").Value.Substring(1)]; XAttribute xattribute = node.Attribute("offset"); if (xattribute != null) { this.Offset = int.Parse(xattribute.Value, CultureInfo.InvariantCulture); } XAttribute xattribute2 = node.Attribute("stride"); if (xattribute2 != null) { this.Stride = int.Parse(xattribute2.Value, CultureInfo.InvariantCulture); } }
public ColladaNameId(Collada.ColladaRoot collada, XElement node, string idPostfix = "") { XAttribute xattribute = node.Attribute("id"); if (xattribute != null) { this.Id = xattribute.Value + idPostfix; collada.ObjectsById.Add(this.Id, this); } XAttribute xattribute2 = node.Attribute("name"); if (xattribute2 != null) { this.Name = xattribute2.Value; } }
public ColladaSource(Collada.ColladaRoot collada, XElement node) : base(collada, node, "") { XElement xelement = node.Element(Collada.ColladaRoot.Namespace + "float_array"); if (xelement != null) { this.FloatArray = new Collada.ColladaFloatArray(collada, xelement); } XElement xelement2 = node.Element(Collada.ColladaRoot.Namespace + "technique_common"); if (xelement2 != null) { XElement xelement3 = xelement2.Element(Collada.ColladaRoot.Namespace + "accessor"); if (xelement3 != null) { this.Accessor = new Collada.ColladaAccessor(collada, xelement3); } } }
public ColladaInput(Collada.ColladaRoot collada, XElement node) { this.Offset = int.Parse(node.Attribute("offset").Value, CultureInfo.InvariantCulture); this.Semantic = node.Attribute("semantic").Value; XAttribute xattribute = node.Attribute("set"); if (xattribute != null) { this.Set = int.Parse(xattribute.Value, CultureInfo.InvariantCulture); } Collada.ColladaNameId colladaNameId = collada.ObjectsById[node.Attribute("source").Value.Substring(1)]; if (colladaNameId is Collada.ColladaVertices) { Collada.ColladaVertices colladaVertices = (Collada.ColladaVertices)colladaNameId; this.Source = colladaVertices.Source; this.Semantic = colladaVertices.Semantic; return; } this.Source = (Collada.ColladaSource)colladaNameId; }
public ColladaFloatArray(Collada.ColladaRoot collada, XElement node) : base(collada, node, "") { this.Array = Enumerable.ToArray <float>(Enumerable.Select <string, float>(node.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries), (string s) => float.Parse(s, CultureInfo.InvariantCulture))); }
public ColladaScene(Collada.ColladaRoot collada, XElement node) { XElement xelement = node.Element(Collada.ColladaRoot.Namespace + "instance_visual_scene"); this.VisualScene = (Collada.ColladaVisualScene)collada.ObjectsById[xelement.Attribute("url").Value.Substring(1) + "-ColladaVisualScene"]; }