AB4D Forum
WpfModelVisual3DNode not following its parent - 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: WpfModelVisual3DNode not following its parent (/showthread.php?tid=4096)

WpfModelVisual3DNode not following its parent - Hamish - 03-05-2018

When I parent a WpfModelVisual3DNode to a scene node, it doesn't seem to "follow" when the parent's transform is changed.

I've an empty SceneNode object with two children. A cylinder MeshObjectNode which renders fine and a WpfModelVisual3DNode node which also renders fine. But when I move the SceneNode, the cylinder mesh inherits the transform, but the WpfModelVisual3DNode doesn't inherit the transform.

If I delete the WpfModelVisual3DNode node and re-create it it appears in the correct place, but I shouldn't have to do this. Is this a known bug?

I'm rendering a DXScene directly. I have a DXViewportView instantiated to ensure the text node renders, but does this have something to do with the problem?


RE: WpfModelVisual3DNode not following its parent - abenedik - 03-07-2018

When you change a transformation of a SceneNode, you need to notify all SceneNode parents and all its children about that change.

This is done with the following code:

// Because our transformation has changed, parent SceneNodes should update their bouding boxes                
// Also notify all child nodes that they need to update the world matrix

When you use WPF 3D objects like BoxVisual3D or other Visual3D objects, those notifications are done automatically by the WpfModelVisual3DNode that represents the ModelVisual3D objects in the DXEngine's SceneNode hierarchy.

But when you use SceneNodes directly, you need to notify the "interested" SceneNodes manually. Also when you change a setting in a DXEngine's material you need to notify the SceneNodes that use that material about the material change: NotifySceneNodeChange(SceneNodeDirtyFlags.MaterialChanged)