Пример #1
0
 internal MainloopThread(IEnumerable <NotuiElement> workset, NotuiContext ctx, bool async = true)
 {
     Context = ctx;
     Workset = workset;
     if (async)
     {
         Task = Task.Factory.StartNew(HierarchicalExecution);
     }
 }
Пример #2
0
 /// <summary></summary>
 /// <param name="element">The hosting element</param>
 /// <param name="options">The creation option</param>
 public SubContext(NotuiElement element, SubContextOptions options)
 {
     AttachedElement        = element;
     Options                = options.Copy();
     element.OnMainLoopEnd += AttachedElementMainloopListener;
     Context                = new NotuiContext
     {
         UpdateOnlyChangeFlagged = Options.UpdateOnlyChangeFlagged
     };
 }
Пример #3
0
 /// <inheritdoc />
 public Touch(int id, NotuiContext context) : base(id)
 {
     OnMainLoopEnd += (sender, args) =>
     {
         if (Pressed)
         {
             FramesSincePressed++;
         }
         else
         {
             FramesSincePressed = 0;
         }
     };
     CustomAttachedObject = HittingElements;
     Context = context;
 }
Пример #4
0
        /// <summary>
        /// Get the previous world position of a touch
        /// </summary>
        /// <param name="touch">Touch in question</param>
        /// <param name="context">Context of the touch</param>
        /// <param name="popos">Previous world position</param>
        /// <param name="pdir">Previous ray direction</param>
        public static void GetPreviousWorldPosition(this TouchContainer touch, NotuiContext context, out Vector3 popos, out Vector3 pdir)
        {
            var prevpoint = touch.Point - touch.Velocity;

            Coordinates.GetPointWorldPosDir(prevpoint, context.ProjectionWithAspectRatioInverse, context.ViewInverse, out popos, out pdir);
        }
Пример #5
0
        /// <summary>
        /// Get the planar velocity of a touch and its current and previous intersection-point in the selected plane's space
        /// </summary>
        /// <param name="touch"></param>
        /// <param name="plane">Arbitrary matrix of the XY plane to do the intersection with</param>
        /// <param name="context">Notui context to provide screen space/alignment information</param>
        /// <param name="currpos">Current intersection point in the space of the plane</param>
        /// <param name="prevpos">Previous intersection point in the space of the plane</param>
        /// <returns>Velocity of the touch relative to the space of the plane</returns>
        public static Vector3 GetPlanarVelocity(this TouchContainer touch, Matrix4x4 plane, NotuiContext context, out Vector3 currpos, out Vector3 prevpos)
        {
            // get planar coords for current touch position
            var hit = Intersections.PlaneRay(touch.WorldPosition, touch.ViewDir, plane, out var capos, out var crpos);

            currpos = crpos;

            // get planar coords for the previous touch position
            touch.GetPreviousWorldPosition(context, out var popos, out var pdir);
            var phit = Intersections.PlaneRay(popos, pdir, plane, out var papos, out var prpos);

            prevpos = prpos;
            return(crpos - prpos);
        }
Пример #6
0
        /// <summary>
        /// Create a NotuiElement instance out of this prototype
        /// </summary>
        /// <param name="context">The context to instantiate into</param>
        /// <param name="parent">An optional parent</param>
        /// <returns></returns>
        public NotuiElement Instantiate(NotuiContext context, NotuiElement parent = null)
        {
            var res = (NotuiElement)GetElementConstructor().Invoke(new object[] { this, context, parent });

            return(res);
        }