C# wpf helix scale based mesh parenting using Transform3DGroup
- by Rick2047
I am using https://helixtoolkit.codeplex.com/ as a 3D framework.
I want to move black mesh relative to the green mesh as shown in the attached image below. I want to make green mesh parent to the black mesh as the change in scale of the green mesh also will result in motion of the black mesh. It could be partial parenting or may be more. I need 3D rotation and 3D transition + transition along green mesh's length axis for the black mesh relative to the green mesh itself.
Suppose a variable green_mesh_scale causing scale for the green mesh along its length axis. The black mesh will use that variable in order to move along green mesh's length axis.
How to go about it.
I've done as follows:
GeometryModel3D GreenMesh, BlackMesh;
...
double green_mesh_scale = e.NewValue;
Transform3DGroup forGreen = new Transform3DGroup();
Transform3DGroup forBlack = new Transform3DGroup();
forGreen.Children.Add(new ScaleTransform3D(new Vector3D(1, green_mesh_scale , 1)));
// ... transforms for rotation n transition
GreenMesh.Transform = forGreen ;
forBlack = forGreen;
forBlack.Children.Add(new TranslateTransform3D(new Vector3D(0, green_mesh_scale, 0)));
BlackMesh.Transform = forBlack;
The problem with this is the scale transform will also be applied to the black mesh. I think i just need to avoid the scale part.
I tried keeping all the transforms but scale, on another Transform3DGroup variable but that also not behaving as expected.
Can MatrixTransform3D be used here some how?
Also please suggest if this question can be posted somewhere else in stackexchange.