Loading and saving a scene graph
To quote Frederick Brooks, "Show me your data structures and I do not need to see your code." Hopefully, it is already more or less clear how to implement basic operations on a scene graph, but the remaining recipes in this chapter will explicitly describe all the required routines. Here, we will provide an overview of the loading and saving operations for our scene graph structure.
Getting ready
Make sure you have read the previous recipe, Using data-oriented design for a scene graph, before proceeding any further.
How to do it...
The loading procedure is a sequence of fread()
calls, followed by a pair of loadMap()
operations. As usual, we will be omitting any error handling code in this book's text; however, the accompanying source code bundle contains many necessary checks to see if the file was actually opened and so on. Let's get started:
- After opening the file, we can read the count of stored scene nodes...