Пример #1
0
 public Face(FaceDatabase db, int v0, int v1, int v2)
 {
     this._db = db;
     this._v0 = v0;
     this._v1 = v1;
     this._v2 = v2;
     this._db.Add(this);
 }
Пример #2
0
 public Simplification(Vector3[] vertices, int[] triangles)
 {
     this.vertices    = vertices;
     this.triangles   = triangles;
     this.faceDb      = new FaceDatabase();
     this.vertexInfos = InitVertexInfos();
     this.costs       = InitCosts();
 }
Пример #3
0
    FaceDatabase m_faceDatabase;    // = new FaceDatabase();

    // Use this for initialization
    void Start()
    {
        Debug.Log("Start");
        textMeshes            = new TextMesh[2];
        textMeshComponentTags = new string[2];
        editButtons           = new KeyCode[2];

        textMeshComponentTags[0] = overheadTextId;
        textMeshComponentTags[1] = faceTextId;

        editButtons[0] = KeyCode.Return;
        editButtons[1] = KeyCode.LeftControl;

        TextMesh[] textMeshesInChildren = GetComponentsInChildren <TextMesh>();

        m_faceDatabase = GetComponent <FaceDatabase>();

        int tagCount = 0;

        foreach (string textMeshComponentTag in textMeshComponentTags)
        {
            foreach (TextMesh tm in textMeshesInChildren)
            {
                if (tm.name == textMeshComponentTag)
                {
                    textMeshes[tagCount++] = tm;
                    break;
                }
            }
        }

        //textMesh = GetComponentInChildren< TextMesh >();
        editing    = false;
        editCache  = false;
        changeEdit = false;
        isMe       = false;
        photonView = GetComponent <PhotonView>();
        flyScript  = GetComponent <fly1>();

        if (photonView.isMine)
        {
            foreach (TextMesh tm in textMeshes)
            {
                if (tm.name == "TextBoxFace")
                {
                    MeshRenderer renderer = tm.transform.GetComponent <MeshRenderer>();
                    renderer.enabled = false;
                }
            }
        }

        processBufferedEvents();
    }
Пример #4
0
        public void SaveBeforeClose()
        {
            if (string.IsNullOrWhiteSpace(SerializeFile))
            {
                return;
            }

            var dialogResult = MessageBox.Show("Do you wish to save database before exiting?", "Save database", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                using (var stream = File.OpenWrite(SerializeFile))
                {
                    FaceDatabase.Serialize(stream);
                }
            }
        }
Пример #5
0
        public string Save()
        {
            if (string.IsNullOrEmpty(SerializeFile))
            {
                return(SaveAs());
            }
            try
            {
                using (var fs = File.OpenWrite(SerializeFile))
                {
                    FaceDatabase.Serialize(fs);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(
                    $"Error: An error occured while saving the database to {SerializeFile}:{Environment.NewLine}{exc}");
            }

            return(SerializeFile);
        }
Пример #6
0
        public string SaveAs()
        {
            if (!Directory.Exists(_defaultSerializePath))
            {
                Directory.CreateDirectory(_defaultSerializePath);
            }

            var dialog = new SaveFileDialog
            {
                InitialDirectory = SerializeFile == null ? _defaultSerializePath : Path.GetDirectoryName(SerializeFile),
                DefaultExt       = "xml",
                Filter           = FileFilter
            };

            var result = dialog.STAShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    using (var fs = dialog.OpenFile())
                    {
                        FaceDatabase.Serialize(fs);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(
                        $"Error: An error occured while saving the database to {dialog.FileName}:{Environment.NewLine}{exc}");
                }

                SerializeFile = dialog.FileName;
            }

            return(SerializeFile);
        }
Пример #7
0
        public IFaceDatabase <T> Open()
        {
            var dialog = new OpenFileDialog
            {
                InitialDirectory = SerializeFile == null ? _defaultSerializePath : Path.GetDirectoryName(SerializeFile),
                DefaultExt       = "xml",
                Filter           = FileFilter,
                Title            = "Select file containing saved face database"
            };

            var result = dialog.STAShowDialog();
            // make a backup of the current database in case something goes wrong
            var backup = FaceDatabase.Backup();

            if (result == DialogResult.OK)
            {
                try
                {
                    using (var fs = dialog.OpenFile())
                    {
                        FaceDatabase.Deserialize(fs);
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(
                        $"Error: An error occured while loading the database from {dialog.FileName}: {Environment.NewLine}{exc}");
                    // something went wrong -> revert
                    FaceDatabase.Restore(backup);
                }
            }

            SerializeFile = dialog.FileName;

            return(FaceDatabase);
        }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        int pressedKey = -1;

        int keyArrayId = 0;

        foreach (KeyCode kc in editButtons)
        {
            if (Input.GetKeyUp(kc))
            {
                pressedKey = keyArrayId;
                break;
            }
            keyArrayId++;
        }

        if (pressedKey >= 0 && !editing && photonView.isMine)
        {
            editing = true;
            Camera camera = GetComponentInChildren <Camera>();
            //GameObject canvasObject = PhotonNetwork.Instantiate( "Canvas" , transform.position + 10 * transform.forward , transform.rotation , 0 );
            GameObject canvasObject = (GameObject)GameObject.Instantiate(Resources.Load("Canvas"), camera.transform.position + 10 * camera.transform.forward, camera.transform.rotation);

            InputFieldSync canvasSync = canvasObject.GetComponent <InputFieldSync>();
            //canvasSync.setTextMesh( textMesh );
            canvasSync.setTextChanger(this);
            canvasSync.setTextMeshId(pressedKey);


            UnityEngine.UI.InputField inputField = canvasObject.GetComponentInChildren <UnityEngine.UI.InputField>();
            inputField.text = textMeshes[pressedKey].text;
            if (textMeshComponentTags[pressedKey] == overheadTextId)
            {
                inputField.characterLimit = 140;
            }
            else if (textMeshComponentTags[pressedKey] == faceTextId)
            {
                inputField.characterLimit = 6;
            }
            inputField.lineType = InputField.LineType.MultiLineSubmit;
//			RectTransform inputFieldTransform = (RectTransform) inputField.transform;
//			inputFieldTransform.sizeDelta = new Vector2( 40 , 40 );
            inputField.Select();

            flyScript.setTranslationEnabled(false);

            currentInputField = inputField;
            currentEditId     = pressedKey;
        }

        int faceId = FaceDatabase.numberButtonPressed();

        if (editing && textMeshComponentTags[currentEditId] == faceTextId && faceId >= 0)
        {
            if (Input.GetKey(KeyCode.LeftAlt))
            {
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    m_faceDatabase.setFace(faceId, currentInputField.text);
                }
                else
                {
                    currentInputField.text = m_faceDatabase.getFace(faceId);
                }
            }
        }

        if (changeEdit && Time.time - editTime > 1.0f)
        {
            changeEdit = false;
            editing    = editCache;
        }
    }