예제 #1
0
        private void LeftGrab(Selector.ButtonType button, bool grabState)
        {
            if (button != Selector.ButtonType.Grip)
            {
                return;
            }

            initialDistance = Vector3.Distance(selectorLeft.transform.localPosition, selectorRight.transform.localPosition);

            leftGrabbing = grabState;

            if (leftGrabbing || rightGrabbing)
            {
                if (!rightGrabbing)
                {
                    worldSrt.Clear();
                }

                Srt cameraRig = new Srt(transform);

                SetLocalCursor();

                childSrt = cameraRig.Inverse() * worldSrt;
                childSrt = cursorSrt.Inverse() * childSrt;
            }
        }
예제 #2
0
        private void Update()
        {
            if (!leftGrabbing && !rightGrabbing)
            {
                return;
            }

            SetLocalCursor();

            Srt CameraRigSrt = new Srt(transform);

            worldSrt = CameraRigSrt * (cursorSrt * childSrt);

            // Convert childSrt through cameraRigSrt and cursorSrt to world space and save to a new local variable worldMovedSrt.
            // This is where the world would be if it actually could be moved!

            // Note: cameraRigSrt and worldMovedSrt are now siblings in world space.
            // Convert cameraRigSrt (this) frame to be a child of worldMovedSrt and save to cameraRigMovedSrt.
            // Note: This is where the cameraRig would be in worldMovedSrt space!

            Srt cameraRigMovedSrt = worldSrt.Inverse() * CameraRigSrt;

            // But we cannot actually move world space so we move cameraRig instead.
            // If we changed worldMovedSrt to identity cameraRigMovedSrt is just the new cameraRig transform in world (identity) space.
            // You don't have to actually change worldMovedSrt to identity... just set cameraRig (this) transform to cameraRigMovedSrt.

            this.transform.SetLocalSRT(cameraRigMovedSrt);

            // Note: Use the transform.SetLocalSrt( ... ) method to set cameraRig (this) frame to your result.
        }
예제 #3
0
    public Srt Inverse()
    {
        Srt retval = new Srt(this);

        retval.Invert();
        return(retval);
    }
예제 #4
0
        public IActionResult CreateSRT(IFormFile VideoFile, List <SelectListItem> categoryList)
        {
            List <string> selected = new List <string>();

            foreach (SelectListItem item in categoryList)
            {
                if (item.Selected)
                {
                    selected.Add(item.Text.ToString());
                }
            }


            string email         = HttpContext.Session.GetString("Mail");
            string userName      = _userService.getUserByKey(email).name;
            string directoryPath = _srtService.getDirPath(VideoFile, userName);

            string videoPath = _srtService.saveVideo(VideoFile, directoryPath);


            string fileId = Convert(VideoFile, directoryPath, videoPath);

            if (fileId == "")
            {
                ViewBag.fail            = true;
                ViewBag.isAuthenticated = true;

                ViewBag.hide = true;

                //return View(categoryList);
                return(RedirectToAction("CreateSRT", "Srt", new { isAuthenticated = true, ViewBag.fail, ViewBag.hide, ViewBag.data }));
            }
            else
            {
                //create מופע srt (לא במסד נתונים)
                Srt srt = new Srt();
                srt.name     = Path.GetFileNameWithoutExtension(VideoFile.FileName);
                srt.date     = DateTime.Now.ToString();
                srt.fileId   = fileId;
                ViewBag.fail = false;
                //save srt in json file
                _srtService.setCategory(selected, srt, dictionaryPath);

                //הוספת הקובץ לרשימת הקבצים של המשתמש
                _srtService.addSRTToUser(HttpContext.Session.GetString("Mail"), srt);

                ViewBag.isAuthenticated = true;

                ViewBag.hide = true;

                ViewBag.data = "success";
                //return View(categoryList);
                return(RedirectToAction("CreateSRT", "Srt", new { isAuthenticated = true, ViewBag.fail, ViewBag.hide, ViewBag.data }));
            }



            //return View();
        }
예제 #5
0
    static public Vector3 PointToChild(Vector3 sibling_pt, Srt sibling)
    {
        Vector3 position = sibling_pt - sibling.localPosition;

        position = Quaternion.Inverse(sibling.localRotation) * position;
        position = Vector3.Scale(position, InvertScale(sibling.localScale));
        return(position);
    }
