void Update() { if (selModel != null) { if (Mathf.Abs(curVerticalOffset - verticalOffset) >= 0.001f) { // update v-offset curVerticalOffset = verticalOffset; AvatarController ac = selModel.GetComponent <AvatarController>(); if (ac != null) { ac.verticalOffset = verticalOffset; } } if (Mathf.Abs(curScaleFactor - (bodyScaleFactor + bodyWidthFactor + armScaleFactor + legScaleFactor)) >= 0.001f) { // update scale factors curScaleFactor = bodyScaleFactor + bodyWidthFactor + armScaleFactor + legScaleFactor; AvatarScaler scaler = selModel.GetComponent <AvatarScaler>(); if (scaler != null) { scaler.continuousScaling = continuousScaling; scaler.bodyScaleFactor = bodyScaleFactor; scaler.bodyWidthFactor = bodyWidthFactor; scaler.armScaleFactor = armScaleFactor; scaler.legScaleFactor = legScaleFactor; } } } }
// Token: 0x060000B5 RID: 181 RVA: 0x00009560 File Offset: 0x00007760 public void SetInfo() { AvatarController ac = this.selModel.GetComponent <AvatarController>(); bool flag = ac != null; if (flag) { ac.verticalOffset = this.CurInfo.Vertacal; ac.forwardOffset = this.CurInfo.Farward; } AvatarScaler scaler = this.selModel.GetComponent <AvatarScaler>(); bool flag2 = scaler != null; if (flag2) { scaler.bodyScaleFactor = this.CurInfo.BodyScale; scaler.legScaleFactor = this.CurInfo.LegScale; scaler.armScaleFactor = this.CurInfo.ArmScale; } ModelHatController mhc = this.selHat.GetComponent <ModelHatController>(); bool flag3 = mhc != null; if (flag3) { mhc.verticalOffset = this.CurInfo.HatHeight; } bool flag4 = FacetrackingManager.Instance != null; if (flag4) { //FacetrackingManager.Instance.Shifting = this.CurInfo.Shifting; //FacetrackingManager.Instance.modelMeshScale = this.CurInfo.HeadScale; } }
void Update() { // check for selection change if (activeSelector && selected >= 0 && selected < modelNames.Length && prevSelected != selected) { KinectManager kinectManager = KinectManager.Instance; if (kinectManager && kinectManager.IsInitialized() && kinectManager.IsUserDetected(playerIndex)) { OnDressingItemSelected(selected); } } if (selModel != null) { // update model settings as needed float curMuscleLimits = applyMuscleLimits ? 1f : 0f; float updModelOffset = horizontalOffset + verticalOffset + forwardOffset + curMuscleLimits; if (Mathf.Abs(curModelOffset - updModelOffset) >= 0.001f) { // update model offsets curModelOffset = updModelOffset; AvatarController ac = selModel.GetComponent <AvatarController>(); if (ac != null) { ac.horizontalOffset = horizontalOffset; ac.verticalOffset = verticalOffset; ac.forwardOffset = forwardOffset; ac.applyMuscleLimits = applyMuscleLimits; } } if (Mathf.Abs(curScaleFactor - (bodyScaleFactor + bodyWidthFactor + armScaleFactor + legScaleFactor)) >= 0.001f) { // update scale factors curScaleFactor = bodyScaleFactor + bodyWidthFactor + armScaleFactor + legScaleFactor; AvatarScaler scaler = selModel.GetComponent <AvatarScaler>(); if (scaler != null) { scaler.continuousScaling = continuousScaling; scaler.bodyScaleFactor = bodyScaleFactor; scaler.bodyWidthFactor = bodyWidthFactor; scaler.armScaleFactor = armScaleFactor; scaler.legScaleFactor = legScaleFactor; } } } }
private void ResizeClicked(float increment) { if (app.model.modelClothes.listClothes[app.model.modelData.playerIndex] != null) { AvatarScaler scaler = app.model.modelClothes.listClothes[app.model.modelData.playerIndex].GetComponent <AvatarScaler>(); if (scaler != null) { scaler.bodyScaleFactor += increment; scaler.bodyWidthFactor += increment; scaler.armScaleFactor += increment; scaler.legScaleFactor += increment; } } }
private void LoadModel(string modelDir) { string modelPath = "Clothing/" + modelDir + "/model"; UnityEngine.Object modelPrefab = Resources.Load(modelPath, typeof(GameObject)); if (modelPrefab == null) { return; } if (selModel != null) { GameObject.Destroy(selModel); } selModel = (GameObject)GameObject.Instantiate(modelPrefab); selModel.name = "Model" + modelDir; selModel.transform.position = Vector3.zero; selModel.transform.rotation = Quaternion.Euler(0, 180f, 0); AvatarController ac = selModel.AddComponent <AvatarController>(); ac.posRelativeToCamera = modelRelativeToCamera; ac.posRelOverlayColor = (foregroundCamera != null); ac.mirroredMovement = true; ac.verticalMovement = true; ac.smoothFactor = 0f; KinectManager km = KinectManager.Instance; ac.Awake(); if (km.IsUserDetected()) { ac.SuccessfulCalibration(km.GetPrimaryUserID()); } km.avatarControllers.Clear(); // = new List<AvatarController>(); km.avatarControllers.Add(ac); AvatarScaler scaler = selModel.AddComponent <AvatarScaler>(); scaler.mirroredAvatar = true; scaler.bodyScaleFactor = bodyScaleFactor; scaler.continuousScaling = continuousScaling; scaler.foregroundCamera = foregroundCamera; scaler.Start(); }
// Token: 0x060000AF RID: 175 RVA: 0x00009044 File Offset: 0x00007244 private void Update() { bool flag = this.activeSelector && this.selected >= 0 && this.selected < this.modelNames.Length && this.prevSelected != this.selected; if (flag) { KinectManager kinectManager = KinectManager.Instance; bool flag2 = kinectManager && kinectManager.IsInitialized() && kinectManager.IsUserDetected(this.playerIndex); if (flag2) { } } bool flag3 = this.selModel != null; if (flag3) { float curMuscleLimits = this.applyMuscleLimits ? 1f : 0f; bool flag4 = Mathf.Abs(this.curModelOffset - (this.verticalOffset + this.forwardOffset + curMuscleLimits)) >= 0.001f; if (flag4) { this.curModelOffset = this.verticalOffset + this.forwardOffset + curMuscleLimits; AvatarController ac = this.selModel.GetComponent <AvatarController>(); bool flag5 = ac != null; if (flag5) { ac.verticalOffset = this.verticalOffset; ac.forwardOffset = this.forwardOffset; ac.applyMuscleLimits = this.applyMuscleLimits; } } bool flag6 = Mathf.Abs(this.curScaleFactor - (this.bodyScaleFactor + this.bodyWidthFactor + this.armScaleFactor + this.legScaleFactor)) >= 0.001f; if (flag6) { this.curScaleFactor = this.bodyScaleFactor + this.bodyWidthFactor + this.armScaleFactor + this.legScaleFactor; AvatarScaler scaler = this.selModel.GetComponent <AvatarScaler>(); bool flag7 = scaler != null; if (flag7) { scaler.continuousScaling = this.continuousScaling; scaler.bodyScaleFactor = this.bodyScaleFactor; scaler.bodyWidthFactor = this.bodyWidthFactor; scaler.armScaleFactor = this.armScaleFactor; scaler.legScaleFactor = this.legScaleFactor; } } } }
void Update () { KinectManager manager = KinectManager.Instance; if(manager && manager.IsInitialized()) { if(backgroundImage && (backgroundImage.texture == null)) { backgroundImage.texture = manager.GetUsersClrTex(); } MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[]; foreach(MonoBehaviour monoScript in monoScripts) { if(typeof(AvatarScaler).IsAssignableFrom(monoScript.GetType())) { AvatarScaler scaler = (AvatarScaler)monoScript; int userIndex = scaler.playerIndex; long userId = manager.GetUserIdByIndex(userIndex); if(userId != scaler.currentUserId) { scaler.currentUserId = userId; if(userId != 0) { scaler.GetUserBodySize(true, true, true); scaler.FixJointsBeforeScale(); scaler.ScaleAvatar(0f); } } } } if(!manager.IsUserDetected()) { if(debugText != null) { debugText.GetComponent<GUIText>().text = "Please stand in T-pose for calibration."; } } } }
void Update() { KinectManager manager = KinectManager.Instance; if (manager && manager.IsInitialized()) { if (manager.autoHeightAngle == KinectManager.AutoHeightAngle.AutoUpdate || manager.autoHeightAngle == KinectManager.AutoHeightAngle.AutoUpdateAndShowInfo) { // update the cameras automatically, according to the current sensor height and angle KinectInterop.SensorData sensorData = manager.GetSensorData(); if (foregroundCamera != null && sensorData != null) { foregroundCamera.transform.position = new Vector3(sensorData.depthCameraOffset, manager.sensorHeight, 0f); foregroundCamera.transform.rotation = Quaternion.Euler(-manager.sensorAngle, 0f, 0f); } if (backgroundCamera != null && sensorData != null) { backgroundCamera.transform.position = new Vector3(0f, manager.sensorHeight, 0f); backgroundCamera.transform.rotation = Quaternion.Euler(-manager.sensorAngle, 0f, 0f); } } if (backgroundImage && (backgroundImage.texture == null)) { backgroundImage.texture = manager.GetUsersClrTex(); } MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[]; foreach (MonoBehaviour monoScript in monoScripts) { if (typeof(AvatarScaler).IsAssignableFrom(monoScript.GetType())) { AvatarScaler scaler = (AvatarScaler)monoScript; int userIndex = scaler.playerIndex; long userId = manager.GetUserIdByIndex(userIndex); if (userId != scaler.currentUserId) { scaler.currentUserId = userId; if (userId != 0) { scaler.GetUserBodySize(true, true, true); scaler.FixJointsBeforeScale(); scaler.ScaleAvatar(0f); } } } } if (!manager.IsUserDetected()) { if (debugText != null) { debugText.GetComponent <GUIText>().text = "Please stand in T-pose for calibration."; } } } }
// sets the selected dressing model as user avatar private void LoadDressingModel(string modelDir) { string modelPath = modelCategory + "/" + modelDir + "/model"; UnityEngine.Object modelPrefab = Resources.Load(modelPath, typeof(GameObject)); if (modelPrefab == null) { return; } Debug.Log("Model: " + modelPath); if (selModel != null) { GameObject.Destroy(selModel); } selModel = (GameObject)GameObject.Instantiate(modelPrefab, Vector3.zero, Quaternion.Euler(0, 180f, 0)); selModel.name = "Model" + modelDir; AvatarController ac = selModel.GetComponent <AvatarController>(); if (ac == null) { ac = selModel.AddComponent <AvatarController>(); ac.playerIndex = playerIndex; ac.mirroredMovement = true; ac.verticalMovement = true; ac.verticalOffset = verticalOffset; ac.forwardOffset = forwardOffset; ac.smoothFactor = 0f; } ac.posRelativeToCamera = modelRelativeToCamera; ac.posRelOverlayColor = (foregroundCamera != null); KinectManager km = KinectManager.Instance; //ac.Awake(); if (km && km.IsInitialized()) { long userId = km.GetUserIdByIndex(playerIndex); if (userId != 0) { ac.SuccessfulCalibration(userId); } // locate the available avatar controllers MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[]; km.avatarControllers.Clear(); foreach (MonoBehaviour monoScript in monoScripts) { if ((monoScript is AvatarController) && monoScript.enabled) { AvatarController avatar = (AvatarController)monoScript; km.avatarControllers.Add(avatar); } } } AvatarScaler scaler = selModel.GetComponent <AvatarScaler>(); if (scaler == null) { scaler = selModel.AddComponent <AvatarScaler>(); scaler.playerIndex = playerIndex; scaler.mirroredAvatar = true; scaler.continuousScaling = continuousScaling; scaler.bodyScaleFactor = bodyScaleFactor; scaler.bodyWidthFactor = bodyWidthFactor; scaler.armScaleFactor = armScaleFactor; scaler.legScaleFactor = legScaleFactor; } scaler.foregroundCamera = foregroundCamera; //scaler.debugText = debugText; //scaler.Start(); }
private void LoadModel(string modelDir) { string modelPath = modelCategory + "/" + modelDir + "/model"; UnityEngine.Object modelPrefab = Resources.Load(modelPath, typeof(GameObject)); if (modelPrefab == null) { return; } if (selModel != null) { GameObject.Destroy(selModel); } selModel = (GameObject)GameObject.Instantiate(modelPrefab, Vector3.zero, Quaternion.Euler(0, 180f, 0)); selModel.name = "Model" + modelDir; AvatarController ac = selModel.GetComponent <AvatarController>(); if (ac == null) { ac = selModel.AddComponent <AvatarController>(); ac.playerIndex = playerIndex; ac.mirroredMovement = true; ac.verticalMovement = true; ac.smoothFactor = 0f; } ac.posRelativeToCamera = modelRelativeToCamera; ac.posRelOverlayColor = (foregroundCamera != null); KinectManager km = KinectManager.Instance; //ac.Awake(); long userId = km.GetUserIdByIndex(playerIndex); if (userId != 0) { ac.SuccessfulCalibration(userId); } km.avatarControllers.Clear(); // = new List<AvatarController>(); km.avatarControllers.Add(ac); AvatarScaler scaler = selModel.GetComponent <AvatarScaler>(); if (scaler == null) { scaler = selModel.AddComponent <AvatarScaler>(); scaler.playerIndex = playerIndex; scaler.mirroredAvatar = true; scaler.bodyScaleFactor = bodyScaleFactor; scaler.continuousScaling = continuousScaling; } scaler.foregroundCamera = foregroundCamera; //scaler.debugText = debugText; //scaler.Start(); }
// Token: 0x060000B6 RID: 182 RVA: 0x00009660 File Offset: 0x00007860 private void LoadDressingModel(string modelDir, int select) { string modelPath = this.modelCategory + "/" + modelDir + "/model"; Object modelPrefab = Resources.Load(modelPath, typeof(GameObject)); bool flag = modelPrefab == null; if (!flag) { bool flag2 = this.selModel != null; if (flag2) { Object.Destroy(this.selModel); } for (int i = 0; i < this.modelHat.Length; i++) { bool flag3 = i == select; if (flag3) { this.selHat = this.modelHat[select]; } else { this.modelHat[i].SetActive(false); } } this.UserBodyBlender.ChangeBackGround(this.selected); this.selModel = (GameObject)Object.Instantiate(modelPrefab, Vector3.zero, Quaternion.Euler(0f, 180f, 0f)); this.selModel.name = "Model" + modelDir; ModelData data = this.selModel.GetComponent <ModelData>(); bool flag4 = data == null; if (flag4) { throw new UnityException("没有找到模型数据"); } this.CurInfo = GlobalSettings.GetRoleInfo(data.Name); bool flag5 = this.CurInfo == null; if (flag5) { throw new UnityException("没有找到角色数据,查找的角色是:" + data.Name); } this.editorModel.SetInfo(this.CurInfo); this.selHat.GetComponent <ModelHatController>().verticalOffset = this.CurInfo.HatHeight; bool flag6 = FacetrackingManager.Instance != null; if (flag6) { //FacetrackingManager.Instance.Shifting = this.CurInfo.Shifting; //FacetrackingManager.Instance.modelMeshScale = this.CurInfo.HeadScale; } AvatarController ac = this.selModel.GetComponent <AvatarController>(); bool flag7 = ac == null; if (flag7) { ac = this.selModel.AddComponent <AvatarController>(); ac.playerIndex = this.playerIndex; ac.mirroredMovement = true; ac.verticalMovement = true; ac.applyMuscleLimits = this.applyMuscleLimits; ac.verticalOffset = this.verticalOffset; ac.forwardOffset = this.forwardOffset; ac.smoothFactor = 0f; ac.verticalOffset = this.CurInfo.Vertacal; ac.forwardOffset = this.CurInfo.Farward; ac.fingerOrientations = true; ac.applyMuscleLimits = true; } ac.posRelativeToCamera = this.modelRelativeToCamera; ac.posRelOverlayColor = (this.foregroundCamera != null); KinectManager km = KinectManager.Instance; bool flag8 = km && km.IsInitialized(); if (flag8) { long userId = km.GetUserIdByIndex(this.playerIndex); bool flag9 = userId != 0L; if (flag9) { ac.SuccessfulCalibration(userId, false); } MonoBehaviour[] monoScripts = Object.FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[]; km.avatarControllers.Clear(); foreach (MonoBehaviour monoScript in monoScripts) { bool flag10 = monoScript is AvatarController && monoScript.enabled; if (flag10) { AvatarController avatar = (AvatarController)monoScript; km.avatarControllers.Add(avatar); } } } AvatarScaler scaler = this.selModel.GetComponent <AvatarScaler>(); bool flag11 = scaler == null; if (flag11) { scaler = this.selModel.AddComponent <AvatarScaler>(); scaler.playerIndex = this.playerIndex; scaler.mirroredAvatar = true; scaler.continuousScaling = this.continuousScaling; scaler.bodyScaleFactor = this.bodyScaleFactor; scaler.bodyWidthFactor = this.bodyWidthFactor; scaler.armScaleFactor = this.armScaleFactor; scaler.legScaleFactor = this.legScaleFactor; scaler.bodyScaleFactor = this.CurInfo.BodyScale; scaler.legScaleFactor = this.CurInfo.LegScale; scaler.armScaleFactor = this.CurInfo.ArmScale; } scaler.foregroundCamera = this.foregroundCamera; } }
void Update() { KinectManager manager = KinectManager.Instance; if (manager && manager.IsInitialized()) { long userId = manager.GetUserIdByIndex(playerIndex); if (userId != 0) { MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[]; foreach (MonoBehaviour monoScript in monoScripts) { // if(typeof(AvatarScaler).IsAssignableFrom(monoScript.GetType()) && // monoScript.enabled) if ((monoScript is AvatarScaler) && monoScript.enabled) { AvatarScaler scaler = (AvatarScaler)monoScript; if (scaler.scalerInited && scaler.playerIndex == playerIndex && scaler.currentUserId != userId) { scaler.currentUserId = userId; if (userId != 0) { scaler.GetUserBodySize(true, true, true); if (fixModelHipsAndShoulders) { scaler.FixJointsBeforeScale(); } scaler.ScaleAvatar(0f); } } } } if (lastUserId != userId) { if (infoText != null) { string sMessage = swipeToChangeModel && modelSelector ? "Swipe left or right to change clothing." : string.Empty; if (raiseHandToChangeCategory && allModelSelectors.Length > 1) { sMessage += " Raise hand to change category."; } infoText.text = sMessage; } lastUserId = userId; } } if (userId == 0 && userId != lastUserId) { lastUserId = userId; if (modelSelector) { modelSelector.DestroyCurrentModel(); } if (infoText != null) { infoText.text = "Please stand in T-pose for calibration."; } } } }
private void LoadClothes(string clothesName) { app.model.modelClothes.verticalOffset = 0; app.model.modelClothes.forwardOffset = 0; app.model.modelClothes.modelCategory = "Clothing"; string subPath = ChangeSubPath(); int playerIndex = app.model.modelData.playerIndex; string modelPath = app.model.modelClothes.modelCategory + "/" + subPath + "/" + clothesName; print(modelPath); UnityEngine.Object modelPrefab = Resources.Load(modelPath, typeof(GameObject)); if (modelPrefab == null) { return; } print(clothesName); Debug.Log("Model: " + modelPath); if (app.model.modelClothes.listClothes.Length >= app.model.modelData.kinectManager.GetUsersCount()) { if (app.model.modelClothes.listClothes[app.model.modelData.playerIndex]) { GameObject.Destroy(app.model.modelClothes.listClothes[app.model.modelData.playerIndex]); //app.model.modelClothes.selModels.RemoveAt(app.model.modelData.playerIndex); } } app.model.modelClothes.listClothes[app.model.modelData.playerIndex] = (GameObject)GameObject.Instantiate(modelPrefab, Vector3.zero, Quaternion.Euler(0, 180f, 0)); app.model.modelClothes.listClothes[app.model.modelData.playerIndex].name = "Model000" + playerIndex; //app.model.modelClothes.selModels.Add(app.model.modelClothes.selModel); //app.model.modelClothes.selModels[playerIndex] = (GameObject)GameObject.Instantiate(modelPrefab, Vector3.zero, Quaternion.Euler(0, 180f, 0)); //app.model.modelClothes.selModels[playerIndex].name = "Model000" + playerIndex; //app.model.modelClothes.selModel = (GameObject)GameObject.Instantiate(modelPrefab, Vector3.zero, Quaternion.Euler(0, 180f, 0)); ////app.model.modelClothes.selModel.name = "Model" + "0000"; AvatarController ac = app.model.modelClothes.listClothes[playerIndex].GetComponent <AvatarController>(); if (ac == null) { ac = app.model.modelClothes.listClothes[playerIndex].AddComponent <AvatarController>(); ac.playerIndex = playerIndex; ac.mirroredMovement = true; ac.verticalMovement = true; ac.verticalOffset = app.model.modelClothes.verticalOffset; ac.forwardOffset = app.model.modelClothes.forwardOffset; ac.smoothFactor = 0f; } ac.posRelativeToCamera = app.model.modelData.backgroundCamera; ac.posRelOverlayColor = (app.model.modelData.foregroundCamera != null); KinectManager km = KinectManager.Instance; //ac.Awake(); if (km && km.IsInitialized()) { long userId = km.GetUserIdByIndex(playerIndex); if (userId != 0) { ac.SuccessfulCalibration(userId, false); } // locate the available avatar controllers MonoBehaviour[] monoScripts = FindObjectsOfType(typeof(MonoBehaviour)) as MonoBehaviour[]; km.avatarControllers.Clear(); foreach (MonoBehaviour monoScript in monoScripts) { if ((monoScript is AvatarController) && monoScript.enabled) { AvatarController avatar = (AvatarController)monoScript; km.avatarControllers.Add(avatar); } } } AvatarScaler scaler = app.model.modelClothes.listClothes[app.model.modelData.playerIndex].GetComponent <AvatarScaler>(); if (scaler == null) { scaler = app.model.modelClothes.listClothes[app.model.modelData.playerIndex].AddComponent <AvatarScaler>(); scaler.playerIndex = playerIndex; scaler.mirroredAvatar = true; scaler.continuousScaling = true; scaler.bodyScaleFactor = 1.1f; scaler.bodyWidthFactor = 1.1f; scaler.armScaleFactor = 1.1f; scaler.legScaleFactor = 1.1f; } scaler.foregroundCamera = app.model.modelData.foregroundCamera; }