protected void Release()
        {
            this.graspedRigidbody.transform.parent = this.savedParentObj;

            this.graspedRigidbody.useGravity = true;
//			this.graspedRigidbody.isKinematic = false;

            GraspedObjectFixer graspedObjectFixer = this.graspedRigidbody.gameObject.GetComponent <GraspedObjectFixer>();

            graspedObjectFixer.enabled = false;
            Destroy(graspedObjectFixer);

            this.graspedRigidbody.constraints = RigidbodyConstraints.None;

            this.graspedRigidbody = null;
            this.savedParentObj   = null;

            this.SendGraspedObjectInfo(null);

            SIGVerseLogger.Info("Released the object");

            this.latestReleaseTime = Time.time;
        }
Esempio n. 2
0
        void Awake()
        {
            try
            {
                this.subviewCameras        = new Camera       [SubviewNum];
                this.subviewButtons        = new Button       [SubviewNum];
                this.subviewDropdowns      = new Dropdown     [SubviewNum];
                this.subviewRectTransforms = new RectTransform[SubviewNum];
                this.subviewRectSizes      = new Vector2      [SubviewNum];
                this.subviewRenderTextures = new RenderTexture[SubviewNum];
                this.subviewMaterials      = new Material     [SubviewNum];
                this.subviewImages         = new Image        [SubviewNum];
                this.subviewLastUpdateTime = new DateTime     [SubviewNum];

                this.unlitTexturShader = (Shader)Resources.Load(SIGVerseUtils.UnlitShaderResourcePath);

                // Initialize Subviews
                for (int i = 0; i < this.subviewPanels.Length; i++)
                {
                    this.subviewPanels[i].SetActive(false);

                    // Set subviews position (All panels are the same size)
                    RectTransform rectTransform = this.subviewPanels[i].GetComponent <RectTransform>();

                    float posX = Screen.width - DefaultPositionOffset - rectTransform.rect.width;
                    float posY = Screen.height - DefaultPositionOffset - i * rectTransform.rect.height;

                    if (posY - rectTransform.rect.height < 0)
                    {
                        posY = rectTransform.rect.height;
                    }

                    rectTransform.position = new Vector3(posX, posY, 0.0f);
                }

                this.cameraListLastUpdateTime = DateTime.MinValue;

                for (int i = 0; i < SubviewNum; i++)
                {
                    this.subviewCameras[i] = this.subviewPanels[i].GetComponentInChildren <Camera>();

                    this.subviewButtons[i]   = this.subviewObjects[i].GetComponentInChildren <Button>();
                    this.subviewDropdowns[i] = this.subviewObjects[i].GetComponentInChildren <Dropdown>();

                    Image[] subviewPanelImages = this.subviewPanels[i].GetComponentsInChildren <Image>().Where(image => this.subviewPanels[i] != image.gameObject).ToArray();

                    this.subviewRectTransforms[i] = subviewPanelImages[0].GetComponent <RectTransform>();

                    this.subviewImages[i] = subviewPanelImages[0].GetComponent <Image>();

                    this.subviewDropdowns[i].value = 0;

                    this.UpdateRenderTexture(i);

                    this.subviewImages[i].material = null;

                    this.subviewLastUpdateTime[i] = DateTime.MinValue;
                }

                this.OnActiveSceneChanged(SceneManager.GetActiveScene(), SceneManager.GetActiveScene());

                this.UpdateButtonStates();

                SceneManager.activeSceneChanged += OnActiveSceneChanged;
            }
            catch (Exception ex)
            {
                SIGVerseLogger.Error(ex.Message);
                SIGVerseLogger.Error(ex.StackTrace);
            }
        }
Esempio n. 3
0
        private void StartPlaying()
        {
            if (!File.Exists(inputFilePath.text))
            {
                SIGVerseLogger.Info("Input File NOT found.");
                return;
            }

            // File open
            StreamReader srMotionsDataReader = new StreamReader(inputFilePath.text);

            this.timeSeriesMotionsQue = new Queue <TimeSeriesMotionsData>();

            List <Transform> transformOrder = new List <Transform>();

            while (srMotionsDataReader.Peek() >= 0)
            {
                string lineStr = srMotionsDataReader.ReadLine();

                string[] columnArray = lineStr.Split(new char[] { '\t' }, 2);

                if (columnArray.Length < 2)
                {
                    continue;
                }

                string headerStr = columnArray[0];
                string dataStr   = columnArray[1];

                string[] headerArray = headerStr.Split(',');

                // Motion data
                if (headerArray[1] == DataType1Motion)
                {
                    string[] dataArray = dataStr.Split('\t');

                    // Definition
                    if (headerArray[2] == DataType2MotionDefinition)
                    {
                        transformOrder.Clear();

                        Debug.Log("data num=" + dataArray.Length);

                        foreach (string transformPath in dataArray)
                        {
                            transformOrder.Add(GameObject.Find(transformPath).transform);
                        }
                    }
                    // Value
                    else if (headerArray[2] == DataType2MotionValue)
                    {
                        if (transformOrder.Count == 0)
                        {
                            continue;
                        }

                        TimeSeriesMotionsData timeSeriesMotionsData = new TimeSeriesMotionsData();

                        timeSeriesMotionsData.ElapsedTime = float.Parse(headerArray[0]);

                        for (int i = 0; i < dataArray.Length; i++)
                        {
                            string[] transformValues = dataArray[i].Split(',');

                            GameObjUpdateData transform = new GameObjUpdateData();
                            transform.SetUpdatingTargetTransform(transformOrder[i]);

                            transform.SetPostion(new Vector3(float.Parse(transformValues[0]), float.Parse(transformValues[1]), float.Parse(transformValues[2])));
                            transform.SetRotation(new Vector3(float.Parse(transformValues[3]), float.Parse(transformValues[4]), float.Parse(transformValues[5])));

                            if (transformValues.Length == 6)
                            {
                                transform.SetScale(Vector3.one);
                            }
                            else if (transformValues.Length == 9)
                            {
                                transform.SetScale(new Vector3(float.Parse(transformValues[6]), float.Parse(transformValues[7]), float.Parse(transformValues[8])));
                            }

                            timeSeriesMotionsData.AddGameObjUpdateData(transform);
                        }

                        this.timeSeriesMotionsQue.Enqueue(timeSeriesMotionsData);
                    }
                }
            }

            srMotionsDataReader.Close();

            // Change Buttons
            this.playButtonText.text       = ButtonTextStop;
            this.recordButton.interactable = false;

            // Disable Animator
            foreach (GameObject targetObj in targetObjects)
            {
                // Disable only one animator component
                targetObj.transform.GetComponent <Animator>().enabled = false;
            }

            // Reset elapsed time
            this.elapsedTime          = 0.0f;
            this.previousRecordedTime = 0.0f;

            this.isPlaying = true;
        }