private void OffsetMinBound(BoneName boneName, float offset)
 {
     initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.W -= offset;
     initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.X -= offset;
     initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Y -= offset;
     initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Z -= offset;
 }
        // create a BoneSkeleton based on a Skeleton instance received from Kinect sensor
        public BoneSkeleton(Skeleton skeleton)
        {
            foreach (BoneOrientation boneOrientation in skeleton.BoneOrientations)
            {
                if (!Mapper.JointTypeJointNameMap.ContainsKey(boneOrientation.StartJoint) ||
                    !Mapper.JointTypeJointNameMap.ContainsKey(boneOrientation.EndJoint))
                {
                    continue;
                }

                Tuple <JointName, JointName> jointTuple = new Tuple <JointName, JointName>(
                    Mapper.JointTypeJointNameMap[boneOrientation.StartJoint],
                    Mapper.JointTypeJointNameMap[boneOrientation.EndJoint]);

                if (!Mapper.JointBoneMap.ContainsKey(jointTuple))
                {
                    continue;
                }

                BoneName boneName = Mapper.JointBoneMap[jointTuple];
                Rotation rotation = new Rotation(boneOrientation.HierarchicalRotation.Quaternion.W
                                                 , boneOrientation.HierarchicalRotation.Quaternion.X
                                                 , boneOrientation.HierarchicalRotation.Quaternion.Y
                                                 , boneOrientation.HierarchicalRotation.Quaternion.Z);

                bones[Mapper.BoneIndexMap[boneName]] = new Bone(rotation, boneName);;
            }
        }
Esempio n. 3
0
        BoneProfile GetBoneProfile(BoneName bone)
        {
            bool isRoot = Bindings.Definition.IsRoot(bone);

            BoneProfile previous = previousProfile.GetBoneProfile(bone, isRoot);
            BoneProfile current  = currentProfile.GetBoneProfile(bone, isRoot);

            return(BoneProfile.Blend(previous, current, profileTransitioner.Value));
        }
        public Bone GetBone(BoneName boneName)
        {
            if (!Mapper.BoneIndexMap.ContainsKey(boneName))
            {
                return(new Bone());
            }

            return(bones[Mapper.BoneIndexMap[boneName]]);
        }
        public void WriteToFile(FxArchive Owner, BinaryWriter writer)
        {
            BoneName.WriteToFile(Owner, writer);
            Transform.WriteToFile(writer);
            writer.Write(UnkQuaternion);
            writer.Write(PossibleIdx2);
            writer.Write(Unk0);

            writer.Write(Links.Length);
            foreach (FxBoneLink Link in Links)
            {
                Link.WriteToFile(writer);
            }
        }
        /// <summary>
        /// Gets the animator profile for the bone.
        /// If it has no overrides, the default profile will be returned; even if the bone isn't in the definition.
        /// </summary>
        public BoneProfile GetBoneProfile(BoneName boneName, bool isRoot)
        {
            bool overrideExists = overridenProfiles.TryGetValue(boneName, out BoneProfile returnedProfile);

            if (!overrideExists)
            {
                returnedProfile = DefaultBoneProfile;
            }

            if (isRoot && !matchRootRotation)
            {
                returnedProfile.rotationAlpha = 0;
            }

            return(returnedProfile);
        }
Esempio n. 7
0
        private float[][] GetRawSignal(Body[] bodySignal, BoneName boneName)
        {
            float[][] res = new float[4][];
            for (int i = 0; i < 4; i++)
            {
                res[i] = new float[bodySignal.Length];
            }

            for (int i = 0; i < bodySignal.Length; i++)
            {
                res[0][i] = bodySignal[i].BoneSkeleton.GetBone(boneName).Rotation.W;
                res[1][i] = bodySignal[i].BoneSkeleton.GetBone(boneName).Rotation.X;
                res[2][i] = bodySignal[i].BoneSkeleton.GetBone(boneName).Rotation.Y;
                res[3][i] = bodySignal[i].BoneSkeleton.GetBone(boneName).Rotation.Z;
            }

            return(res);
        }
        private void ComputeMinBounds(Body body, BoneName boneName)
        {
            initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.W =
                Math.Min(body.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.W,
                         initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.W);

            initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.X =
                Math.Min(body.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.X,
                         initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.X);

            initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Y =
                Math.Min(body.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Y,
                         initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Y);

            initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Z =
                Math.Min(body.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Z,
                         initialPositionDeviation.MinBound.BoneSkeleton.Bones[Mapper.BoneIndexMap[boneName]].Rotation.Z);
        }
        public void ReadFromFile(FxArchive Owner, BinaryReader reader)
        {
            BoneName.ReadFromFile(Owner, reader);
            Transform = new FxBoneTransform();
            Transform.ReadFromFile(reader);
            UnkQuaternion = reader.ReadBytes(16);
            PossibleIdx2  = reader.ReadUInt32();
            Unk0          = reader.ReadSingle();

            uint NumLinks = reader.ReadUInt32();

            Links = new FxBoneLink[NumLinks];
            for (int i = 0; i < NumLinks; i++)
            {
                FxBoneLink LinkObject = new FxBoneLink();
                LinkObject.ReadFromFile(reader);
                Links[i] = LinkObject;
            }
        }
