Exemple #1
0
		public Skeleton(CoreSkeleton coreSkeleton)
		{
			this.coreSkeleton = coreSkeleton;

			bones = coreSkeleton.Bones.Select(x => new Bone(x, this)).
				ToDictionary(x => x.CoreBone);
		}
		public CoreAnimation(string filename, CoreSkeleton skeleton)
		{
			var doc = new XmlDocument();
			doc.Load(filename);

			duration = float.Parse(doc.SelectSingleNode("/ANIMATION/@DURATION").Value);

			tracks = doc.SelectElements("//TRACK").Select(
				e => new CoreTrack(e, skeleton)).ToList();
		}
		public CoreTrack(XmlElement e, CoreSkeleton skeleton)
		{
			int boneId = int.Parse(e.GetAttribute("BONEID"));
			bone = skeleton.GetBone(boneId);

			keys = e.SelectElements("./KEYFRAME").Select(
				x => new Pair<float, Transform>(
					float.Parse(x.GetAttribute("TIME")),
					new Transform(
						Util.ReadQuaternion(x.SelectSingleNode("./ROTATION")),
						Util.ReadVector3(x.SelectSingleNode("./TRANSLATION"))))).ToList();
		}
Exemple #4
0
		public CoreMesh(string filename, CoreSkeleton skeleton)
		{
			var doc = new XmlDocument();
			doc.Load(filename);

			vertices = doc.SelectElements("//VERTEX").Select(
				e => new Pair<Vertex, CoreBone>(
					new Vertex(e),
					skeleton.GetBone(int.Parse( e.SelectSingleNode("./INFLUENCE/@ID" ).Value )))).ToArray();

			indices = doc.SelectAttributes("//FACE/@VERTEXID").SelectMany(
				e => e.Value.Split(' ').Select(x => ushort.Parse(x))).ToArray();

			textureName = CoreMaterial.GetTextureFilename(
				Path.ChangeExtension(filename, ".xrf"));
		}
Exemple #5
0
		internal CoreBone(XmlElement e, CoreSkeleton skeleton)
		{
			parentId = int.Parse(e.SelectSingleNode("./PARENTID").InnerText);

			name = e.GetAttribute("NAME");
			boneSpace = new Transform(
				Util.ReadQuaternion(e.SelectSingleNode("./LOCALROTATION")),
				Util.ReadVector3(e.SelectSingleNode("./LOCALTRANSLATION")));

			transform = new Transform(
				Util.ReadQuaternion(e.SelectSingleNode("./ROTATION")),
				Util.ReadVector3(e.SelectSingleNode("./TRANSLATION")));

			this.skeleton = skeleton;

			parent = Lazy.New(() => 
			{ 
				var bone = skeleton.GetBone(parentId); 
				if (bone != null)
					bone.AddChild(this);
				return bone;
			});
		}