void Start() { if (HeadTransform != null) { HeadInitialPosition = HeadTransform.localPosition; //HeadInitialPosition.z = 0; HeadInitialRotation = HeadTransform.localRotation; } if (LeftEyeTransform != null) { LeftEyeInitialPosition = LeftEyeTransform.localPosition; //HeadInitialPosition.z = 0; LeftEyeInitialRotation = LeftEyeTransform.localRotation; } if (RightEyeTransform != null) { RightEyeInitialPosition = LeftEyeTransform.localPosition; //HeadInitialPosition.z = 0; RightEyeInitialRotation = LeftEyeTransform.localRotation; } KinectManager kinectManager = KinectManager.Instance; if (kinectManager && kinectManager.IsInitialized()) { platform = kinectManager.GetSensorPlatform(); } blendShapeCount = skinnedMesh.blendShapeCount; }
// sets up the image rectangle and body colliders private void SetupJointColliders() { if (kinectManager && kinectManager.IsInitialized()) { sensorIndex = kinectManager.GetPrimaryBodySensorIndex(); sensorData = kinectManager.GetSensorData(sensorIndex); if (sensorData != null && foregroundCamera != null) { // sensor platform sensorPlatform = sensorData.sensorIntPlatform; // get depth image size depthImageWidth = sensorData.depthImageWidth; depthImageHeight = sensorData.depthImageHeight; // calculate the foreground rectangles //Rect cameraRect = foregroundCamera.pixelRect; //float rectHeight = cameraRect.height; //float rectWidth = cameraRect.width; //if (rectWidth > rectHeight) // rectWidth = rectHeight * depthImageWidth / depthImageHeight; //else // rectHeight = rectWidth * depthImageHeight / depthImageWidth; //float foregroundOfsX = (cameraRect.width - rectWidth) / 2; //float foregroundOfsY = (cameraRect.height - rectHeight) / 2; //foregroundImgRect = new Rect(foregroundOfsX, foregroundOfsY, rectWidth, rectHeight); foregroundImgRect = kinectManager.GetForegroundRectDepth(sensorIndex, foregroundCamera); // create joint colliders numColliders = kinectManager.GetJointCount(); jointColliders = new GameObject[numColliders]; for (int i = 0; i < numColliders; i++) { string sColObjectName = ((KinectInterop.JointType)i).ToString() + "Collider"; jointColliders[i] = new GameObject(sColObjectName); jointColliders[i].transform.parent = transform; if (i == 0) { // circle collider for body center CircleCollider2D collider = jointColliders[i].AddComponent <CircleCollider2D>(); collider.radius = colliderWidth; } else { // box colliders for bones BoxCollider2D collider = jointColliders[i].AddComponent <BoxCollider2D>(); collider.size = new Vector2(colliderWidth, colliderWidth); } } } } }
void Start() { if (HeadTransform != null) { HeadInitialPosition = HeadTransform.localPosition; //HeadInitialPosition.z = 0; HeadInitialRotation = HeadTransform.localRotation; } UpperLipLeftNeutral = GetJointRotation(UpperLipLeft, UpperLipLeftAxis); UpperLipRightNeutral = GetJointRotation(UpperLipRight, UpperLipRightAxis); JawNeutral = GetJointRotation(Jaw, JawAxis); LipLeftNeutral = GetJointRotation(LipLeft, LipLeftAxis); LipRightNeutral = GetJointRotation(LipRight, LipRightAxis); EyebrowLeftNeutral = GetJointRotation(EyebrowLeft, EyebrowLeftAxis); EyebrowRightNeutral = GetJointRotation(EyebrowRight, EyebrowRightAxis); LipCornerLeftNeutral = GetJointRotation(LipCornerLeft, LipCornerLeftAxis); LipCornerRightNeutral = GetJointRotation(LipCornerRight, LipCornerRightAxis); UpperEyelidLeftNeutral = GetJointRotation(UpperEyelidLeft, UpperEyelidLeftAxis); UpperEyelidRightNeutral = GetJointRotation(UpperEyelidRight, UpperEyelidRightAxis); LowerEyelidLeftNeutral = GetJointRotation(LowerEyelidLeft, LowerEyelidLeftAxis); LowerEyelidRightNeutral = GetJointRotation(LowerEyelidRight, LowerEyelidRightAxis); KinectManager kinectManager = KinectManager.Instance; if (kinectManager && kinectManager.IsInitialized()) { platform = kinectManager.GetSensorPlatform(); } }
void Start() { if (foregroundCamera == null) { // by default use the main camera foregroundCamera = Camera.main; } manager = KinectManager.Instance; if (manager && manager.IsInitialized()) { KinectInterop.SensorData sensorData = manager.GetSensorData(); if (sensorData != null && sensorData.sensorInterface != null && foregroundCamera != null) { // sensor platform sensorPlatform = sensorData.sensorIntPlatform; // get depth image size depthImageWidth = sensorData.depthImageWidth; depthImageHeight = sensorData.depthImageHeight; // calculate the foreground rectangles Rect cameraRect = foregroundCamera.pixelRect; float rectHeight = cameraRect.height; float rectWidth = cameraRect.width; if (rectWidth > rectHeight) { rectWidth = rectHeight * depthImageWidth / depthImageHeight; } else { rectHeight = rectWidth * depthImageHeight / depthImageWidth; } float foregroundOfsX = (cameraRect.width - rectWidth) / 2; float foregroundOfsY = (cameraRect.height - rectHeight) / 2; foregroundImgRect = new Rect(foregroundOfsX, foregroundOfsY, rectWidth, rectHeight); // create joint colliders numColliders = sensorData.jointCount; jointColliders = new GameObject[numColliders]; for (int i = 0; i < numColliders; i++) { string sColObjectName = ((KinectInterop.JointType)i).ToString() + "Collider"; jointColliders[i] = new GameObject(sColObjectName); jointColliders[i].transform.parent = transform; if (i == 0) { // circle collider for body center CircleCollider2D collider = jointColliders[i].AddComponent <CircleCollider2D>(); collider.radius = colliderWidth; } else { // box colliders for bones BoxCollider2D collider = jointColliders[i].AddComponent <BoxCollider2D>(); collider.size = new Vector2(colliderWidth, colliderWidth); } } } } }
void Start() { if(HeadTransform != null) { HeadInitialPosition = HeadTransform.localPosition; //HeadInitialPosition.z = 0; HeadInitialRotation = HeadTransform.localRotation; } UpperLipLeftNeutral = GetJointRotation(UpperLipLeft, UpperLipLeftAxis); UpperLipRightNeutral = GetJointRotation(UpperLipRight, UpperLipRightAxis); JawNeutral = GetJointRotation(Jaw, JawAxis); LipLeftNeutral = GetJointRotation(LipLeft, LipLeftAxis); LipRightNeutral = GetJointRotation(LipRight, LipRightAxis); EyebrowLeftNeutral = GetJointRotation(EyebrowLeft, EyebrowLeftAxis); EyebrowRightNeutral = GetJointRotation(EyebrowRight, EyebrowRightAxis); LipCornerLeftNeutral = GetJointRotation(LipCornerLeft, LipCornerLeftAxis); LipCornerRightNeutral = GetJointRotation(LipCornerRight, LipCornerRightAxis); UpperEyelidLeftNeutral = GetJointRotation(UpperEyelidLeft, UpperEyelidLeftAxis); UpperEyelidRightNeutral = GetJointRotation(UpperEyelidRight, UpperEyelidRightAxis); LowerEyelidLeftNeutral = GetJointRotation(LowerEyelidLeft, LowerEyelidLeftAxis); LowerEyelidRightNeutral = GetJointRotation(LowerEyelidRight, LowerEyelidRightAxis); KinectManager kinectManager = KinectManager.Instance; if(kinectManager && kinectManager.IsInitialized()) { platform = kinectManager.GetSensorPlatform(); } }