private void Awake()
        {
            this.targetObjects      = this.GetComponent <PlaybackerCommon>().targetObjects;
            this.changeModeDropdown = this.GetComponent <PlaybackerCommon>().changeModeDropdown;
            this.resetObjectsButton = this.GetComponent <PlaybackerCommon>().resetObjectsButton;

            this.playButtonText = this.playButton.GetComponentInChildren <Text>();

            this.inputFilePathInputField = this.textSettings.GetComponentInChildren <InputField>();

            this.uniqueIdInputField  = this.databaseSettings.transform.Find("UniqueIdInputField").GetComponent <InputField>();
            this.mysqlIpInputField   = this.databaseSettings.transform.Find("IpInputField").GetComponent <InputField>();
            this.mysqlPortInputField = this.databaseSettings.transform.Find("PortInputField").GetComponent <InputField>();
            this.mysqlUserInputField = this.databaseSettings.transform.Find("UserInputField").GetComponent <InputField>();
            this.mysqlPassInputField = this.databaseSettings.transform.Find("PassInputField").GetComponent <InputField>();

            this.ChangeModeDropdownValueChanged(this.changeModeDropdown);

            foreach (GameObject targetObj in targetObjects)
            {
                Transform[] transforms = targetObj.transform.GetComponentsInChildren <Transform>(true);

                foreach (Transform transform in transforms)
                {
                    this.targetObjectsPathMap.Add(SIGVerseUtils.GetHierarchyPath(transform), transform);
                }
            }
        }
Пример #2
0
        //録画データのヘッダーを作成
        private void CreatePlaybackMotionDefinition()
        {
            //動作データのヘッダー
            this.savedMotionDefinitionString += "0.0," + CookingSupportPlaybackCommon.TypeDefMotion;

            List <string> linkPathMotionList = new List <string>();

            foreach (Transform transform in this.targetTransformInstances)
            {
                string linkPath = SIGVerseUtils.GetHierarchyPath(transform);

                this.savedMotionDefinitionString += "\t" + linkPath;

                if (linkPathMotionList.Contains(linkPath))
                {
                    Debug.LogError("Objects in the same path exist. path = " + linkPath);
                    throw new Exception("Objects in the same path exist.");
                }

                linkPathMotionList.Add(linkPath);
            }

            //接触している物体のヘッダー
            this.targetNames.Clear();
            foreach (GameObject obj in this.playbackCommon.GetTargetObjects())
            {
                this.targetNames.Add(obj.name);
            }

            this.savedCollidingDefinitionString = string.Join("\t", this.targetNames);
        }
Пример #3
0
        public PlaybackTransformEventController(string filePath)
        {
            this.targetTransforms = new List <Transform>();

            foreach (GameObject rootObj in SceneManager.GetActiveScene().GetRootGameObjects())
            {
                if (!rootObj.activeInHierarchy)
                {
                    continue;
                }

                this.targetTransforms.AddRange(rootObj.GetComponentsInChildren <Transform>(true));
            }

            this.targetTransformPathMap = new Dictionary <string, Transform>();

            foreach (Transform targetTransform in this.targetTransforms)
            {
                if (this.targetTransformPathMap.ContainsKey(SIGVerseUtils.GetHierarchyPath(targetTransform)))
                {
                    //Debug.Log("Already exist: " + SIGVerseUtils.GetHierarchyPath(targetTransform));
                }
                else
                {
                    this.targetTransformPathMap.Add(SIGVerseUtils.GetHierarchyPath(targetTransform), targetTransform);
                }
            }

            this.IsRigidbodiesDisable = true;
            this.IsCollidersDisable   = true;
        }
        void Start()
        {
            this.placedRigidbodyMap = new Dictionary <Rigidbody, int>();

            if (this.transform.GetComponents <Collider>().Length == 0)
            {
                SIGVerseLogger.Error("No Colliders on " + SIGVerseUtils.GetHierarchyPath(this.transform));
                throw new Exception("No Colliders on " + SIGVerseUtils.GetHierarchyPath(this.transform));
            }
        }
