mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 22:35:03 -06:00
Add images and text about the 3D scene graph
CURA-7502
This commit is contained in:
parent
06666bddca
commit
1db4cbe5f0
6 changed files with 65 additions and 13 deletions
BIN
docs/scene/images/components_interacting_with_scene.jpg
Normal file
BIN
docs/scene/images/components_interacting_with_scene.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 211 KiB |
BIN
docs/scene/images/components_interacting_with_scene.png
Normal file
BIN
docs/scene/images/components_interacting_with_scene.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 174 KiB |
BIN
docs/scene/images/layer_data_scene_node.jpg
Normal file
BIN
docs/scene/images/layer_data_scene_node.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 KiB |
BIN
docs/scene/images/scene_example.png
Normal file
BIN
docs/scene/images/scene_example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 493 KiB |
BIN
docs/scene/images/scene_example_scene_graph.jpg
Normal file
BIN
docs/scene/images/scene_example_scene_graph.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 328 KiB |
|
@ -2,6 +2,15 @@ Scene
|
|||
====
|
||||
The 3D scene in Cura is designed as a [Scene Graph](https://en.wikipedia.org/wiki/Scene_graph), which is common in many 3D graphics applications. The scene graph of Cura is usually very flat, but has the possibility to have nested objects which inherit transformations from each other.
|
||||
|
||||
Class Diagram
|
||||
====
|
||||
|
||||
The following class diagram depicts the classes that interact with the Scene
|
||||
|
||||

|
||||
|
||||
The scene lives in the Controller of the Application, and it is primarily interacting with SceneNode objects, which are the components of the Scene Graph.
|
||||
|
||||
Scene Graph
|
||||
----
|
||||
Cura's scene graph is a mere tree data structure. This tree contains all scene nodes, which represent the objects in the 3D scene.
|
||||
|
@ -10,17 +19,60 @@ The main idea behind the scene tree is that each scene node has a transformation
|
|||
|
||||
A Typical Scene
|
||||
----
|
||||
Cura's scene has a few nodes that are always present, and a few nodes that are repeated for every object that the user loads onto their build plate. To give an idea of how a scene normally looks, this is an overview of a typical scene tree for Cura.
|
||||
Cura's scene has a few nodes that are always present, and a few nodes that are repeated for every object that the user loads onto their build plate. The root of the scene graph is a SceneNode that lives inside the Scene and contains all the other children SceneNodes of the scene. Typically, inside the root you can find the SceneNodes that are always loaded, such as the Cameras and the [BuildVolume](build_volume.md) (which contains the Platform), and the objects that are loaded on the platform.
|
||||
|
||||
* Root
|
||||
* Camera
|
||||
* [Build volume](build_volume.md)
|
||||
* Platform
|
||||
* Object 1
|
||||
* Group 1
|
||||
* Object 2
|
||||
* Object 3
|
||||
* Object 1 convex hull node
|
||||
* Object 2 convex hull node
|
||||
* Object 3 convex hull node
|
||||
* Group 1 convex hull node
|
||||
Let's take the following example Scene:
|
||||
|
||||

|
||||
|
||||
The scene graph in this case is the following:
|
||||
|
||||
|
||||

|
||||
|
||||
As it is visible, aside from the BuildVolume, the Cameras, and the objects, the root SceneNode also contains all the ConvexHullNodes, which are used to display the convex hull of each object and each group of objects. A ConvexHullNode is always loaded for each of the existing CuraSceneNodes
|
||||
|
||||
|
||||
Accessing SceneNodes in the Scene
|
||||
----
|
||||
|
||||
SceneNodes can be accessed using a BreadthFirstIterator or a DepthFirstIterator. Each iterator traverses the scene graph and returns a Python iterator, which yield all the SceneNodes and their children.
|
||||
|
||||
``` python
|
||||
for node in BreadthFirstIterator(scene.getRoot()):
|
||||
# do stuff with the node
|
||||
```
|
||||
|
||||
Example result when iterating the above scene graph:
|
||||
|
||||
```python
|
||||
[i for i in BreadthFirstIterator(self._root)]
|
||||
```
|
||||
* 00 = {SceneNode} <SceneNode object: 'Root'>
|
||||
* 01 = {BuildVolume} <BuildVolume object '0x2e35dbce108'>
|
||||
* 02 = {Camera} <Camera object: '3d'>
|
||||
* 03 = {CuraSceneNode} <CuraSceneNode object: 'Torus.stl'>
|
||||
* 04 = {CuraSceneNode} <CuraSceneNode object: 'Group #1'>
|
||||
* 05 = {Camera} <Camera object: 'snapshot'>
|
||||
* 06 = {CuraSceneNode} <CuraSceneNode object: 'Star.stl'>
|
||||
* 07 = {ConvexHullNode} <ConvexHullNode object: '0x2e3000def08'>
|
||||
* 08 = {ConvexHullNode} <ConvexHullNode object: '0x2e36861bd88'>
|
||||
* 09 = {ConvexHullNode} <ConvexHullNode object: '0x2e3000bd4c8'>
|
||||
* 10 = {ConvexHullNode} <ConvexHullNode object: '0x2e35fbb62c8'>
|
||||
* 11 = {ConvexHullNode} <ConvexHullNode object: '0x2e3000a0648'>
|
||||
* 12 = {ConvexHullNode} <ConvexHullNode object: '0x2e30019d0c8'>
|
||||
* 13 = {ConvexHullNode} <ConvexHullNode object: '0x2e3001a2dc8'>
|
||||
* 14 = {Platform} <Platform object '0x2e35a001948'>
|
||||
* 15 = {CuraSceneNode} <CuraSceneNode object: 'Group #2'>
|
||||
* 16 = {CuraSceneNode} <CuraSceneNode object: 'Sphere.stl'>
|
||||
* 17 = {CuraSceneNode} <CuraSceneNode object: 'Cylinder.stl'>
|
||||
* 18 = {CuraSceneNode} <CuraSceneNode object: 'Cube.stl'>
|
||||
|
||||
Layer Data
|
||||
----
|
||||
|
||||
Once the Slicing has completed and the CuraEngine has returned the slicing data, Cura creates a CuraSceneNode inside the BuildVolume which holds all the layer data. This CuraSceneNode can be identified via its LayerDataDecorator.
|
||||
|
||||
<img src = "https://github.com/Ultimaker/Cura/blob/master/docs/scene/images/layer_data_scene_node.jpg" width = "250" alt="Layer Data Scene Node">
|
||||
|
||||
**Note:** This CuraSceneNode is created once Cura has completed processing the Layer data (after the user clicks on the Preview tab after slicing). The CuraSceneNode then is destroyed once any action that changes the Scene occurs (e.g. if the user moves/rotates/scales an object or changes a setting value).
|
Loading…
Add table
Add a link
Reference in a new issue