WPF-3D动效-文字球形环绕
生活随笔
收集整理的這篇文章主要介紹了
WPF-3D动效-文字球形环绕
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
原文:WPF-3D動效-文字球形環繞
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>
版權聲明:本文為博主原創文章,未經博主允許不得轉載。 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>
?
總結
以上是生活随笔為你收集整理的WPF-3D动效-文字球形环绕的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: day10 局部变量 全局变量 作用域前
- 下一篇: 【cisco下针对冗余链路故障备份的处理