示例#1
0
    /// <summary>
    /// Create the avatar control
    /// </summary>
    /// <param name="h">The height.</param>
    public void Create(GameObject h)
    {
        humanoid    = (GameObject)Instantiate(h, Vector3.zero, Quaternion.identity);
        SpineHeight = humanoid.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.Hips).position.y;

        var invisiblelayer = LayerMask.NameToLayer("tagInvisibleToZED");

        humanoid.layer = invisiblelayer;

        foreach (Transform child in humanoid.transform)
        {
            child.gameObject.layer = invisiblelayer;
        }

        rigBone       = new Dictionary <HumanBodyBones, RigBone>();
        rigBoneTarget = new Dictionary <HumanBodyBones, Quaternion>();
        foreach (HumanBodyBones bone in humanBone)
        {
            rigBone[bone]       = new RigBone(humanoid, bone);
            rigBoneTarget[bone] = Quaternion.identity;
        }

        trackingSegment = new Dictionary <HumanBodyBones, Vector3>(targetBone.Length);

        for (int i = 0; i < targetBone.Length; i++)
        {
            trackingSegment[targetBone[i]] = Vector3.zero;
        }
    }
示例#2
0
 void Start()
 {
     leftUpperArm  = new RigBone(humanoid, HumanBodyBones.LeftUpperArm);
     leftLowerArm  = new RigBone(humanoid, HumanBodyBones.LeftLowerArm);
     rightUpperArm = new RigBone(humanoid, HumanBodyBones.RightUpperArm);
     rightUpperLeg = new RigBone(humanoid, HumanBodyBones.RightUpperLeg);
     rightLowerLeg = new RigBone(humanoid, HumanBodyBones.RightLowerLeg);
 }
示例#3
0
    void Start()
    {
        rightLowerArm = new RigBone(humanoid, HumanBodyBones.RightLowerArm);
        rightUpperArm = new RigBone(humanoid, HumanBodyBones.RightUpperArm);

        //x = 0;
        //y = 0;
        //z = 0;
    }
示例#4
0
 public CharacterSkeleton(GameObject h)
 {
     humanoid = h;
     rigBone  = new Dictionary <HumanBodyBones, RigBone>();
     foreach (HumanBodyBones bone in humanBone)
     {
         rigBone[bone] = new RigBone(humanoid, bone);
     }
     savedHumanoidRotation = humanoid.transform.rotation;
     trackingSegment       = new Dictionary <HumanBodyBones, Vector3>(targetBone.Length);
     trackingState         = new Dictionary <HumanBodyBones, int>(targetBone.Length);
 }
示例#5
0
        private void InitializeRigging()
        {
            Vector3 CamPoleLocation        = new Vector3(1, 0, 0);
            Vector3 CamPoleScaleCorrection = new Vector3(.75f, .5f, .75f);

            Vector3 CamArmAPointOfRotationFromPole = new Vector3(0, 1, 0);
            Vector3 CamArmAOriginCorrection        = new Vector3(0, 0, -.1f);

            Vector3 CamArmBPointOfRotationFromArmA = new Vector3(.07f, .07f, -.19f);
            Vector3 CamArmBOriginCorrection        = new Vector3(0, 0, -.1f);
            Vector3 CamArmBOrientCorrection        = new Vector3(0, 0, -(float)Math.PI / 2.0f);

            Vector3 CamBoxPointOfRotationFromArmB = new Vector3(0, 0, 0);
            Matrix  CamBoxRotation = Matrix.CreateFromQuaternion(Quaternion.CreateFromYawPitchRoll(0, 0, 0));
            //Matrix CamBoxOrientCorrection = Matrix.CreateFromQuaternion(Quaternion.CreateFromYawPitchRoll(0, (float)Math.PI, -(float)Math.PI / 2.0f));
            Vector3 CamBoxOrientCorrection = new Vector3(0, (float)Math.PI, 0);
            Vector3 CamBoxOriginCorrection = new Vector3(0, 0, .13f);

            //Vector3 LaserBoxRelativeToCam = new Vector3(-.47f, -.1f, .06f);
            Vector3 LaserBoxRelativeToCam = new Vector3(-.35f, .1f, -.26f); //X:-0.35 Y:0.1 Z:-0.26
            Vector3 LaserScaleCorrection  = new Vector3(.05f, .05f, .1f);

            RigBone CameraPole = RigBone.GetBone((int)RigParts.CameraPole, Pole, CamPoleScaleCorrection, Vector3.Zero, CamPoleLocation, Vector3.Zero, Vector3.Zero);

            RigBone CameraArmA = RigBone.GetBone((int)RigParts.CameraArmA, Arm, 1.4f, Vector3.Zero, CamArmAPointOfRotationFromPole, Vector3.Zero, CamArmAOriginCorrection);

            CameraArmA.AdjustYawPitchRoll(rotCamYaw, 0, 0);

            RigBone CameraArmB = RigBone.GetBone((int)RigParts.CameraArmB, Arm, 1.4f, Vector3.Zero, CamArmBPointOfRotationFromArmA, CamArmBOrientCorrection, CamArmBOriginCorrection);

            CameraArmB.AdjustYawPitchRoll(0, rotCamPitch, 0);

            RigBone CameraBox = RigBone.GetBone((int)RigParts.CameraBox, Cam, Vector3.Zero, CamBoxPointOfRotationFromArmB, CamBoxOrientCorrection, CamBoxOriginCorrection);

            RigBone LaserBox = RigBone.GetBone((int)RigParts.LaserBox, Laser, LaserScaleCorrection, Vector3.Zero, LaserBoxRelativeToCam, Vector3.Zero, Vector3.Zero);

            rig.AddBone(-1, CameraPole);
            rig.AddBone((int)RigParts.CameraPole, CameraArmA);
            rig.AddBone((int)RigParts.CameraArmA, CameraArmB);
            rig.AddBone((int)RigParts.CameraArmB, CameraBox);
            rig.AddBone((int)RigParts.CameraBox, LaserBox);
        }
    public CharacterSkeleton(GameObject h)
    {
        humanoid = h;

        pointer = GameObject.Find(humanoid.name + "_pointer");
        rigBone = new Dictionary <HumanBodyBones, RigBone>();

        joint      = new Vector3[jointCount];
        jointState = new int[jointCount];

        foreach (HumanBodyBones bone in humanBone)
        {
            rigBone[bone] = new RigBone(humanoid, bone);
        }


        trackingSegment = new Dictionary <HumanBodyBones, Vector3>(targetBone.Length);
        trackingState   = new Dictionary <HumanBodyBones, int>(targetBone.Length);

        criteriaVec = new Vector3[19];
    }