예제 #1
0
        /// <summary>
        /// Draws the element as a GUI using EditorGUILayout calls. This should return a copy of the
        /// Operation with the modified data. This way we mirror how regular GUI calls work.
        /// </summary>
        /// <param name = "guiOptions">Options to use when drawing the operation GUI.</param>
        /// <returns>A ListButtonEvent indicating if a button was clicked.</returns>
        public ListButtonEvent DrawGUI(GUIOptions guiOptions)
        {
            var operationStyle = new GUIStyle("ScriptText");

            operationStyle.stretchHeight = false;
            operationStyle.padding       = new RectOffset(6, 6, 4, 4);
            Rect            operationRect = EditorGUILayout.BeginVertical(operationStyle);
            ListButtonEvent buttonEvent   = this.DrawHeaderAndReorderButtons(
                this.HeadingLabel,
                guiOptions.DisableUpButton,
                guiOptions.DisableDownButton);

            EditorGUI.indentLevel++;
            this.DrawContents(guiOptions.ControlPrefix);
            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();

            var coloredHighlightRect = new Rect(operationRect);

            coloredHighlightRect.yMin += 2.0f;
            coloredHighlightRect.yMax -= 1.0f;
            coloredHighlightRect.xMin += 2.0f;
            coloredHighlightRect.width = 3.0f;
            var oldColor = GUI.color;

            GUI.color = this.HighlightColor;
            GUI.DrawTexture(coloredHighlightRect, Texture2D.whiteTexture);
            GUI.color = oldColor;

            return(buttonEvent);
        }
예제 #2
0
    public void switchOpacity(Material m, int arg)
    {
        GUIOptions guiOptions = GetComponent <GUIOptions>();

        for (int i = 0; i < trackingPointsGameObjects.Count; i++)
        {
            MeshRenderer mr = trackingPointsGameObjects[i].GetComponent <MeshRenderer>();
            mr.material = m;
            Color strengthColor = guiOptions.mixColor(trackingStrengths[i]);
            mr.material.color = strengthColor;
        }
    }
예제 #3
0
    //Vector3 trackingCenter;


    // Use this for initialization
    void Start()
    {
        vertexIndexes = new List <int>();
        faceTracing   = GetComponent <FaceTracing>();

        // StartAnimation();
        MeshFilter mr = guy.GetComponent <MeshFilter>();

        m = mr.mesh;

        //vertexIndexes = faceTracing.returnVertexIndexes();
        meshVertices = new List <Vector3>();

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


        guiOptions = GetComponent <GUIOptions>();
    }
예제 #4
0
    public void addTrackingPoint(int indexVertice, int value)
    {
        //int indexVertice = 0;
        Vector3 trackingPointPos = m.vertices[indexVertice] + rootGuy.transform.position;

        GameObject newVertice = GameObject.Instantiate(pointCubeBigger);

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

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


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

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

        newVertice.transform.parent = cleaner;
    }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        // Debug.DrawRay(transform.position, worldPos - transform.position, Color.green);

        // linkToTrackingPosition();
        GUIOptions guiOptions = GetComponent <GUIOptions>();


        if (Input.GetMouseButtonDown(0) && guiOptions.returnEditable())
        {
            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);
                    Vector3 vertexPos      = vertices[closestVertice] + rootGuy.transform.position;

                    GameObject newVertice = GameObject.Instantiate(vertice);
                    newVertice.transform.position = vertexPos;
                    MeshRenderer mrv = newVertice.GetComponent <MeshRenderer>();
                    mrv.material       = guiOptions.returnOpacityMaterial();
                    mrv.material.color = guiOptions.returnPowerColor();

                    trackingPoints.Add(newVertice);
                    trackingIndexes.Add(closestVertice);
                    trackingStrengths.Add(guiOptions.returnPower());
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Delete))
        {
            removeTrackingPoints(false);
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            removeTrackingPoints(true);
        }


        if (Input.GetKeyDown(KeyCode.Y))
        {
            animate = !animate;
        }

        if (animate)
        {
        }
    }