Chapter 4 File Format
Objectives of this Chapter
After reading this chapter, we will be able to do the following:
L outputs scenario data to a file in ASCII or binary format.
L read the scenario file and input the data to the inventor database.
L create a graphic scenario using an inventor scenario file.
L read graphics from the memory buffer.
This chapter describes the ASCII file format of inventor. Whenever we apply the write action to a node, path, or path list, scenario data is output in ASCII format. Using the database's file reading method, we can read files in the ASCII file format and input data to the inventor database. This file format can also be used to transfer 3D copy and paste data between two program processes.
Output graphics scenarios
As described in Chapter 9th, we can apply the output action to a node, path, or path list. When the output action is applied to a node, it uses this node as the root node and outputs the entire sub-scenario.
SoWriteAction writeAction; writeAction.apply(root); //writes the entire scene graph to stdout |
Scenario for reading from files
TheReadall ()Method, we can read the graphic scenario data from a file to the scenario database. The following code reads a file with a given name, and then returnsSoseparatorNode. If an error occurs during file reading, the function returns NULL.
For the complete translation of this chapter, please download the following link:
The inventor mentorOriginal English version. Download
The inventor mentorChinese translation. Download
The inventor mentorSample Code. Download