C# wpf helix scale based mesh parenting using Transform3DGroup

Posted by Rick2047 on Game Development See other posts from Game Development or by Rick2047
Published on 2012-10-31T10:12:29Z Indexed on 2012/10/31 11:14 UTC
Read the original article Hit count: 415

Filed under:
|
|
|

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;   

Black mesh is moving relative to the change in scale of the green mesh

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.

© Game Development or respective owner

Related posts about c#

Related posts about 3d-meshes