[Hexlix WPF-v2.23] TranslateManipulator can not set position, and update wrong Transform in code behind
See original GitHub issueI’m trying to use the C# code behind to create a TranslateManipulator with cutting plane and rectangleVisual3D.
But I see that, I can not set position for TranslateManipulator if I use it together with translateManipulator.Bind(ModelVisual3D)
.
TranslateManipulator seems it init then updates the wrong value.
case error 1: translateManipulator.Transform wrong update value (see cutting plane cut the box), translateManipulator not move
case error 2: translateManipulator can not set and update position, it allway is (0,0,0)
Here is my code reproduction error ( see case error 1 and case error 2)
using HelixToolkit.Wpf;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
namespace LearnHelixTookit.Wpf.Views
{
/// <summary>
/// Err update position TranslateManipulator position (see case 1 anfd case 2)
/// </summary>
public partial class FixManipulatorPosition : Window
{
Plane3D plane = new Plane3D(new Point3D(), new Vector3D(0, 0, 1));
CuttingPlaneGroup cuttingGroup;
RectangleVisual3D rectangle3D;
TranslateManipulator translateManipulator;
public FixManipulatorPosition()
{
InitializeComponent();
translateManipulator = new TranslateManipulator()
{
Direction = new Vector3D(0, 0, 1),
Length = 2,
Color = Colors.Green,
/*Position= new Point3D(0, 0, 2) not update */
};
translateManipulator.MouseMove += TranslateManipulator_MouseMove;
rectangle3D = new RectangleVisual3D()
{
Width = 2,
Length = 4,
Normal = new Vector3D(0, 0, 1),
Material = new DiffuseMaterial(Brushes.Red),
Origin = new Point3D(0, 5, 1),
};
//Case err1 - translateManipulator.Transform wrong update value (see cutting plane cut the box), translateManipulator not move
translateManipulator.Bind(rectangle3D);
translateManipulator.Position = new Point3D(0, 5, 2);
////Case err2 translateManipulator can not set and update position, it allway is (0,0,0)
//translateManipulator.Position = new Point3D(0, 5, 2);
//translateManipulator.Bind(rectangle3D);
CubeVisual3D cube = new CubeVisual3D() { Center = new Point3D(0, 5, 1) };
cuttingGroup = new CuttingPlaneGroup();
cuttingGroup.CuttingPlanes = new List<Plane3D> { plane };
cuttingGroup.Children.Add(cube);
viewport.Children.Add(translateManipulator);
viewport.Children.Add(rectangle3D);
viewport.Children.Add(cuttingGroup);
BillboardTextVisual3D billboard = new BillboardTextVisual3D() { Text = "C# behavior (see case err 1 and case err 2 in code behide )", Position = new Point3D(0, 5, 3) };
viewport.Children.Add(billboard);
}
private void TranslateManipulator_MouseMove(object sender, MouseEventArgs e)
{
plane.Position = translateManipulator.Transform.Transform(rectangle3D.Origin);
cuttingGroup.UpdateModel();
}
private void manipulator_MouseMove(object sender, MouseEventArgs e)
{
xamlCutting.UpdateModel();
}
}
}
<Window x:Class="LearnHelixTookit.Wpf.Views.FixManipulatorPosition"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LearnHelixTookit.Wpf.Views"
xmlns:ht="http://helix-toolkit.org/wpf"
mc:Ignorable="d"
Title="FixManipulator" Height="450" Width="800">
<Grid>
<ht:HelixViewport3D x:Name="viewport">
<ht:SunLight></ht:SunLight>
<ht:GridLinesVisual3D ></ht:GridLinesVisual3D>
<ht:TranslateManipulator x:Name="manipulator" Color="Red" MouseMove="manipulator_MouseMove"
Length="4"
Position="{Binding ElementName=pl, Path=Position}"
Direction="0,0,1"
></ht:TranslateManipulator>
<ht:RectangleVisual3D Width="2" Length="3" Origin="{Binding ElementName=manipulator, Path=Position}"></ht:RectangleVisual3D>
<ht:CuttingPlaneGroup x:Name="xamlCutting">
<ht:CuttingPlaneGroup.CuttingPlanes>
<ht:Plane3D x:Name="pl" Position="5,0,0" Normal="0,0,1"></ht:Plane3D>
</ht:CuttingPlaneGroup.CuttingPlanes>
<ht:CubeVisual3D x:Name="cube" Center="5,0,0"></ht:CubeVisual3D>
</ht:CuttingPlaneGroup>
<ht:BillboardTextVisual3D Text="xaml behavior" Position="5,0,4"></ht:BillboardTextVisual3D>
</ht:HelixViewport3D>
</Grid>
</Window>
Issue Analytics
- State:
- Created 5 months ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Why does two Transform do not work with a Helix Toolkit ...
I have put together some code where I am manipulating two Helix Toolkit Torus objects by using WPF slider controls. This code is...
Read more >Resolved - transform.position does not work
I've been trying to make my own save and load features for my game. I got everything working until the last few lines...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Breaking change should be fine if it is necessary to fix bugs.
what are the purposes of BindableTranslateManipulator/BindableRotateManipulator vs TranslateManipulator/ RotateManipulator? I think they are the same functions. and should be reduce 2 of them in 1.