public MeshInputs(XElement element,ColladaSchema schema) { var countAttribute = element.Attribute(schema.countName); if (countAttribute != null) { this.count = int.Parse(countAttribute.Value, CultureInfo.InvariantCulture); } foreach (var xElement in element.Elements(schema.inputName)) { inputs.Add(new Input(xElement, schema)); } this.stride = inputs.Max(x => x.Offset)+1; }
public Accessor(XElement accessorElement, ColladaSchema schema) { var attribute = accessorElement.Attribute(schema.strideName); if (attribute != null) { this.stride = int.Parse(attribute.Value, CultureInfo.InvariantCulture); } else { this.stride = 1; } var xAttribute = accessorElement.Attribute(schema.countName); if (xAttribute != null) { this.count = int.Parse(xAttribute.Value, CultureInfo.InvariantCulture); } }
/// <summary> /// Load mesh from stream. /// </summary> /// <param name="stream">Stream to read from.</param> /// <param name="basePath"> </param> /// <returns>Complete parsed mesh.</returns> public IScene Load(Stream stream, string basePath) { this.basePath = basePath ?? Directory.GetCurrentDirectory(); var scene = new Scene(); var doc = XDocument.Load(stream); var r = doc.Root; this.schema = new ColladaSchema(r.Name.Namespace.NamespaceName); this.collada = doc.Element(this.schema.colladaName); this.ParseAsset(scene, this.collada.Element(this.schema.assetName)); this.ParseImages(scene, this.collada.Element(this.schema.libraryImagesName)); this.ParseEffects(scene, this.collada.Element(this.schema.libraryEffectsName)); this.ParseMaterials(scene, this.collada.Element(this.schema.libraryMaterialsName)); this.ParseGeometries(scene, this.collada.Element(this.schema.libraryGeometriesName)); this.ParseScene(scene, this.collada, this.collada.Element(this.schema.sceneName)); this.AssignNullMaterialToDefault(scene); return scene; }
public Input(XElement input, ColladaSchema schema) { var setAttr = input.Attribute(schema.setName); if (setAttr != null) { this.set = int.Parse(setAttr.Value, CultureInfo.InvariantCulture); } var offsetAttr = input.Attribute(schema.offsetName); if (offsetAttr != null) { this.offset = int.Parse(offsetAttr.Value, CultureInfo.InvariantCulture); } this.semantic = input.Attribute(schema.semanticName).Value; this.source = input.Attribute(schema.sourceAttributeName).Value; //if (this.source[0] != '#') //{ // throw new DaeException(string.Format(CultureInfo.InvariantCulture, "Invalid element reference {0}", this.source)); //} //var id = this.source.Substring(1); //this.sourceElement = // (from node in mesh.Descendants() let a = node.Attribute(schema.idName) where a != null && a.Value == id select node) // .First(); //if (this.sourceElement.Name == schema.verticesName) //{ // this.sourceData = this.ParseVerticesSource(this.sourceElement, schema, mesh); //} //else if (this.sourceElement.Name == schema.sourceName) //{ // this.sourceData = this.ParseSource(this.sourceElement, schema, mesh); //} //else //{ // throw new DaeException( // string.Format(CultureInfo.InvariantCulture, "Unknown source type {0}", this.sourceElement.Name)); //} }
private static ISource ParseIDREFArraySource(XElement xElement, ColladaSchema schema) { var s = new IDREFArraySource(xElement, schema); return s; }
public static ISource ParseSource(XElement xElement, ColladaSchema schema) { var floatArray = xElement.Element(schema.floatArrayName); if (floatArray != null) { return ParseFloatArraySource(xElement, schema); } var intArray = xElement.Element(schema.intArrayName); if (intArray != null) { return ParseIntArraySource(xElement, schema); } var boolArray = xElement.Element(schema.boolArrayName); if (boolArray != null) { return ParseBoolArraySource(xElement, schema); } var nameArray = xElement.Element(schema.nameArrayName); if (nameArray != null) { return ParseNameArraySource(xElement, schema); } var idrefArray = xElement.Element(schema.boolArrayName); if (idrefArray != null) { return ParseIDREFArraySource(xElement, schema); } throw new DaeException( string.Format(CultureInfo.InvariantCulture, "Unknown source type {0}", xElement.Name)); }