Esempio n. 10
0
        private GrabInfo GetGrabInfoForBone(BoneName bone)
        {
            switch (bone)
            {
            case "L_Foot":
                return(leftFootGrab);

            case "R_Foot":
                return(rightFootGrab);

            case "L_Hand":
                return(leftHandGrab);

            case "R_Hand":
                return(rightHandGrab);

            default:
                UnityEngine.Debug.LogError($"Asked for the GrabInfo for a bone that isn't an extremity ({bone}). This is wrong.", this);
                return(null);
            }
        }
        private void OffsetBounds(BoneName boneName)
        {
            float offset;

            if (boneName == BoneName.BodyCenter || boneName == BoneName.Neck)
            {
                offset = 0.5f;
            }
            else if (boneName == BoneName.ArmLeft || boneName == BoneName.ArmRight ||
                     boneName == BoneName.ForearmLeft || boneName == BoneName.ForearmRight ||
                     boneName == BoneName.FemurusLeft || boneName == BoneName.FemurusRight ||
                     boneName == BoneName.TibiaLeft || boneName == BoneName.TibiaRight)
            {
                offset = 0.1f;
            }
            else
            {
                offset = 0.1f;
            }

            OffsetMinBound(boneName, offset);
            OffsetMaxBound(boneName, offset);
        }
Esempio n. 12
0
        public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene)
        {
            if (!editorScene.ShouldBeDrawn(this))
            {
                return;
            }

            bool hovered = editorScene.Hovered == this;

            string modelName = "";

            float noModelScale = 0.0625f;

            if (BoneName.StartsWith("W") && !BoneName.EndsWith("M0"))
            {
                modelName = "cobCourse";
            }
            //else if(attributes!=null && attributes[2].Contains("switchA"))
            //{
            //    modelName = "cobSwitchA";
            //}
            //else if (attributes != null && attributes[2].Contains("switchB"))
            //{
            //    modelName = "cobSwitchB";
            //}

            if (BfresModelCache.Contains(modelName))
            {
                control.UpdateModelMatrix(
                    Matrix4.CreateTranslation(Selected ? editorScene.SelectionTransformAction.NewPos(GlobalPosition) : GlobalPosition));

                Vector4 highlightColor;

                if (Selected)
                {
                    highlightColor = selectColor;
                }
                else if (hovered)
                {
                    highlightColor = hoverColor;
                }
                else
                {
                    highlightColor = Vector4.Zero;
                }

                BfresModelCache.TryDraw(modelName, control, pass, highlightColor);
                return;
            }
            else
            {
                if (pass == Pass.TRANSPARENT)
                {
                    return;
                }

                control.UpdateModelMatrix(
                    Matrix4.CreateScale(noModelScale) *
                    Matrix4.CreateTranslation(Selected ? editorScene.SelectionTransformAction.NewPos(GlobalPosition) : GlobalPosition));
            }

            Vector4 blockColor;
            Vector4 lineColor;

            if (hovered && Selected)
            {
                lineColor = hoverColor;
            }
            else if (hovered || Selected)
            {
                lineColor = selectColor;
            }
            else
            {
                lineColor = Color;
            }

            if (hovered && Selected)
            {
                blockColor = Color * 0.5f + hoverColor * 0.5f;
            }
            else if (hovered || Selected)
            {
                blockColor = Color * 0.5f + selectColor * 0.5f;
            }
            else
            {
                blockColor = Color;
            }

            Renderers.ColorBlockRenderer.DrawWithoutTextures(control, pass, blockColor, lineColor, control.NextPickingColor());
        }
Esempio n. 13
0
 public Bone(Rotation rotation, BoneName boneName)
 {
     this.rotation = rotation;
     this.boneName = boneName;
 }
 public override string ToString()
 {
     return(BoneName.ToString());
 }
 public void PopulateStringTable(FxArchive Owner)
 {
     BoneName.AddToStringTable(Owner);
 }