예제 #6
0
    static public Vector3 PointToParent(Vector3 child_pt, Srt parent)
    {
        Vector3 position = Vector3.Scale(child_pt, parent.localScale);

        position  = parent.localRotation * position;
        position += parent.localPosition;
        return(position);
    }
예제 #7
0
    // A point is transformed to a child frame by reversing the position, then reversing the rotation
    // and then reversing scale.
    public static Vector3 InverseTransformPointLocal(this Transform A, Vector3 sibling_pt)
    {
        Vector3 position = sibling_pt - A.localPosition;

        position = Quaternion.Inverse(A.localRotation) * position;
        position = Vector3.Scale(position, Srt.ScaleInverse(A.localScale));
        return(position);
    }
예제 #8
0
 public override void FocusUpdate(Selector cursor)
 {
     if (isSelected)
     {
         Srt objectSrt = cursor.Cursor * offsetSrt;
         transform.position = objectSrt.localPosition;
         transform.rotation = objectSrt.localRotation;
     }
 }
예제 #9
0
    static public void SiblingToChild(Transform A, Srt sibling)
    {
        Quaternion inv_rot   = Quaternion.Inverse(sibling.localRotation);
        Vector3    inv_scale = InvertScale(sibling.localScale);

        A.localPosition -= sibling.localPosition;
        A.localPosition  = inv_rot * A.localPosition;
        A.localPosition  = Vector3.Scale(A.localPosition, inv_scale);

        A.localRotation = inv_rot * A.localRotation;
        A.localScale    = Vector3.Scale(A.localScale, inv_scale);
    }
예제 #10
0
    public void TransformUp(Srt sibling)
    {
        Quaternion inv_rot   = Quaternion.Inverse(sibling.localRotation);
        Vector3    inv_scale = InvertScale(sibling.localScale);

        localPosition -= sibling.localPosition;
        localPosition  = inv_rot * localPosition;
        localPosition  = Vector3.Scale(localPosition, inv_scale);

        localRotation = inv_rot * localRotation;
        localScale    = Vector3.Scale(localScale, inv_scale);
    }
예제 #11
0
        // The selctor sends vodgets with focus all button events.
        public override void Button(Selector selector, Selector.ButtonType button, bool state)
        {
            if (button != Selector.ButtonType.Trigger)
            {
                return;
            }

            if (currSelc != null && selector != currSelc)
            {
                return;
            }

            if (state == true)
            {
                // Hint: You will need to access the world cursor Srt at selector.Cursor
                // This component script is attached to the scaled cube primative.
                // Convert this.transform to a world space Srt that you then convert to be a child of the world cursor.
                // Save this child Srt as a class variable to be used during the focusUpdate.

                currSelc = selector;

                Child.localPosition = this.transform.position;
                Child.localRotation = this.transform.rotation;
                Child.localScale    = Vector3.one;

                Child = currSelc.Cursor.Inverse() * Child;

                // Don't allow the selector to find another client until the trigger is released.
                currSelc.GrabFocus(true);
                isGrabbing = true;

                if (gameObject.GetComponent <Color_Change>() != null)
                {
                    gameObject.GetComponent <Color_Change>().Change();
                }
            }
            else
            {
                // The trigger is released so free the selector to find other clients.

                if (currSelc != null)
                {
                    currSelc.GrabFocus(false);
                    isGrabbing = false;
                    currSelc   = null;

                    if (gameObject.GetComponent <Color_Change>() != null)
                    {
                        gameObject.GetComponent <Color_Change>().Change();
                    }
                }
            }
        }
예제 #12
0
 static public void RotateAboutSiblingPoint(Srt A, Vector3 pivot_pt, Quaternion dquat)
 {
     // If we created an Srt as a pivot frame converting frame to be a child would only change
     // the frames position.
     // Srt frame_pivot = ( pivot_pt, identity, 1f )
     // Srt frame_child = ( frame.localPosition - pivot_pt, frame.localRotation, frame.localScale )
     //
     // We then rotate frame_pivot by the users dquat.
     // frame_pivot = ( pivot_pt, dquat, 1f )
     //
     // Converting frame_child back to world through frame_pivot yeilds.
     A.localPosition = (dquat * (A.localPosition - pivot_pt)) + pivot_pt;
     A.localRotation = dquat * A.localRotation;
 }
