AB4D Forum
Moving and Efficient creation of SceneNodes - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.DXEngine (https://forum.ab4d.com/forumdisplay.php?fid=11)
+--- Thread: Moving and Efficient creation of SceneNodes (/showthread.php?tid=4265)



Moving and Efficient creation of SceneNodes - Marc - 06-11-2021

I have to create an scene with many independent meshes. I am using MeshObjectNode to create the SceneNode that are all appended to one root SceneNode. First of all I am not sure if this is the most efficient way of creating the objects, having one root scene node and then appending all of the different object's meshobjectnode.

Secondly, I would like to move each of the objects independently, but I am not sure how. I have seen in the examples that in order to move them all the examples use the SceneNodeVisual3D and then the transform of this object is changed. As far as I understand the SceneNodeVisual3D is a wpf object which is less efficient since I want to work directly with MeshObjectNode.

I have tried changing the Transform of the children SceneNodes but that does not move the mesh defined within the SceneNode. Am I missing anything?


RE: Moving and Efficient creation of SceneNodes - abenedik - 06-11-2021

You can change the transformation of SceneNodes with setting the Transform property. After that change, you also need to call NotifySceneNodeChange method on the changed SceneNode.

For example:
Code:
var transformMatrix = Matrix.Scaling(1, _orangePyramidYScale, 1) *
                      Matrix.RotationY(MathUtil.DegreesToRadians(_orangePyramidYRotate)) *
                      Matrix.Translation(0, -_orangePyramidYRotate, 0);

_orangePyramidObjectNode.Transform = new Transformation(ref transformMatrix);

// When the Transform is already set, you can change the matrix by:
//_orangePyramidObjectNode.Transform.SetMatrix(transformMatrix);

_orangePyramidObjectNode.NotifySceneNodeChange(SceneNode.SceneNodeDirtyFlags.TransformChanged);

I have updated the ManuallyCreatedSceneNodes sample with sample code that shows how to change transformation.
You can check the new content of the files on the sample project on GitHub:
https://github.com/ab4d/Ab3d.DXEngine.Wpf.Samples/blob/master/Ab3d.DXEngine.Wpf.Samples/DXEngineAdvanced/ManuallyCreatedSceneNodes.xaml
https://github.com/ab4d/Ab3d.DXEngine.Wpf.Samples/blob/master/Ab3d.DXEngine.Wpf.Samples/DXEngineAdvanced/ManuallyCreatedSceneNodes.xaml.cs


RE: Moving and Efficient creation of SceneNodes - Marc - 06-11-2021

awesome thanks! i'll be back... hahaha