Exemple #1
0
    // Use this for initialization
    void Start()
    {
        redSliderObject   = redSlider.GetComponent <Slider>();
        greenSliderObject = greenSlider.GetComponent <Slider>();
        blueSliderObject  = blueSlider.GetComponent <Slider>();

        //loadColorFile();

        skinnedGui = GetComponent <SkinnedGUIOptions>();



        redSlider.SetActive(false);
        greenSlider.SetActive(false);
        blueSlider.SetActive(false);

        smr = fbxGuy.GetComponent <SkinnedMeshRenderer>();

        m = smr.sharedMaterial;
        print("Mesh material is : " + m.name);
        //loadColorFile();

        //float r = m.color.r;



        redSliderObject.value   = m.color.r;
        greenSliderObject.value = m.color.g;
        blueSliderObject.value  = m.color.b;
    }
    public void addTrackingPoint(int indexVertice, int value)
    {
        //int indexVertice = 0;
        float   scaling          = fbxGuy.transform.localScale.x;
        Vector3 trackingPointPos = fbxMesh.vertices[indexVertice] * scaling + rootGuy.transform.position;

        GameObject newVertice = GameObject.Instantiate(pointCubeBigger);

        newVertice.transform.position = trackingPointPos;
        MeshRenderer      mrv        = newVertice.GetComponent <MeshRenderer>();
        SkinnedGUIOptions guiOptions = GetComponent <SkinnedGUIOptions>();

        mrv.material       = guiOptions.returnOpacityMaterial();
        mrv.material.color = guiOptions.getColorWithThisValue(value);
        //print("trackingPoint " + trackingPointPos);



        trackingPointsGameObjects.Add(newVertice);
        trackingIndexes.Add(indexVertice);
        trackingStrengths.Add(value);


        Transform cleaner = GameObject.Find("Cleaner").transform;

        newVertice.transform.parent = cleaner;
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        animator         = rootGuy.GetComponent <Animator>();
        animator.enabled = rigAnim;

        skinnedGui = GetComponent <SkinnedGUIOptions>();
    }
Exemple #4
0
    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"))
            {
            }
        }
    }
Exemple #5
0
 public void initMorphing()
 {
     faces       = new List <FaceState>();
     skinnedGUI  = GetComponent <SkinnedGUIOptions>();
     faceTracing = GetComponent <SkinnedFaceTracing>();
     Vector3[] currentFace = faceTracing.returnCurrentFace();
     //faces.Add(new FaceState(0, currentFace));
     distances = new Vector3[currentFace.Length];
 }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        skinnedGui    = GetComponent <SkinnedGUIOptions>();
        skinMaterial  = fbxGuy.GetComponent <SkinnedMeshRenderer>().sharedMaterial;
        xTilingSlider = xTiling.GetComponent <Slider>();
        yTilingSlider = yTiling.GetComponent <Slider>();

        xTilingSlider.value = skinMaterial.mainTextureScale.x;
        yTilingSlider.value = skinMaterial.mainTextureScale.y;
    }
Exemple #7
0
    public void switchOpacity(Material m, int arg)
    {
        SkinnedGUIOptions guiOptions = GetComponent <SkinnedGUIOptions>();

        for (int i = 0; i < trackingPoints.Count; i++)
        {
            MeshRenderer mr = trackingPoints[i].point.GetComponent <MeshRenderer>();
            mr.material = m;
            Color strengthColor = guiOptions.mixColor(trackingPoints[i].strength);
            mr.material.color = strengthColor;
        }
    }
Exemple #8
0
    // Use this for initialization
    void Start()
    {
        animNameInputField.SetActive(false);

        //string fileName = "faceName.txt";

        //string[] lines = System.IO.File.ReadAllLines(@"Assets\" + fileName);// dirty because Assets is inside Assets....<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        //print("set the lines[0]");

        //faceName = lines[0];

        //string[] faceLines = System.IO.File.ReadAllLines(lines[0]);// dirty because Assets is inside Assets....<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        //print(faceLines[0]);
        skinnedGui = GetComponent <SkinnedGUIOptions>();
    }
Exemple #9
0
    // Use this for initialization
    void Start()
    {
        vertexIndexes = new List <int>();
        meshVertices  = new List <Vector3>();
        faceTracing   = GetComponent <SkinnedFaceTracing>();
        smr           = fbxGuy.GetComponent <SkinnedMeshRenderer>();
        m             = smr.sharedMesh;

        for (int i = 0; i < m.vertices.Length; i++)
        {
            meshVertices.Add(m.vertices[i]);
        }

        guiOptions = GetComponent <SkinnedGUIOptions>();
        bakedAnimationController = GetComponent <BakedAnimationController>();
    }
Exemple #10
0
    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"))
            {
            }
        }
    }
Exemple #11
0
    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));
                }
            }
        }
    }
    // 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();
        }
    }
Exemple #13
0
    // 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);
        }
    }
Exemple #14
0
 // Use this for initialization
 void Start()
 {
     prevX      = Input.mousePosition.x;
     prevY      = Input.mousePosition.y;
     skinnedGui = GetComponent <SkinnedGUIOptions>();
 }
Exemple #15
0
    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();
            }
        }
    }
Exemple #16
0
 // Use this for initialization
 void Start()
 {
     skinnedGui = GetComponent <SkinnedGUIOptions>();
     cubeSizeSlider.SetActive(false);
 }
Exemple #17
0
 // Use this for initialization
 void Start()
 {
     //saveActive
     inputField.SetActive(false);
     skinnedGUI = GetComponent <SkinnedGUIOptions>();
 }
Exemple #18
0
 // Use this for initialization
 void Start()
 {
     skinnedGui = GetComponent <SkinnedGUIOptions>();
 }