첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ SpecularMaterial 엘리먼트 사용하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


MainWindow.xaml

 

 

<Window x:Class="TestProject.MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="800"

    Height="600"

    Title="SpecularMaterial 엘리먼트 사용하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Viewport3D>

        <ModelVisual3D>

            <ModelVisual3D.Content>

                <GeometryModel3D>

                    <GeometryModel3D.Geometry>

                        <MeshGeometry3D

                            Positions="-1.00  1 0.00, -0.99  1 0.16, -0.95  1 0.31, -0.89  1 0.45,

                                       -0.81  1 0.59, -0.71  1 0.71, -0.59  1 0.81, -0.45  1 0.89,

                                       -0.31  1 0.95, -0.16  1 0.99,  0.00  1 1.00,  0.16  1 0.99,

                                        0.31  1 0.95,  0.45  1 0.89,  0.59  1 0.81,  0.71  1 0.71,

                                        0.81  1 0.59,  0.89  1 0.45,  0.95  1 0.31,  0.99  1 0.16, 1.00  1 0.00,

                                       -1.00 -1 0.00, -0.99 -1 0.16, -0.95 -1 0.31, -0.89 -1 0.45,

                                       -0.81 -1 0.59, -0.71 -1 0.71, -0.59 -1 0.81, -0.45 -1 0.89,

                                       -0.31 -1 0.95, -0.16 -1 0.99,  0.00 -1 1.00,  0.16 -1 0.99,

                                        0.31 -1 0.95,  0.45 -1 0.89,  0.59 -1 0.81,  0.71 -1 0.71,

                                        0.81 -1 0.59,  0.89 -1 0.45,  0.95 -1 0.31,  0.99 -1 0.16, 1.00 -1 0.00"

                            Normals="-1.00  0 0.00, -0.99  0 0.16, -0.95  0 0.31, -0.89  0 0.45,

                                     -0.81  0 0.59, -0.71  0 0.71, -0.59  0 0.81, -0.45  0 0.89,

                                     -0.31  0 0.95, -0.16  0 0.99,  0.00  0 1.00,  0.16  0 0.99,

                                      0.31  0 0.95,  0.45  0 0.89,  0.59  0 0.81,  0.71  0 0.71,

                                      0.81  0 0.59,  0.89  0 0.45,  0.95  0 0.31,  0.99  0 0.16, 1.00  0 0.00,

                                     -1.00  0 0.00, -0.99  0 0.16, -0.95  0 0.31, -0.89  0 0.45,

                                     -0.81  0 0.59, -0.71  0 0.71, -0.59  0 0.81, -0.45  0 0.89,

                                     -0.31  0 0.95, -0.16  0 0.99,  0.00  0 1.00,  0.16  0 0.99,

                                      0.31  0 0.95,  0.45  0 0.89,  0.59  0 0.81,  0.71  0 0.71,

                                      0.81  0 0.59,  0.89  0 0.45,  0.95  0 0.31,  0.99  0 0.16, 1.00  0 0.00"

                            TextureCoordinates="0.00 0, 0.05 0, 0.10 0, 0.15 0, 0.20 0, 0.25 0, 0.30 0,

                                                0.35 0, 0.40 0, 0.45 0, 0.50 0, 0.55 0, 0.60 0, 0.65 0,

                                                0.70 0, 0.75 0, 0.80 0, 0.85 0, 0.90 0, 0.95 0, 1.00 0,

                                                0.00 1, 0.05 1, 0.10 1, 0.15 1, 0.20 1, 0.25 1, 0.30 1,

                                                0.35 1, 0.40 1, 0.45 1, 0.50 1, 0.55 1, 0.60 1, 0.65 1,

                                                0.70 1, 0.75 1, 0.80 1, 0.85 1, 0.90 1, 0.95 1, 1.00 1"

                            TriangleIndices=" 0 21  1,  1 21 22,  1 22  2,  2 22 23,  2 23  3,  3 23 24,

                                              3 24  4,  4 24 25,  4 25  5,  5 25 26,  5 26  6,  6 26 27,

                                              6 27  7,  7 27 28,  7 28  8,  8 28 29,  8 29  9,  9 29 30,

                                              9 30 10, 10 30 31, 10 31 11, 11 31 32, 11 32 12, 12 32 33,

                                             12 33 13, 13 33 34, 13 34 14, 14 34 35, 14 35 15, 15 35 36,

                                             15 36 16, 16 36 37, 16 37 17, 17 37 38, 17 38 18, 18 38 39,

                                             18 39 19, 19 39 40, 19 30 20, 20 40 41" />

                    </GeometryModel3D.Geometry>

                    <GeometryModel3D.Material>

                        <MaterialGroup>

                            <DiffuseMaterial

                                Brush="Black"

                                Color="Black" />

                            <SpecularMaterial SpecularPower="5">

                                <SpecularMaterial.Brush>

                                    <ImageBrush ImageSource="./sample.jpg" />

                                </SpecularMaterial.Brush>

                            </SpecularMaterial>

                        </MaterialGroup>

                    </GeometryModel3D.Material>

                </GeometryModel3D>

            </ModelVisual3D.Content>

        </ModelVisual3D>

        <ModelVisual3D>

            <ModelVisual3D.Content>

                <AmbientLight Color="White" />

            </ModelVisual3D.Content>

        </ModelVisual3D>

        <ModelVisual3D>

            <ModelVisual3D.Content>

                <DirectionalLight

                    Color="#c0c0c0"

                    Direction="0 0 -1" />

            </ModelVisual3D.Content>

            <ModelVisual3D.Transform>

                <RotateTransform3D>

                    <RotateTransform3D.Rotation>

                        <AxisAngleRotation3D x:Name="axisAngleRotation3D"

                            Axis="0 1 0" />

                    </RotateTransform3D.Rotation>

                </RotateTransform3D>

            </ModelVisual3D.Transform>

        </ModelVisual3D>

        <Viewport3D.Camera>

            <PerspectiveCamera

                Position="0 0 4"

                LookDirection="0 0 -1"

                UpDirection="0 1 0"

                FieldOfView="60" />

        </Viewport3D.Camera>

    </Viewport3D>

    <Window.Triggers>

        <EventTrigger RoutedEvent="Window.Loaded">

            <BeginStoryboard>

                <Storyboard

                    TargetName="axisAngleRotation3D"

                    TargetProperty="Angle">

                    <DoubleAnimation

                        From="0"

                        To="360"

                        Duration="0:0:3"

                        RepeatBehavior="Forever" />

                </Storyboard>

            </BeginStoryboard>

        </EventTrigger>

    </Window.Triggers>

</Window>

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요