Ab3d.PowerToys Line with text samples




                        
<Page x:Class="Ab3d.PowerToys.Samples.Text3D.LineWithTextSample"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:cameras="clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys"
      xmlns:ab3d="clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys"  
      xmlns:visuals="clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys">
    <Page.Resources>
        <DiffuseMaterial x:Key="ObjectsMaterial" Brush="#247589"/>
    </Page.Resources>
    <Grid Name="MainGrid">
        <Grid.Background>
            <LinearGradientBrush StartPoint="0 0" EndPoint="0 1">
                <GradientStop Offset="0" Color="#033C62"/>
                <GradientStop Offset="1" Color="#01131F"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid Name="ViewportGrid" Grid.Row="0" Background="Transparent">
            <Viewport3D Name="MainViewport">
                <visuals:BoxVisual3D CenterPosition="0 0 -50" Size="200 80 100" Material="#247589"/>

                <visuals:LineVisual3D StartPosition="-100 -40 0" EndPosition="-100 -40 40" LineThickness="1" LineColor="Yellow"/>
                <visuals:LineVisual3D StartPosition="100 -40 0" EndPosition="100 -40 40" LineThickness="1" LineColor="Yellow"/>

                <visuals:LineWithTextVisual3D StartPosition="-100 -40 30" EndPosition="100 -40 30"
                                              StartLineCap="ArrowAnchor" EndLineCap="ArrowAnchor"
                                              LineThickness="1" LineColor="Yellow"
                                              FontSize="15" TextUpDirection="0 1 0"
                                              Text="200 cm"/>


                <visuals:LineVisual3D StartPosition="100 40 0" EndPosition="100 40 40" LineThickness="1" LineColor="Yellow"/>

                <visuals:LineWithTextVisual3D StartPosition="100 -40 30" EndPosition="100 40 30"
                                              StartLineCap="ArrowAnchor" EndLineCap="ArrowAnchor"
                                              LineThickness="1" LineColor="Yellow"
                                              FontSize="15" TextUpDirection="0 0 -1"
                                              Text="80 cm"/>


                <visuals:LineVisual3D StartPosition="-100 -40 0" EndPosition="-140 -40 0" LineThickness="1" LineColor="Yellow"/>
                <visuals:LineVisual3D StartPosition="-100 -40 -100" EndPosition="-140 -40 -100" LineThickness="1" LineColor="Yellow"/>

                <visuals:LineWithTextVisual3D StartPosition="-130 -40 -100" EndPosition="-130 -40 0"
                                              StartLineCap="ArrowAnchor" EndLineCap="ArrowAnchor"
                                              LineThickness="1" LineColor="Yellow"
                                              FontSize="15" TextUpDirection="1 0 0"
                                              Text="100 cm"/>


                <visuals:LineVisual3D StartPosition="-100 40 -90" EndPosition="-50 70 -90" LineThickness="1" LineColor="Yellow" StartLineCap="ArrowAnchor"/>

                <visuals:LineWithTextVisual3D StartPosition="-50 70 -90" EndPosition="100 70 -90"
                                              LineThickness="1" LineColor="Yellow"
                                              FontSize="20" TextUpDirection="0 1 0"
                                              Text="One corner"/>


            </Viewport3D>
        </Grid>

        <cameras:SceneCamera Name="Camera1" Grid.Row="0" Heading="30" Attitude="-20" Bank="0" Distance="600" ShowCameraLight="Always"/>

        <!-- EventsSourceElement is set to ViewportGrid - this means that the ViewportGrid's mouse events are subscribed to - 
             this enables camera rotation without the need to be over the rendered 3D element -->
        <ab3d:MouseCameraController Name="MouseCameraController1" Grid.Row="0" UsedMouseButton="Left" EventsSourceElement="{Binding ElementName=ViewportGrid}"/>

        <ab3d:CameraControlPanel VerticalAlignment="Bottom" Grid.Row="0" HorizontalAlignment="Left" Margin="5" Width="150" Height="75"/>

    </Grid>
</Page>