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(); }
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")); }
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; }); }