void OnGUI() { int ww = 200; int sx = Screen.width - ww * 2; int sy = 60; int sw = ww; int sh = 30; int i = 0; SkinnedGUIOptions skinnedGUI = GetComponent <SkinnedGUIOptions>(); //WE LOAD MESH ONLY IN OBJECT MODE if (skinnedGUI.returnModeValue() == 0) { foreach (string fileName in filesNames) { if (GUI.Button(new Rect(sx, sy + i * sh, sw, sh), fileName)) { readFile(fileName); } i++; } if (GUI.Button(new Rect(sx, 0, 150, 60), "Load Mesh")) { } } }
// Update is called once per frame void Update() { float yMouth = yMouthSlider.GetComponent <Slider>().value; float zMouth = zMouthSlider.GetComponent <Slider>().value; float sawStrength = sawStrengthSlider.GetComponent <Slider>().value; // SI ON EST EN EDIT MODE OU EN BAKED ANIM , ON MODIFIE LE MESH if (guiOptions.returnModeValue() == 1) { calculModeling(yMouth, zMouth, sawStrength); } if (guiOptions.returnModeValue() == 3 && !bakedAnimationController.isPlaying) { calculModeling(yMouth, zMouth, sawStrength); } }
// Update is called once per frame void Update() { if (skinnedGui.returnModeValue() == 1 && enable) { Slider slider = cubeSizeSlider.GetComponent <Slider>(); float v = slider.value; int nbChild = childGroup.transform.childCount; for (int i = 0; i < nbChild; i++) { childGroup.transform.GetChild(i).localScale = new Vector3(v, v, v); } } if (skinnedGui.returnModeValue() != 1) { cubeSizeSlider.SetActive(false); } }
void prepare(string fileName) { loaded = true; // trackingExemple = trackingScreenshots[index]; preparedFileName = fileName; faceTracing.resetPreview(); trackingPoints = new List <TrackingPoint>(); string[] lines = System.IO.File.ReadAllLines(@"Assets\" + fileName);// dirty because Assets is inside Assets....<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< SkinnedGUIOptions skinnedGUI = GetComponent <SkinnedGUIOptions>(); //WE LOAD GROUP ONLY IN EDIT MODE OR IN BAKE MODE if (skinnedGUI.returnModeValue() == 1 || skinnedGUI.returnModeValue() == 3) { // Display the file contents by using a foreach loop. foreach (string line in lines) { string[] values = line.Split(' '); string input = values[0]; // Index Value int i; bool result = int.TryParse(input, out i); //Check If Input is Parsable if (result) { int index = int.Parse(values[0]); int value = int.Parse(values[1]); faceTracing.addPreviewPoint(index); trackingPoints.Add(new TrackingPoint(index, value)); } } } }
void OnGUI() { if (skinnedGui.returnModeValue() == 2) { if (GUI.Button(new Rect(0, 0, 100, 20), "RigAnim:" + rigAnim)) { rigAnim = !rigAnim; animator.enabled = rigAnim; //float normalizeScaling = fbxGuy.transform.localScale.x / newFbxGuy.transform.localScale.x; //rootGuy.transform.localScale *= normalizeScaling; } } }
void OnGUI() { float sw = 120; float sh = 50; if (skinnedGUI.returnModeValue() == 0) { if (GUI.Button(new Rect(Screen.width / 2 - sw / 2, Screen.height - sh, sw, sh), "SaveMeshState")) { fieldActive = !fieldActive; inputField.SetActive(fieldActive); } } }
void OnGUI() { // SKIN if (skinnedGui.returnModeValue() == 4) { float xTiling = xTilingSlider.value; float yTiling = yTilingSlider.value; //skinMaterial.SetTextureOffset("_MainTex",new Vector2(xTiling, yTiling) ); skinMaterial.SetTextureScale("_MainTex", new Vector2(xTiling, yTiling)); // skinMaterial.mainTextureOffset.y = yTilingSlider; float sw = 200; float sy = 20; for (int i = 0; i < skinTextures.Length; i++) { Rect r = new Rect(Screen.width - sw, sy, sw, sw); if (selected == i) { GUI.color = Color.yellow; } else { GUI.color = Color.white; } if (GUI.Button(r, "")) { selected = i; } GUI.DrawTexture(r, skinTextures[i]); sy += sw; } if (GUI.Button(new Rect(Screen.width - sw, 0, sw, 20), "Load Texture")) { //print("ok"); skinMaterial.mainTexture = skinTextures[selected]; } } }
void OnGUI() { int ww = 200; int sx = Screen.width - ww; int sy = 60; int sw = ww; int sh = 30; int i = 0; SkinnedGUIOptions skinnedGui = GetComponent <SkinnedGUIOptions>(); int guiMode = skinnedGui.returnModeValue(); // WE LOAD TRACKING IN EDIT MODE if (guiMode == 2) { foreach (string fileName in filesNames) { GUI.color = Color.white; if (i == selected) { GUI.color = Color.green; } if (GUI.Button(new Rect(sx, sy + i * sh, sw, sh), fileName)) { readFile(fileName); //prepare(i, fileName); selected = i; } i++; } if (GUI.Button(new Rect(sx, 0, 150, 60), "Load Anim")) { } } }
void OnGUI() { int modeValue = skinnedGui.returnModeValue(); if (modeValue == 2) { if (GUI.Button(new Rect(400, 10, 150, 40), "Save Anim File")) { saving = !saving; animNameInputField.SetActive(saving); } if (saving) { if (Input.GetKeyDown(KeyCode.Return)) { FaceMorpher morpher = GetComponent <FaceMorpher>(); List <string> faceNames = morpher.returnFaceNames(); List <int> frames = morpher.returnFrames(); List <string> lines = new List <string>(); lines.Add("" + morpher.nbFrames); for (int i = 0; i < faceNames.Count; i++) { string line = faceNames[i] + "_" + frames[i]; lines.Add(line); } InputField field = animNameInputField.GetComponent <InputField>(); string fileName = field.text; System.IO.File.WriteAllLines("Assets/AnimFiles/" + fileName + ".txt", lines.ToArray()); saving = false; animNameInputField.SetActive(saving); } } } }
void OnGUI() { if (skinnedGui.returnModeValue() == 4) { float redValue = redSliderObject.value; float greenValue = greenSliderObject.value; float blueValue = blueSliderObject.value; if (GUI.Button(new Rect(50, 600, 100, 30), "SetSkinColor")) { Color c = smr.sharedMaterial.color; string s = c.r + "_" + c.g + "_" + c.b; string[] lines = new string[1]; lines[0] = s; saveColorFile(lines); } Color skinColor = new Color(redValue, greenValue, blueValue); m.color = skinColor; } }
// Update is called once per frame void Update() { Debug.DrawRay(transform.position, worldPos - transform.position, Color.green); // linkToTrackingPosition(); SkinnedGUIOptions guiOptions = GetComponent <SkinnedGUIOptions>(); if (Input.GetMouseButtonDown(0) && guiOptions.returnModeValue() == 0) { Vector2 mousePos = Input.mousePosition; float fwd = 10; Vector3 mPos = new Vector3(mousePos.x, mousePos.y, fwd); worldPos = main.ScreenToWorldPoint(mPos); if (Physics.Raycast(transform.position, worldPos - transform.position, fwd)) { //print("There is something in front of the object!"); Debug.DrawRay(transform.position, worldPos); } RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider != null) { Vector3 hitPoint = hit.point; int closestVertice = indexClosestVertice(hitPoint); //vertexPos is the closest Vertice to collision point Vector3 fbxPos = vertices[closestVertice] + rootGuy.transform.position; // * SCALING GameObject newVertice = GameObject.Instantiate(vertice); //newVertice.transform.position = vertexPos; //print("closest Vertice "+closestVertice+" indexLinks Count"+indexLinks.Count); //Vector3 fbxPos = fbxMesh.vertices[indexVertice]; print(fbxGuy.transform.localScale.x); //newVertice.transform.position = fbxPos * fbxGuy.transform.localScale.x; newVertice.transform.position = fbxPos; MeshRenderer mrv = newVertice.GetComponent <MeshRenderer>(); mrv.material = guiOptions.returnOpacityMaterial(); mrv.material.color = guiOptions.returnPowerColor(); if (!trackingIndexesContains(indexLinks[closestVertice])) { trackingPointsGameObjects.Add(newVertice); //trackingIndexes.Add(closestVertice); trackingStrengths.Add(guiOptions.returnPower()); trackingIndexes.Add(indexLinks[closestVertice]); GameObject newHitPoint = GameObject.Instantiate(myHitPoint); newHitPoint.transform.position = hitPoint; } } } } if (Input.GetKeyDown(KeyCode.Delete)) { removeTrackingPoints(false); } if (Input.GetKeyDown(KeyCode.Z)) { removeTrackingPoints(true); //removeLastIndexLink(); } }
// Update is called once per frame void Update() { Debug.DrawRay(transform.position, worldPos - transform.position, Color.green); // linkToTrackingPosition(); SkinnedGUIOptions guiOptions = GetComponent <SkinnedGUIOptions>(); if (Input.GetMouseButtonDown(0) && guiOptions.returnModeValue() == 0) { Camera main = transform.GetComponent <Camera>(); Vector2 mousePos = Input.mousePosition; float fwd = 10; Vector3 mPos = new Vector3(mousePos.x, mousePos.y, fwd); worldPos = main.ScreenToWorldPoint(mPos); RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider != null) { Vector3 hitPoint = hit.point; int closestVertice = indexClosestVertice(hitPoint); Vector3 fbxPos = vertices[closestVertice] + rootGuy.transform.position; print("WE HIT ( index closest is " + closestVertice); if (!trackingIndexesContains(closestVertice)) { GameObject newVertice = GameObject.Instantiate(vertice); newVertice.transform.position = fbxPos; // MODIFIEE // trackingPoints.Add(new TrackingPoint(newVertice, indexLinks[closestVertice], guiOptions.returnPower())); trackingPoints.Add(new TrackingPoint(newVertice, closestVertice, guiOptions.returnPower())); GameObject newHitPoint = GameObject.Instantiate(myHitPoint); newHitPoint.transform.position = hitPoint; MeshRenderer mrv = newVertice.GetComponent <MeshRenderer>(); mrv.material = guiOptions.returnOpacityMaterial(); mrv.material.color = guiOptions.returnPowerColor(); } else { if (Input.GetKey(KeyCode.LeftShift)) { removeTrackingPoint(closestVertice); } } /* * } * else * { * * * * print("out"); * * GameObject newVertice = GameObject.Instantiate(vertice); * newVertice.transform.position = fbxPos;// MODIFIEE * * GameObject newHitPoint = GameObject.Instantiate(myHitPoint); * newHitPoint.transform.position = hitPoint; * * } * * */ } } } if (Input.GetKeyDown(KeyCode.Delete)) { removeTrackingPoints(false); } if (Input.GetKeyDown(KeyCode.Z)) { removeTrackingPoints(true); } }
void OnGUI() { int ww = 200; int sx = Screen.width - ww; int sy = 60; int sw = ww; int sh = 30; int i = 0; SkinnedGUIOptions skinnedGui = GetComponent <SkinnedGUIOptions>(); int guiMode = skinnedGui.returnModeValue(); // WE LOAD TRACKING IN EDIT MODE if (guiMode % 2 == 1) { float lX = Screen.width / 1.39f; float d = 0.7f; if (loaded) { //GUI.DrawTexture(new Rect(lX, 0, 400 * d, 600*d), trackingExemple); if (GUI.Button(new Rect(lX, 600 * d, 100, 30), "LoadTracking")) { readFile(preparedFileName); loaded = false; } if (GUI.Button(new Rect(lX + 120, 600 * d, 100, 30), "Cancel")) { //readFile(preparedFileName); loaded = false; selected = -1; } } foreach (string fileName in filesNames) { GUI.color = Color.white; if (i == selected) { GUI.color = Color.green; } if (GUI.Button(new Rect(sx, sy + i * sh, sw, sh), fileName)) { // readFile(fileName); prepare(fileName); selected = i; } i++; } GUI.color = Color.white; if (GUI.Button(new Rect(sx, 0, 150, 60), "Load Tracking Group")) { listFiles(); } } }