예제 #13
0
        // The selector calls FocusUpdate every Update that a vodget has its focus.
        public override void FocusUpdate(Selector selector)
        {
            if (!isGrabbing)
            {
                return;
            }

            // Convert the child Srt that you saved at the moment the Trigger button was pressed back to a world Srt through the current world cursor Srt.
            // Set this.transform.position and rotation to the result.

            Srt Offset = currSelc.Cursor * Child;

            this.transform.position = Offset.localPosition;
            this.transform.rotation = Offset.localRotation;
        }
예제 #14
0
 public override void Button(Selector cursor, Selector.ButtonType button, bool state)
 {
     if (button == Selector.ButtonType.Trigger)
     {
         if (state)
         {
             Srt objectSrt = new Srt(transform.position, transform.rotation, transform.lossyScale);
             offsetSrt  = cursor.Cursor.Inverse() * objectSrt;
             isSelected = true;
         }
         else
         {
             isSelected = false;
         }
         cursor.GrabFocus(state);
     }
 }
예제 #15
0
    private void Update()
    {
        if (isLeftGripped || isRightGripped)
        {
            SetControllerSrt();
            Srt worldCameraFrame = controllerSrt * worldOffsetSrt;
            if (DollyMode)
            {
                Quaternion correction = Quaternion.FromToRotation(worldCameraFrame.localRotation * Vector3.up, Vector3.up);
                worldCameraFrame.localRotation = correction * worldCameraFrame.localRotation;
                worldCameraFrame.localPosition = correction * (worldCameraFrame.localPosition - controllerSrt.localPosition) + controllerSrt.localPosition;
            }
            worldSrt = worldCameraFrame.Inverse();

            transform.localPosition = worldSrt.localPosition;
            transform.localRotation = worldSrt.localRotation;
            transform.localScale    = worldSrt.localScale;
        }
    }
예제 #16
0
        void TextStructVClass()
        {
            var st1 = new Srt("Struct", 0);
            var cl1 = new Cls("Class", 0);

            print(st1);
            print(cl1);

            var st2 = st1;
            var cl2 = cl1;

            cl2.Value = 1;
            st2.Value = 1;

            print(st1 + " ?= " + st2);
            print(cl1 + " ?= " + cl2);

            // Passing structs into fucntions makes a copy, which is inherently more expensive
        }
예제 #17
0
        public void addSRTToUser(string email, Srt srt)
        {
            var userIn = _users.Find(u => u.email == email).SingleOrDefault();

            if (userIn.srtList != null)
            {
                userIn.srtList.Add(new Srt {
                    name = srt.name, date = srt.date, fileId = srt.fileId
                });
            }
            else
            {
                userIn.srtList = new List <Srt> {
                    new Srt {
                        name = srt.name, date = srt.date, fileId = srt.fileId
                    }
                }
            };

            _users.ReplaceOne(p => p.email == email, userIn);
        }
예제 #18
0
        public void setCategory(List <string> selected, Srt srt, string dictionaryPath)
        {
            // JSON string
            string json = File.ReadAllText(dictionaryPath);

            //convert JSON to object dynamic
            dynamic jsonObj = JsonConvert.DeserializeObject(json);


            foreach (var CategoryName in selected)
            {
                List <Srt> srts = jsonObj[CategoryName].ToObject <List <Srt> >();


                if (srts.Count > 0)
                {
                    srts.Add(new Srt {
                        name = srt.name, date = srt.date, fileId = srt.fileId
                    });
                }
                else
                {
                    srts = new List <Srt> {
                        new Srt {
                            name = srt.name, date = srt.date, fileId = srt.fileId
                        }
                    }
                };

                jsonObj[CategoryName] = JArray.FromObject(srts);//update json file
            }

            // serialize JSON directly to a file
            string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented);

            File.WriteAllText(dictionaryPath, output);//write after update json file
        }