Пример #5
0
        private static void CheckExistanceOfColliders(Transform transform)
        {
            Collider[] colliders = transform.GetComponents <Collider>();

            if (colliders.Length == 0)
            {
                SIGVerseLogger.Error("No Colliders on " + SIGVerseUtils.GetHierarchyPath(transform));
                throw new Exception("No Colliders on " + SIGVerseUtils.GetHierarchyPath(transform));
            }
        }
        public static string GetDefinitionLine(List <VideoPlayer> targetVideoPlayers)
        {
            string definitionLine = "0.0," + WorldPlaybackCommon.DataType1VideoPlayer + "," + WorldPlaybackCommon.DataType2VideoPlayerDef;             // Elapsed time is dummy.

            foreach (VideoPlayer targetVideoPlayer in targetVideoPlayers)
            {
                // Make a header line
                definitionLine += "\t" + SIGVerseUtils.GetHierarchyPath(targetVideoPlayer.transform);
            }

            return(definitionLine);
        }
Пример #7
0
        public static string GetDefinitionLine(List <Transform> targetTransforms)
        {
            string definitionLine = "0.0," + WorldPlaybackCommon.DataType1Transform + "," + WorldPlaybackCommon.DataType2TransformDef;             // Elapsed time is dummy.

            foreach (Transform targetTransform in targetTransforms)
            {
                // Make a header line
                definitionLine += "\t" + SIGVerseUtils.GetHierarchyPath(targetTransform);
            }

            return(definitionLine);
        }
        public PlaybackVideoPlayerEventController(WorldPlaybackCommon playbackCommon)
        {
            this.common = playbackCommon;

            // Video Player
            this.targetVideoPlayers = this.common.GetTargetVideoPlayers();

            this.targetVideoPlayerPathMap = new Dictionary <string, VideoPlayer>();

            foreach (VideoPlayer targetVideoPlayer in this.targetVideoPlayers)
            {
                this.targetVideoPlayerPathMap.Add(SIGVerseUtils.GetHierarchyPath(targetVideoPlayer.transform), targetVideoPlayer);
            }
        }
        protected static string GetDataLine(string elapsedTime, Collision collision, float collisionVelocity, float effectScale, string dataType)
        {
            Vector3 contactAve = SIGVerseUtils.CalcContactAveragePoint(collision);

            string dataLine = elapsedTime + "," + dataType;

            dataLine += "\t" + contactAve.x + "\t" + contactAve.y + "\t" + contactAve.z + "\t" + effectScale;

            // Following data is unused now
            dataLine += "\t" + collisionVelocity +
                        "\t" + SIGVerseUtils.GetHierarchyPath(collision.contacts[0].thisCollider.transform) +
                        "\t" + SIGVerseUtils.GetHierarchyPath(collision.contacts[0].otherCollider.transform);

            return(dataLine);
        }
Пример #10
0
        //対象物体のパスとトランスフォームのマップを作成
        private void SetTargetObjectPathTranformMap()
        {
            this.targetPathTransformMap.Clear();

            //アバタの各部位
            foreach (Transform transform in this.instructor.GetComponentsInChildren <Transform>())
            {
                this.targetPathTransformMap.Add(SIGVerseUtils.GetHierarchyPath(transform), transform);
            }

            //対象物体
            foreach (GameObject targetObj in this.playbackCommon.GetTargetObjects())
            {
                this.targetPathTransformMap.Add(SIGVerseUtils.GetHierarchyPath(targetObj.transform), targetObj.transform);
            }
        }
Пример #11
0
        public PlaybackTransformEventController(WorldPlaybackCommon playbackCommon)
        {
            this.common = playbackCommon;

            // Transform
            this.targetTransforms = this.common.GetTargetTransforms();

            this.targetTransformPathMap = new Dictionary <string, Transform>();

            foreach (Transform targetTransform in this.targetTransforms)
            {
                this.targetTransformPathMap.Add(SIGVerseUtils.GetHierarchyPath(targetTransform), targetTransform);
            }

            this.IsRigidbodiesDisable = true;
            this.IsCollidersDisable   = true;
        }
