Article From:https://www.cnblogs.com/lonelyxmas/p/9689174.html
Original text: WPF-3D dynamic effect – word spherical surround

Copyright notice: This article is an original article for bloggers. It can not be reproduced without permission from bloggers. Https://blog.csdn.net/u013224722/article/details/81784443

It’s hard to write a dynamic effect, but it needs to be cut down and broken.


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];

                // Scrolling fragmentInteractiveCustom3DPlane 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 Vector3)D (0, oPoint.Y, oPoint.Z));Double dAngleY = Vector3D.AngleBetween (oVectorCenter, NE)W 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);/ / national nameString sNationName = DataService.DataModels.Nations[nIndex].Name;Border oBoder = new Border (){Width = 48, Height = 15};OBoder.Background = new SolidColorBrush (Colors.Transpa)Rent);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>

 

Leave a Reply

Your email address will not be published. Required fields are marked *