I found several topics about serialization in Panda :
discourse.panda3d.org/viewtopic.php?t=1924
discourse.panda3d.org/viewtopic.php?t=924
But that’s not what I do here. (please correct anything I missed)
What I understand is, serialization means dumping the whole scenegraph under a node from memory to external storage, so that in the future it can be loaded as a whole piece as if created piece by piece at runtime. Just like loading models. This is the workflow of serializing nodes :
- run the script, let it build up the nodes, and at the given time, dump those nodes to disk
- the nodes’ builder part in the script must be eliminated (or commented out) to avoid duplication at future run-time
- create it’s loader script
While what I want is only to save/write to disk the transformation of particular nodes under aspect2d, kind of “save game”. I don’t mean to build a visual builder/editor. There is scene editor, but I’ve never used it to build 2d nodes.
All I want is the same standard workflow, but more flexible and (hopefully) intuitive. So my workflow is not changed at all, just need to be more careful, though.
- build up the nodes using script interface, mark which node whose transform must be saved to disk, using hardcoded tag for it’s unique node identity, which must stay the same forever
- anytime at run-time, I can move them around and scale them up/down, and dump the transform matrix to disk
- next, at future run-times, the transform matrix will be loaded from disk and automatically applied to the node
download :
A2DEditor.zip (last updated Jun 25, 2012)
test script (last updated 10/20/07)
put the test script at the same level with the A2DEditor directory.
A little guide to use it :
1. You must assign a unique ID to each node which need to be dynamically transformed at run-time. Call saveA2D and pass a hardcode unique random number, just close your eyes and hit some numbers. Sounds funny ??
2. Next, at run-time, you can enter edit session by pressing F5
3. In edit session, you can move & scale those marked nodes. They’re including Direct GUI and any geometry nodes. For geometry nodes, I use collision ray to select the geom, and then it’s parents will be displayed, so you can select exactly which node you want to edit. After selecting the node, press SPACE to enter edit mode, and there will be some info displayed following the mouse position to remind you about what you can do there.
4. After editing the nodes and keep the changes, you can leave edit session with 2 options : save/write the changes during that session to disk, or just discard them.
NEW 10/20/07 :
Aspect2D_EDITOR-UserGuide.htm (8.6 MB)
This is the internal of how it works :
1. The process walks through aspect2d scenegraph, searching for tagged nodes, even under not-tagged nodes.
2. Any node under a tagged node, if is not tagged already, will be tagged according to it’s parent’s tag.
Example : if the parent is tagged with “1234” number, the not-tagged children will be tagged with “1234-#”, which # means child’s index. It will be “1234-0”, “1234-1”, “1234-2”, and so on.
3. Important !! Just make sure to assign unique ID to each desired node, otherwise if two different nodes have the same ID, then they would share the same transform matrix.
Have fun !!