Пример #12
0
        //録画を行う対象物体を格納
        private void SetTargetTransforms()
        {
            this.targetTransformInstances.Clear();

            //アバタの各部位
            foreach (Transform avatarTransform in this.playbackCommon.GetAvatar().GetComponentsInChildren <Transform>())
            {
                if (!this.ignoringKeywords.Exists(x => SIGVerseUtils.GetHierarchyPath(avatarTransform).Contains(x)))
                {
                    this.targetTransformInstances.Add(avatarTransform);
                }
            }

            //対象物体
            foreach (GameObject graspingCandidate in this.playbackCommon.GetTargetObjects())
            {
                this.targetTransformInstances.Add(graspingCandidate.transform);
            }
        }
Пример #13
0
        public void scoreCollision(GameObject obj, Collision collision)
        {
            if (recordScore && collision.relativeVelocity.magnitude > scoreThreshold)
            {
                //Arm-Obstacle
                String colPathArm = SIGVerseUtils.GetHierarchyPath(collision.collider.transform);
                bool   colArm     = colPathArm.Contains("arm_lift_link");
                if (colArm)
                {
                    //SIGVerseLogger.Info ("************************************************************************************************ ARM COLLISION  ************"  );
                    collisionA++;
                }
                //Obstacle-Obstacle
                bool colObs = collision.gameObject.CompareTag(TagObstacleCandidates);
                if (colObs)
                {
                    //SIGVerseLogger.Info ("************************************************************************************************ OBSTACLE COLLISION  ************"  );
                    collisionO++;
                }

                //Target-Obstacle
                bool colTar = collision.gameObject.CompareTag(TagGraspingCandidates);
                if (colTar)
                {
                    //SIGVerseLogger.Info ("************************************************************************************************ TARGET COLLISION  ************"  );
                    collisionT++;
                }
                //Furniture-Obstacle
                String colPathFur = SIGVerseUtils.GetHierarchyPath(collision.collider.transform);
                bool   colFur     = colPathFur.Contains("Tables");
                if (colFur)
                {
                    //SIGVerseLogger.Info ("************************************************************************************************ FURNITURE COLLISION  ************"  );
                    collisionF++;
                }

                if (collision.relativeVelocity.magnitude > maxVel)
                {
                    maxVel = collision.relativeVelocity.magnitude;
                }
            }
        }
        private void ExecCollisionProcess(CollisionType collisionType, Collision collision)
        {
            SIGVerseLogger.Info("Object collision occurred. name=" + this.name + " Collided object=" + SIGVerseUtils.GetHierarchyPath(collision.collider.transform) + ", vel=" + collision.relativeVelocity);

            // Effect
            GameObject effect = MonoBehaviour.Instantiate(this.collisionEffect);

            Vector3 contactPoint = SIGVerseUtils.CalcContactAveragePoint(collision);

            effect.transform.position   = contactPoint;
            effect.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);

            Destroy(effect, 1.0f);

            // Sound
            if (this.objectCollisionAudioSource != null)
            {
                this.objectCollisionAudioSource.Play();
            }

            foreach (GameObject destination in this.destinations)
            {
                ExecuteEvents.Execute <ITransferredCollisionHandler>
                (
                    target: destination,
                    eventData: null,
                    functor: (reciever, eventData) => reciever.OnTransferredCollisionEnter(collisionType, collision, collision.relativeVelocity.magnitude, 0.1f)
                );
            }
        }
