public CharacterRenderer(DfmFile head, DfmFile body, DfmFile leftHand, DfmFile rightHand) { Head = head; Body = body; LeftHand = leftHand; RightHand = rightHand; }
public CharacterSkinning(DfmFile dfm) { this.dfm = dfm; boneMatrices = new Matrix4[dfm.Bones.Count]; for (int i = 0; i < boneMatrices.Length; i++) { boneMatrices[i] = Matrix4.Identity; } }
public DfmSkinning(DfmFile dfm) { this.dfm = dfm; int length = (dfm.Parts.Keys.Max() + 1); boneMatrices = new Matrix4x4[length]; instanceArray = new BoneInstance[length]; foreach (var kv in dfm.Parts) { var inst = new BoneInstance(); inst.Name = kv.Value.objectName; Matrix4x4.Invert(kv.Value.Bone.BoneToRoot, out inst.InvBindPose); inst.BoneMatrix = inst.InvBindPose; instanceArray[kv.Key] = inst; Bones.Add(inst.Name, inst); } foreach (var con in dfm.Constructs.Constructs) { if (!Bones.ContainsKey(con.ChildName)) { continue; } var inst = Bones[con.ChildName]; if (!string.IsNullOrEmpty(con.ParentName)) { var parent = Bones[con.ParentName]; parent.Children.Add(inst); inst.Parent = parent; } inst.OriginalRotation = con.Rotation; inst.Origin = con.Origin; } foreach (var b in Bones.Values) { if (b.Parent == null) { starts.Add(b); } } for (int j = 0; j < boneMatrices.Length; j++) { boneMatrices[j] = Matrix4x4.Identity; } }
public DfmFile GetDfm(string filename) { if (!dfms.ContainsKey(filename)) { var file = new DfmFile(filename, this); if (file.TextureLibrary != null) { AddTextures(file.TextureLibrary, filename); } if (file.MaterialLibrary != null) { AddMaterials(file.MaterialLibrary, filename); } file.Initialize(this); dfms.Add(filename, file); } return(dfms[filename]); }
public CharacterSkinning(DfmFile dfm) { this.dfm = dfm; int length = (dfm.Parts.Keys.Max() + 1); boneMatrices = new Matrix4[length]; instanceArray = new BoneInstance[length]; foreach (var kv in dfm.Parts) { var inst = new BoneInstance(); inst.Name = kv.Value.objectName; inst.InvBindPose = kv.Value.Bone.BoneToRoot.Inverted(); instanceArray[kv.Key] = inst; boneInstances.Add(inst.Name, inst); } foreach (var con in dfm.Constructs.Constructs) { if (!boneInstances.ContainsKey(con.ChildName)) { continue; } var inst = boneInstances[con.ChildName]; if (!string.IsNullOrEmpty(con.ParentName)) { var parent = boneInstances[con.ParentName]; inst.Parent = parent; } inst.OriginalRotation = con.Rotation; inst.Origin = con.Origin; } for (int j = 0; j < boneMatrices.Length; j++) { boneMatrices[j] = Matrix4.Identity; } BonesBuffer = new UniformBuffer(200, 64, typeof(Matrix4)); BonesBuffer.SetData(boneMatrices); }