ScreenSpaceLines3D ScaleTransform bug?

Topics: Developer Forum, User Forum
Feb 21, 2008 at 8:31 PM
When performing a ScaleTransform on a ScreenSpaceLines3D from 1 to 0 and back again it disappears. See attached code.


XAML
<Window x:Class="_3DPreviewer.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tool3d="clr-namespace:_3DTools;assembly=3DTools"
Title="Window1" Height="488" Width="940" x:Name="MainWindow1" Loaded="MainWindow1_Loaded">
<DockPanel>
<ToggleButton x:Name="theBtn" Click="Button_Click">Scale</ToggleButton>
<Viewport3D x:Name="theView3D" OpacityMask="{x:Null}" Grid.ColumnSpan="2">
<Viewport3D.Camera>
<PerspectiveCamera Position="6,6,6" LookDirection="-4,-4,-4"
UpDirection="0,1,0" />
</Viewport3D.Camera>

<ModelVisual3D x:Name="theModel">
<ModelVisual3D.Content>
<Model3DGroup>

<DirectionalLight Direction="0,-5,-2" />
<DirectionalLight Direction="3,2,2" />

<GeometryModel3D x:Name="theGeometry">
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="0,1,0 1,-1,1 -1,-1,1 1,-1,-1 -1,-1,-1"
Normals="0,1,0 -1,0,1 1,0,1 -1,0,-1 1,0,-1"
TriangleIndices="0,2,1 0,3,1 0,3,4 0,2,4" />
</GeometryModel3D.Geometry>

<GeometryModel3D.Material>
<DiffuseMaterial Brush="Red" />
</GeometryModel3D.Material>

<GeometryModel3D.BackMaterial>
<DiffuseMaterial Brush="Green" />
</GeometryModel3D.BackMaterial>
</GeometryModel3D>

</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>

<tool3d:ScreenSpaceLines3D Points="-6,0,0 6,0,0" Color="Red" x:Name="theLine" />
</Viewport3D>
</DockPanel>
</Window>

Code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _3DPreviewer
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
ScaleTransform3D scaleTransform = new ScaleTransform3D( 1.0, 1.0, 1.0 );
public Window1 ()
{
InitializeComponent();
theLine.Transform = scaleTransform;
theModel.Transform = scaleTransform;

}

private void MainWindow1_Loaded ( object sender, RoutedEventArgs e )
{

}

private void Button_Click ( object sender, RoutedEventArgs e )
{
if ( theBtn.IsChecked == true )
{
scaleTransform.ScaleX = scaleTransform.ScaleY = scaleTransform.ScaleZ = 0.0;
}
else
{
scaleTransform.ScaleX = scaleTransform.ScaleY = scaleTransform.ScaleZ = 1.0;
}

}

}
}