public bool GetHardpoint(string hp, out HardpointDefinition def, out BoneInstance bone)
        {
            var hardpoint = dfm.GetHardpoints().First(x => x.Hp.Name.Equals(hp, StringComparison.OrdinalIgnoreCase));

            if (Bones.TryGetValue(hardpoint.Part.objectName, out BoneInstance bi))
            {
                def  = hardpoint.Hp;
                bone = bi;
                return(true);
            }
            def  = null;
            bone = null;
            return(false);
        }
        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;
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 public ResolvedJoint(BoneInstance bone, JointMap jm)
 {
     Bone     = bone;
     JointMap = jm;
 }