Пример #15
0
        private void StartRecording()
        {
            SIGVerseLogger.Info("Recorder : Initialise");

            this.DisableSettings();

            DateTime dateTime = DateTime.Now;

            this.targetTransformInstances = new List <Transform>();

            List <string> linkPathList = new List <string>();                   // It is for only duplication check

            // Make header line
            this.savedHeaderStrings = string.Empty;

            this.savedHeaderStrings += "0.0," + PlaybackerCommon.TypeDef;                     // Elapsed time is dummy.

            // Create targets transform list
            foreach (GameObject targetObj in targetObjects)
            {
                Transform[] transforms = targetObj.transform.GetComponentsInChildren <Transform>();

                foreach (Transform transform in transforms)
                {
                    // Save Transform instance list
                    this.targetTransformInstances.Add(transform);

                    string linkPath = SIGVerseUtils.GetHierarchyPath(transform);

                    // Make a header line
                    this.savedHeaderStrings += "\t" + linkPath;

                    // Duplication check
                    if (linkPathList.Contains(linkPath))
                    {
                        SIGVerseLogger.Error("Objects in the same path exist. path=" + linkPath);
                        throw new Exception("Objects in the same path exist.");
                    }

                    linkPathList.Add(linkPath);
                }
            }

            if (this.modeType == ModeType.TextRecorder)
            {
                this.InitializeText();
            }
            else
            {
#if SIGVERSE_MYSQL
                this.InitializeDatabase();
#endif
            }

            this.savedMotionStrings = new List <string>();

            // Change Buttons
            this.recordButtonText.text = PlaybackerCommon.ButtonTextStop;

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


            SIGVerseLogger.Info("Recorder : Recording start.");

            this.statusText.text = StatusTextRecording;

            this.isRecording = true;
        }
        private void ExecCollisionProcess(Collision collision)
        {
            float collisionVelocity = this.colliderVelocities[Array.IndexOf(this.colliders, collision.contacts[0].thisCollider)];

            SIGVerseLogger.Info("HSR Collision Detection! Time=" + Time.time + ", Collision Velocity=" + collisionVelocity +
                                ", Part=" + collision.contacts[0].thisCollider.name + ", Collided object=" + SIGVerseUtils.GetHierarchyPath(collision.collider.transform));

            // Effect
            GameObject effect = MonoBehaviour.Instantiate(this.collisionEffect);

            Vector3 contactPoint = SIGVerseUtils.CalcContactAveragePoint(collision);

            effect.transform.position   = contactPoint;
            effect.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);

            Destroy(effect, 1.0f);

            // Send the collision notification
            foreach (GameObject destination in this.collisionNotificationDestinations)
            {
                ExecuteEvents.Execute <IHSRCollisionHandler>
                (
                    target: destination,
                    eventData: null,
                    functor: (reciever, eventData) => reciever.OnHsrCollisionEnter(collision, collisionVelocity, 0.5f)
                );
            }

            this.collidedTime = Time.time;
        }
        void OnTriggerExit(Collider other)
        {
            if (other.isTrigger)
            {
                return;
            }

            if (other.attachedRigidbody == null)
            {
                return;
            }

            if (!this.rigidbodyMap.ContainsKey(other))
            {
                SIGVerseLogger.Warn("This Collider does not exist in the Dictionary. (" + this.GetType().FullName + ")  name=" + SIGVerseUtils.GetHierarchyPath(other.transform));
                return;
            }

            this.rigidbodyMap.Remove(other);

            if (this.triggerType == TriggerType.Exit && !this.rigidbodyMap.ContainsValue(other.attachedRigidbody))
            {
                ExecuteEvents.Execute <IFingerTriggerHandler>
                (
                    target: this.transform.root.gameObject,
                    eventData: null,
                    functor: (reciever, eventData) => reciever.OnTransferredTriggerExit(other.attachedRigidbody, this.fingerType)
                );
            }
        }
        void OnTriggerEnter(Collider other)
        {
            if (other.isTrigger)
            {
                return;
            }

            if (other.attachedRigidbody == null)
            {
                return;
            }

            if (this.rigidbodyMap.ContainsKey(other))
            {
                SIGVerseLogger.Warn("This Collider has already been added. (" + this.GetType().FullName + ")  name=" + SIGVerseUtils.GetHierarchyPath(other.transform));
                return;
            }


            if (this.triggerType == TriggerType.Entrance && !this.rigidbodyMap.ContainsValue(other.attachedRigidbody))
            {
                ExecuteEvents.Execute <IFingerTriggerHandler>
                (
                    target: this.transform.root.gameObject,
                    eventData: null,
                    functor: (reciever, eventData) => reciever.OnTransferredTriggerEnter(other.attachedRigidbody, this.fingerType)
                );
            }

            this.rigidbodyMap.Add(other, other.attachedRigidbody);
        }