예제 #1
0
		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;
		}
예제 #2
0
파일: Accessor.cs 프로젝트: gleblebedev/toe
		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);
			}
		}
예제 #3
0
		/// <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;
		}
예제 #4
0
파일: Input.cs 프로젝트: gleblebedev/toe
		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));
			//}
		}
예제 #5
0
		private static ISource ParseIDREFArraySource(XElement xElement, ColladaSchema schema)
		{
			var s = new IDREFArraySource(xElement, schema);
			return s;
		}
예제 #6
0
		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));
		}