Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the transformed geometry from a rotated/translated HelixToolkitScene object #2211

Open
whogoesthere opened this issue May 6, 2024 · 2 comments

Comments

@whogoesthere
Copy link

I have a 3D model (OBJ file).
I use the SharpDX importer to import the file to as a HelixToolkitScene object
Importer Importer = new HelixToolkit.Wpf.SharpDX.Assimp.Importer();
this.Scene = Importer.Load(Filename);
The scene is then added to a SceneNodeGroupModel3D
this.GroupModel.AddNode(this.Scene.Root);

and successfully displayed via a binding to my HelixViewPort3DX.
I later manipulate the rotation and position of the object by manipulating the model matrix of the the HelixToolkitScene object and updating the corresponding SceneNodeGroupModel3D. This works as expected and the model moves on my ViewPort3DX.

I later decompose the HelixToolkitScene object into a Geometry3D[] with
var geometry = this.Scene.Root.Traverse().Where(z => (z is MeshNode)).Select(m => ((MeshNode)m).Geometry).ToArray();
and I then use this to create an array of triangles.

The problem is the geometry represents the unmodified geometry which is unchanged by the rotations or translations. How do I get the geometry from a rotated/translated object.

Greatly appreciate your help.
Best regards
Ian

@holance
Copy link
Member

holance commented May 7, 2024

You need to multiply all vertices of the geometry with the TotalModelMatrix from scene node to get the transformed mesh.

@whogoesthere
Copy link
Author

Could you show me a code snippet please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants