Exemplo n.º 1
0
        /// <summary>
        /// Complete all relevant items in the given Intersection object.
        /// </summary>
        /// <param name="inter">Intersection instance to complete.</param>
        public override void CompleteIntersection(Intersection inter)
        {
            // !!!{{ TODO: add your actual completion code here

            // normal vector:
            if (inter.SolidData is TmpData)
            {
                TmpData tmp = (TmpData)inter.SolidData;

                if (Smooth && mesh.Normals > 0) // smooth interpolation of normal vectors
                {
                    int v1, v2, v3;
                    mesh.GetTriangleVertices(tmp.face, out v1, out v2, out v3);
                    tmp.normal  = mesh.GetNormal(v1) * (float)(1.0 - tmp.uv.X - tmp.uv.Y);
                    tmp.normal += mesh.GetNormal(v2) * (float)tmp.uv.X;
                    tmp.normal += mesh.GetNormal(v3) * (float)tmp.uv.Y;
                }

                Vector3d tu, tv;
                Vector3d normal = (Vector3d)tmp.normal;
                Geometry.GetAxes(ref normal, out tu, out tv);
                tu = Vector3d.TransformVector(tu, inter.LocalToWorld);
                tv = Vector3d.TransformVector(tv, inter.LocalToWorld);
                Vector3d.Cross(ref tu, ref tv, out inter.Normal);
            }

            // 2D texture coordinates (not yet):
            inter.TextureCoord.X     =
                inter.TextureCoord.Y = 0.0;

            // !!!}}
        }
Exemplo n.º 2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var window = new CreateNewPorfile();

            if (await window.ShowAsync() == ContentDialogResult.Primary)
            {
                if (window.Password == window.ConformPassword)
                {
                    if (!string.IsNullOrWhiteSpace(window.Password))
                    {
                        TmpData.Password = window.Password;
                        await TmpData.LoadKeeperAsync();

                        await TmpData.SaveKeeperAsync();

                        Frame.Navigate(typeof(MainPage));
                    }
                    else
                    {
                        await new MessageDialog(TmpData.loader.GetString("Passwordcannotbeempty")).ShowAsync();
                    }
                }
                else
                {
                    await new MessageDialog(TmpData.loader.GetString("Pleasekeepasswordsamewithconformpassword")).ShowAsync();
                }
            }
        }
Exemplo n.º 3
0
 private void byPopularity_Unchecked(object sender, RoutedEventArgs e)
 {
     Data.TmpData.StopLoading();
     _bypopular = false;
     list.Clear();
     TmpData.StopLoading();
     nexturl = null;
     MasterListView.ItemsSource = list;
     var result = firstLoadAsync();
 }
Exemplo n.º 4
0
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var fop = new FileOpenPicker();

            fop.FileTypeFilter.Add(".yfpwd");
            var file = await fop.PickSingleFileAsync();

            if (file != null)
            {
                await file.CopyAndReplaceAsync(await TmpData.GetPwdFileAsync());

                Frame.Navigate(typeof(PasswordInputPage));
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            pwdbox.IsEnabled    = false;
            unlockbtn.IsEnabled = false;
            ProgressBarVisualHelper.SetYFHelperVisibilityForBool(ring, true);
            try
            {
                TmpData.Password = pwdbox.Password;
                await TmpData.LoadKeeperAsync();

                this.Frame.Navigate(typeof(MainPage));
            }
            catch
            {
                await new MessageDialog(TmpData.loader.GetString("passwordnotok")).ShowAsync();
            }
            finally
            {
                ProgressBarVisualHelper.SetYFHelperVisibilityForBool(ring, false);
                unlockbtn.IsEnabled = true;
                pwdbox.IsEnabled    = true;
            }
        }
Exemplo n.º 6
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            savebtn.IsEnabled = false;
            try
            {
                var fsp = new FileSavePicker
                {
                    DefaultFileExtension = ".yfpwd"
                };
                fsp.FileTypeChoices.Add("yfpwd", new List <string> {
                    ".yfpwd"
                });
                var file = await fsp.PickSaveFileAsync();

                if (file != null)
                {
                    await(await TmpData.GetPwdFileAsync()).CopyAndReplaceAsync(file);
                }
            }
            finally
            {
                savebtn.IsEnabled = true;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Computes the complete intersection of the given ray with the object.
        /// </summary>
        /// <param name="p0">Ray origin.</param>
        /// <param name="p1">Ray direction vector.</param>
        /// <returns>Sorted list of intersection records.</returns>
        public override LinkedList <Intersection> Intersect(Vector3d p0, Vector3d p1)
        {
            // !!!{{ TODO: add your accelerated intersection code here

            if (mesh == null || mesh.Triangles < 1)
            {
                return(null);
            }

            List <Intersection> result = null;
            Intersection        i;

            for (int id = 0; id < mesh.Triangles; id++)
            {
                Vector3 a, b, c;
                mesh.GetTriangleVertices(id, out a, out b, out c);
                Vector2d uv;
                double   t = Geometry.RayTriangleIntersection(ref p0, ref p1, ref a, ref b, ref c, out uv);
                if (Double.IsInfinity(t))
                {
                    continue;
                }

                if (result == null)
                {
                    result = new List <Intersection>();
                }

                // Compile the 1st Intersection instance:
                i            = new Intersection(this);
                i.T          = t;
                i.Enter      =
                    i.Front  = true;
                i.CoordLocal = p0 + i.T * p1;

                // Tmp data object
                TmpData tmp = new TmpData();
                tmp.face = id;
                tmp.uv   = uv;
                Vector3 ba = b - a; // temporary value for flat shading
                Vector3 ca = c - a;
                Vector3.Cross(ref ba, ref ca, out tmp.normal);
                i.SolidData = tmp;

                result.Add(i);

                if (!ShellMode)
                {
                    continue;
                }

                // Compile the 2nd Intersection instance:
                i            = new Intersection(this);
                i.T          = t + 1.0e-4;
                i.Enter      =
                    i.Front  = false;
                i.CoordLocal = p0 + i.T * p1;

                // Tmp data object
                TmpData tmp2 = new TmpData();
                tmp2.face   = id;
                tmp2.uv     = uv;
                tmp2.normal = -tmp.normal;
                i.SolidData = tmp2;

                result.Add(i);
            }

            if (result == null)
            {
                return(null);
            }

            // Finalizing the result: sort the result list
            result.Sort();
            return(new LinkedList <Intersection>(result));

            // !!!}}
        }