WPF-3D动效-文字球形环绕

简介: 原文:WPF-3D动效-文字球形环绕 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013224722/article/details/81784443 费劲写了一个动效,却要被砍掉,心碎.
原文: WPF-3D动效-文字球形环绕

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013224722/article/details/81784443

费劲写了一个动效,却要被砍掉,心碎....


private List<Point3D> GetBuckyBallPoints()
        {
            List<Point3D> ltPoints = new List<Point3D>();
            ltPoints.Add(new Point3D(.850651, 0, 2.327438));
            ltPoints.Add(new Point3D(.262866, .809017, 2.327438));
            ltPoints.Add(new Point3D(-.688191, .5, 2.327438));
            ltPoints.Add(new Point3D(-.688191, -.5, 2.327438));
            ltPoints.Add(new Point3D(.262866, -.809017, 2.327438));

            ltPoints.Add(new Point3D(1.701301, 0, 1.801708));
            ltPoints.Add(new Point3D(.52573, 1.618035, 1.801708));
            ltPoints.Add(new Point3D(.52573, -1.618035, 1.801708));
            ltPoints.Add(new Point3D(-1.376383, -.999999, 1.801708));
            ltPoints.Add(new Point3D(-1.376383, .999999, 1.801708));

            ltPoints.Add(new Point3D(1.964166, .809017, 1.275977));
            ltPoints.Add(new Point3D(1.376381, 1.618035, 1.275977));
            ltPoints.Add(new Point3D(-.162461, 2.118035, 1.275977));
            ltPoints.Add(new Point3D(-1.113517, 1.809017, 1.275977));
            ltPoints.Add(new Point3D(-2.064574, .5, 1.275977));
            ltPoints.Add(new Point3D(-2.064574, -.5, 1.275977));
            ltPoints.Add(new Point3D(-1.113517, -1.809017, 1.275977));
            ltPoints.Add(new Point3D(-.162461, -2.118035, 1.275977));
            ltPoints.Add(new Point3D(1.376381, -1.618035, 1.275977));
            ltPoints.Add(new Point3D(1.964166, -.809017, 1.275977));

            ltPoints.Add(new Point3D(2.389492, .5, .425326));
            ltPoints.Add(new Point3D(1.213921, 2.118035, .425326));
            ltPoints.Add(new Point3D(.262865, 2.427051, .425326));
            ltPoints.Add(new Point3D(-1.639248, 1.809017, .425326));
            ltPoints.Add(new Point3D(-2.227033, .999999, .425326));
            ltPoints.Add(new Point3D(-2.227033, -.999999, .425326));
            ltPoints.Add(new Point3D(-1.639248, -1.809017, .425326));
            ltPoints.Add(new Point3D(.262865, -2.427051, .425326));
            ltPoints.Add(new Point3D(1.213921, -2.118035, .425326));
            ltPoints.Add(new Point3D(2.389492, -.5, .425326));

           ltPoints.Add(new Point3D(2.227033, .999999, -.425326));
           ltPoints.Add(new Point3D(1.639248, 1.809017, -.425326));
           ltPoints.Add(new Point3D(-.262865, 2.427051, -.425326));
           ltPoints.Add(new Point3D(-1.213921, 2.118035, -.425326));
           ltPoints.Add(new Point3D(-2.389492, .5, -.425326));
           ltPoints.Add(new Point3D(-2.389492, -.5, -.425326));
           ltPoints.Add(new Point3D(-1.213921, -2.118035, -.425326));
           ltPoints.Add(new Point3D(-.262865, -2.427051, -.425326));
           ltPoints.Add(new Point3D(1.639248, -1.809017, -.425326));
            ltPoints.Add(new Point3D(2.227033, -.999999, -.425326));

           ltPoints.Add(new Point3D(2.064574, .5, -1.275977));
           ltPoints.Add(new Point3D(1.113517, 1.809017, -1.275977));
           ltPoints.Add(new Point3D(.162461, 2.118035, -1.275977));
           ltPoints.Add(new Point3D(-1.376381, 1.618035, -1.275977));
           ltPoints.Add(new Point3D(-1.964166, .809017, -1.275977));
           ltPoints.Add(new Point3D(-1.964166, -.809017, -1.275977));
           ltPoints.Add(new Point3D(-1.376381, -1.618035, -1.275977));
           ltPoints.Add(new Point3D(.162461, -2.118035, -1.275977));
           ltPoints.Add(new Point3D(1.113517, -1.809017, -1.275977));
            ltPoints.Add(new Point3D(2.064574, -.5, -1.275977));

            ltPoints.Add(new Point3D(1.376383, .999999, -1.801708));
            ltPoints.Add(new Point3D(-.52573, 1.618035, -1.801708));
            ltPoints.Add(new Point3D(-1.701301, 0, -1.801708));
            ltPoints.Add(new Point3D(-.52573, -1.618035, -1.801708));
            ltPoints.Add(new Point3D(1.376383, -.999999, -1.801708));

            ltPoints.Add(new Point3D(.688191, .5, -2.327438));
            ltPoints.Add(new Point3D(-.262866, .809017, -2.327438));
            ltPoints.Add(new Point3D(-.850651, 0, -2.327438));
            ltPoints.Add(new Point3D(-.262866, -.809017, -2.327438));
            ltPoints.Add(new Point3D(.688191, -.5, -2.327438));

            return ltPoints;
        }


        private void CreateNationItems()
        {
            List<Point3D> ltPoints = this.GetBuckyBallPoints();
         
            Vector3D oVectorCenter = new Vector3D(0, 0, 2);

            for (int i = 0; i < ltPoints.Count; i++)
            {
                Point3D oPoint = ltPoints[i];

                // 滚动碎片
                InteractiveCustom3DPlane o3DPlane = new InteractiveCustom3DPlane(0.96, 0.3, 0, 0);
                o3DPlane.OffsetX = 0;
                o3DPlane.OffsetY = 0;
                o3DPlane.OffsetZ = 2;
                o3DPlane.RotateXCenterZ = -2;
                o3DPlane.RotateYCenterZ = -2;

                double dAngleX = Vector3D.AngleBetween(oVectorCenter, new Vector3D(0, oPoint.Y, oPoint.Z));
                double dAngleY = Vector3D.AngleBetween(oVectorCenter, new Vector3D(oPoint.X, 0, oPoint.Z));

                if (oPoint.Y < 0)
                    dAngleX = -dAngleX;
                if (oPoint.X < 0)
                    dAngleY = -dAngleY;

                if (Math.Abs(dAngleX) > 90)
                {
                    o3DPlane.OffsetZ = -2;
                    o3DPlane.RotateXCenterZ = 2;
                    o3DPlane.RotateYCenterZ = 2;
                    o3DPlane.ScaleX = -1;
                    dAngleX = 180 - dAngleX;
                    dAngleY = 180 + dAngleY;
                }
                
                o3DPlane.AngleX = dAngleX;
                o3DPlane.AngleY = dAngleY;

                int nIndex = i;
                if (nIndex >= DataService.DataModels.Nations.Count)
                    nIndex = Utilitys.GetRandomSeed().Next(0, 55);
                // 民族名称
                string sNationName = DataService.DataModels.Nations[nIndex].Name;

                Border oBoder = new Border() { Width = 48, Height = 15 };
                oBoder.Background = new SolidColorBrush(Colors.Transparent);
                TextBlock oTbk = new TextBlock();
                oTbk.Text = sNationName;
                oTbk.Foreground = Brushes.White;
                oTbk.VerticalAlignment = VerticalAlignment.Center;
                oTbk.HorizontalAlignment = HorizontalAlignment.Center;
                oBoder.Child = oTbk;
                o3DPlane.Visual = oBoder;
                
                this.ViewportZm.Children.Add(o3DPlane);
            }
        }
    DoubleAnimation oAnim = new DoubleAnimation(0, -360, TimeSpan.FromSeconds(6));
            oAnim.RepeatBehavior = RepeatBehavior.Forever;
            this.CameraAngleZm.BeginAnimation(AxisAngleRotation3D.AngleProperty, oAnim);

            DoubleAnimation oAnimLogo = new DoubleAnimation(0, -360, TimeSpan.FromSeconds(6));
            oAnimLogo.RepeatBehavior = RepeatBehavior.Forever;
            this.LogoAngleZm.BeginAnimation(AxisAngleRotation3D.AngleProperty, oAnimLogo);
 <Viewport3D x:Name="ViewportZm" IsHitTestVisible="True" RenderOptions.EdgeMode="Aliased" Margin="0,100,-0,50">
                    <Viewport3D.Camera>
                        <PerspectiveCamera x:Name="CameraZm" Position="0,0,10" LookDirection="0,0,-1">
                            <PerspectiveCamera.Transform>
                                <Transform3DGroup>
                                    <TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0" x:Name="CameraTranslateZm"/>
                                    <RotateTransform3D x:Name="myRotateTransform3D">
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D Angle="0" Axis="0 1 0"  x:Name="CameraAngleZm"/>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </Transform3DGroup>
                            </PerspectiveCamera.Transform>
                        </PerspectiveCamera>
                    </Viewport3D.Camera>

                    <ModelVisual3D>
                        <ModelVisual3D.Content>
                            <Model3DGroup>
                                <AmbientLight Color="White"/>
                            </Model3DGroup>
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                    <ModelVisual3D x:Name="earthmodel">
                        <ModelVisual3D.Content>
                            <GeometryModel3D   Geometry ="{Binding Source={StaticResource sphere},
                                               Path=Geometry}">
                                <GeometryModel3D.Material>
                                    <DiffuseMaterial Brush="{StaticResource KeyImgBrushModuleMenuBg}">
                                    </DiffuseMaterial>
                                </GeometryModel3D.Material>
                                <GeometryModel3D.Transform>
                                    <RotateTransform3D >
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D x:Name="YRotate" Angle="0"/>
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </GeometryModel3D.Transform>
                            </GeometryModel3D>
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                    
                    <ModelVisual3D x:Name="Mv3dLogoZm">
                        <ModelVisual3D.Transform>
                            <Transform3DGroup>
                                <TranslateTransform3D OffsetZ="0" OffsetX="0" OffsetY="0"/>
                                <ScaleTransform3D ScaleZ="0" ScaleY="0.7" ScaleX="0.7"/>
                                <RotateTransform3D>
                                    <RotateTransform3D.Rotation>
                                        <AxisAngleRotation3D Axis="0,1,0" Angle="360" x:Name="LogoAngleZm"/>
                                    </RotateTransform3D.Rotation>
                                </RotateTransform3D>
                            </Transform3DGroup>
                        </ModelVisual3D.Transform>
                        <ModelVisual3D.Content>
                            <GeometryModel3D>
                                <GeometryModel3D.Geometry>
                                    <MeshGeometry3D Positions="-2.4,-2.7,0  2.4,-2.7,0 2.4,2.7,0 -2.4,2.7,0"
                                                TriangleIndices="0,1,2 0,2,3"  TextureCoordinates="0 1 1 1 1 0 0 0">
                                    </MeshGeometry3D>
                                </GeometryModel3D.Geometry>
                                <GeometryModel3D.Material>
                                    <DiffuseMaterial Brush="{StaticResource KeyImgBrushLogo}">
                                    </DiffuseMaterial>
                                </GeometryModel3D.Material>
                            </GeometryModel3D>
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                   
                    <ModelVisual3D x:Name="Mv3dContentZm">

                    </ModelVisual3D>
                </Viewport3D>

 

