Multiple scenes - 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: Multiple scenes (/showthread.php?tid=4202)
Multiple scenes - janovrom - 07-02-2020
I made this setup:
1. 4 scene views (each has its own DXScene and they share the DXDevice as described in one of the samples)
2. All scenes render the same stuff - SimpleMesh is shared, SceneNodes are duplicated
3. UI is done in WPF
4. There is selection from two sources - 3D hit testing and from an scene hierarchy explorer
5. There is an animation system
I've ran into synchronization issues between all these components as there has to be an additional layer between WPF UI and scene node as you can't (or shouldn't unless you want to risk memory leaks) bind to scene node. This means that I either duplicate the whole structure (transformations, bounds) or access directly the scene nodes. But then you have 4 hierarchies to handle each scene. The animations also have to update four different objects.
1. Is there a way to share SceneNodes as well? The data are the same, only the camera will be different.
2. Can I render multiple cameras in one scene? Like specifying viewport for each camera instead of having multiple DXScenes.
3. Is there a way to extend MeshObjectNode by additional information? Let's say for hit testing. You hit test on the hierarchy, get back a scene node then you do some additional logic like highlighting the object in the hierarchy explorer and in the scene. The scene is simple, I can just add it to an existing custom outline render queue. But to inform the UI I need the access to additional information. It would be nice to extend the MeshObjectNode, but it's sealed. Is there a way to add additional data to MeshObjectNode. Can the Tag property be used (if it's not used for some DXEngine data), or is there a way to pass callbacks for property change or on object hit with raycast?
4. If I want to listen to SceneRendered event from DXView with this setup, you are hooking up to 4 different events.
5. Also outline has to set up the same render queues for each DXScene.
6. There is performance slow down as I have to update 4 hierarchies.
RE: Multiple scenes - abenedik - 07-02-2020
I am planning to improve multi-scene support in the next version (also adding support to render one scene in multiple windows - for example to show a scene on a 3x3 big screens).
Currently you can share WPF 3D objects and meshes, but you cannot share SceneNodes. Usually they do not contain a lot of data, so having multiple copies should not be a problem. But I know that the current situation is not optimal.
This is quite complicated and it is currently a vacation time so you cannot expect some progress soon.
The MeshObjectNode is sealed for performance reasons. But you can use the Tag property for your own data.
RE: Multiple scenes - abenedik - 07-22-2020
The support for using multiple DXViewportViews objects that show the same 3D scene has been added to the development version of Ab3d.DXEngine. I have already sent the new version with new sample to janovrom. If you also want to test this, please contact me with PM or by email.
RE: Multiple scenes - janovrom - 07-22-2020
I have tested it right away. The sample contains 6 viewports from which only one has DXScene with not-null RootNode. If you modify the "IsVisible" property then the object is hidden everywhere (the same goes for other changes). Is it possible to add scene specific objects? I tried creating new MeshObjectNodes and add them to each respective scene with empty RootNode, but it resulting in very unpredictable behavior. I expect that it should be possible to create either new rendering step/queue/filter for each scene that would render the objects on per scene basis. Am I correct? This could be used for frustum culling for example as you can't set IsVisible on the hierarchy itself.
RE: Multiple scenes - abenedik - 07-22-2020
Because there is only one instance of each 3D objects, you cannot set different values for IsVisible for each view.
But you can create the child DXViewportView objects with useMasterRenderingSteps parameter set to false. This will create RenderingSteps for each child DXViewportView.DXScene object. After that you can use the FilterObjectsFunction to filter which objects to render (if the Func<RenderablePrimitiveBase, bool> returns false, then rendering of the objects is skipped). Note that this Func gets a RenderablePrimitiveBase as parameter (and not SceneNode objects). But you can usually get the SceneNode with checking the value of the RenderablePrimitiveBase.OriginalObject.
RE: Multiple scenes - janovrom - 07-23-2020
There also used to be a workaround for using one DXDevice with multiple DXScenes.
Is this still needed?
I can check the SceneNode in the rendering step. If I get the scene node ParentDXScene, to which scene it will point to? To the master scene?
RE: Multiple scenes - abenedik - 07-23-2020
No, this is not needed anymore when the DXViewportView is created with a master DXViewportView as a constructor parameter.
Now the DXViewportView and DXScene objects have the knowledge of master / child objects and handle all required steps internaly.
RE: Multiple scenes - janovrom - 07-27-2020
What about CameraAxisPanel? Is this shared as well (at least when added the same way as previously - the same root as camera controller and camera - it seems it's only in the master view)? If it's true, is there a way to add it to each scene?
RE: Multiple scenes - abenedik - 07-27-2020
As you can see, each DXViewportView has its own TargetPositionCamera and MouseCameraController - this way you can define a different view to the same scene.
This means that you will need to define a different CameraAxisPanel object for each DXViewportView / Camera - do not forget to set the CameraAxisPanel.TargetCamera property to the correct camera (if you do not set this property, then the CameraAxisPanel will show the axis of the first camera that is found in the WPF controls tree).
RE: Multiple scenes - janovrom - 08-10-2020
What is the purpose behind TargetPositionCamera.Distance? When I use it with distance of 10 in the MultiDXViewportViews.Samples.xaml.cs it creates unwanted results. If you look at the attachment, you can see it's weirdly clipped. It does not seem to happen when using standard single view or multiple DXScenes. The near and far plane seem to be automaticaly adjusted.
Is it possible to access the current rendering scene in RenderObjectsRenderingStep.FilterRenderingQueuesFunction? For example to filter some helper objects.