예제 #19
0
        public override void DoUpdate(Selector selector)
        {
            if (selector == grabbing_selector)
            {
                SetCursor(selector);

                Rigidbody body = GetComponent <Rigidbody>();

                if (body == null)
                {
                    obj_world.Set(obj_child);
                    obj_world.TransformDown(cursor);
                    transform.position = obj_world.localPosition;
                    transform.rotation = obj_world.localRotation;
                }
                else
                {
                    obj_world.Set(transform.position, transform.rotation, transform.lossyScale);
                    Srt world_grab_loc = new Srt(grab_loc);
                    world_grab_loc.TransformDown(obj_world);

                    Vector3 ds = cursor.localPosition - world_grab_loc.localPosition;

//#if USE_VELOCITY
                    if (ds.magnitude > breaking_dist)
                    {
                        DoGrab(grabbing_selector, false);

                        if (dolly_mode && gameObject.GetComponent <RotationMover>() == null)
                        {
                            RotationMover mover = gameObject.AddComponent <RotationMover>();
                            mover.Set(yaw_mode, save_isKinematic);
                        }

                        return;
                    }

                    body.velocity = ds * velocity_scale;

                    Quaternion dq = cursor.localRotation * Quaternion.Inverse(world_grab_loc.localRotation);
                    float      angle;
                    Vector3    axis;
                    dq.ToAngleAxis(out angle, out axis);
                    body.angularVelocity = axis * angle;

                    //    body.velocity = Vector3.zero;
                    //    body.angularVelocity = Vector3.zero;
                    //    body.MovePosition(obj_world.localPosition);
                    //    body.MoveRotation(obj_world.localRotation);
//#else
//                    body.AddForceAtPosition(ds * velocity_scale, world_grab_loc.localPosition, ForceMode.Force);

//                    Quaternion dq = cursor.localRotation * Quaternion.Inverse(world_grab_loc.localRotation);
//                    float angle;
//                    Vector3 axis;
//                    dq.ToAngleAxis(out angle, out axis);
//                    body.angularVelocity = axis * angle;

//                    body.AddTorque(axis * angle * velocity_scale * 0.1f);
//#endif
                }
            }
        }
예제 #20
0
 public Srt(Srt s)
 {
     Set(s);
 }
예제 #21
0
 public void Set(Srt s)
 {
     localPosition = s.localPosition;
     localRotation = s.localRotation;
     localScale    = s.localScale;
 }
예제 #22
0
 // Transform a sibling scale to be a child of a transform.
 public static Vector3 InverseTransformScaleLocal(this Transform A, Vector3 sibling_scale)
 {
     return(Vector3.Scale(Srt.ScaleInverse(A.localScale), sibling_scale));
 }
예제 #23
0
 public void TransformDown(Srt parent)
 {
     localPosition = (parent.localRotation * Vector3.Scale(parent.localScale, localPosition)) + parent.localPosition;
     localRotation = parent.localRotation * localRotation;
     localScale    = Vector3.Scale(parent.localScale, localScale);
 }
예제 #24
0
 static public void SetLocalSRT(this Transform A, Srt from)
 {
     A.localPosition = from.localPosition;
     A.localRotation = from.localRotation;
     A.localScale    = from.localScale;
 }
예제 #25
0
    static public Srt Inverse(this Transform A)
    {
        Srt retval = new Srt(A);

        return(retval.Inverse());
    }
예제 #26
0
 static public void CopyLocal(Srt from, Srt to)
 {
     to.localPosition = from.localPosition;
     to.localRotation = from.localRotation;
     to.localScale    = from.localScale;
 }
예제 #27
0
 static public void ChildToSibling(Srt A, Transform parent)
 {
     A.localPosition = (parent.localRotation * Vector3.Scale(parent.localScale, A.localPosition)) + parent.localPosition;
     A.localRotation = parent.localRotation * A.localRotation;
     A.localScale    = Vector3.Scale(parent.localScale, A.localScale);
 }
예제 #28
0
 void Modify(ref Srt s, ref int val)
 {
     s.Value = val;
     val     = -1;
 }
예제 #29
0
 private void SetWorldOffsetSrt()
 {
     cameraRigSrt.Set(transform.position, transform.rotation, transform.localScale);
     worldOffsetSrt = controllerSrt.Inverse() * cameraRigSrt.Inverse();
 }
예제 #30
0
 void Generate(out Srt s, out string id)
 {
     id = "new_name " + _genCount;
     s  = new Srt(id, _genCount++);
 }