目录
相关文章
|
9月前
WPF-布局样式练习-Day02-聊天气泡
WPF-布局样式练习-Day02-聊天气泡
134 1
|
10月前
Photoshop绘制立体风格的拾色器图标
Photoshop绘制立体风格的拾色器图标
36 0
|
C#
WPF模糊和阴影效果
<Button Content="Button" HorizontalAlignment="Left" Margin="31,234,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="-0.
1488 0
|
程序员 C#
WPF 中的三维文字[转贴]
原文:WPF 中的三维文字[转贴] 原文: http://msdn.microsoft.com/msdnmag/issues/07/10/Foundations/default.
971 0
|
C# 容器 异构计算
去除WPF中3D图形的锯齿
原文:去除WPF中3D图形的锯齿       理论上讲PC在计算3D图形的时候是无法避免不出现锯齿的,因为3D图形都是又若干个三角形组成,如果3D图形想平滑就必须建立多个三角形,你可以想象一下正5边形和正100边形哪个更接近圆形的道理一样,这样会大量消耗显卡的存储空间或是从内存共享的存储空间,导致程序的整体性能降低,但如果三角形很少,显卡的解析度毕竟有限,就会出现锯齿。
1369 0
|
C#
WPF实现左右移动(晃动)动画效果
原文:WPF实现左右移动(晃动)动画效果 实现控件或布局的左右移动(晃动)主要用到DoubleAnimation以及Storyboard 布局代码为: ...
1533 0
|
C#
WPF圆形环绕的Loading动画
原文:WPF圆形环绕的Loading动画 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yangyisen0713/article/details/18218167 WPF制作一个模仿Silverlight页面还有win8系统的Loading动画效果,其实就用到WPF的ellipse即可,如果想要简单或者更好的效果的话还是要用Blend去做哈。
892 0
|
Web App开发 C# Windows
WPF图片浏览器(显示大图、小图等)
原文:WPF图片浏览器(显示大图、小图等) 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangshubo1989/article/details/46784601 1.概述                最近利用WPF做了一个图片浏览器,能够将文件夹中的所有图片以小图的形式显示,并将选中的图片以512*512大小显示。
2501 0
|
C#
WPF 通过透明度遮罩和变换制作倒影效果
原文:WPF 通过透明度遮罩和变换制作倒影效果   倒影效果 代码   更加复杂的应用 参考 https://blogs.
1318 0
|
前端开发 C#
WPF多点触摸放大缩小旋转
原文:WPF多点触摸放大缩小旋转 版权声明:本文为博主原创文章,需要转载尽管转载。 https://blog.csdn.net/z5976749/article/details/40118437 如果要方法缩小一个canvas,或图片: 只要在控件中添加    就可以拉伸改控件。
1569 0