File FormatThough we have said uptil now that Direct3D can be used to display 3D data and though it is possible to generate 3D data on the fly, it is very difficult and restrictive to store information of various complex models and scenes, typically used in 3D systems, directly inside the application. Usually, a 3D scene is specified using a data file, which provides all the relevant information required for rendering purposes. Though Direct3D does not provide a file format for specifying whole scenes, it provides a file format to specify a 3D mesh object that can be placed in a scene. This file format is template driven and is architecture neutral and context free. It is also extensible and new templates can be added very easily. The file format allows storage of predefined object meshes, texture and animations, in addition to allows storage of user defined objects. Applications can define higher-level templates using existing lower-level or other higher-level templates. The file format is the DirectX file format and has a ``.x'' extension. It is also called the ``xof'' file. This file format is natively supported and used by the retained mode, which provides objects and methods to read, save and manipulate a file. The file format allows specification of fixed path animations and also supports instacing of objects, which helps in reuse of data sets and hence reducing the total size of the object being manipulated. Let us now consider the details of the file format. A data file can be split into three parts, namely: header, template and data. Each of the parts is described in the following sections. HeaderThe header part contains information which helps indentify the file. It is compulsory at the beginning of the file. The header consists of a magic number (``xof''), which identifies the file and the major and minor version numbers of the file. These numbers can be used to take care of versioning problems in data files, if required. The version numbers are followed by the format type, which can be one of the following:
If the file is a compressed file, the compression type is specified following the format type. The compression type can be one of the following:
The compression type is followed by 4 digits, which indicate the number of bits used to represent floating point numbers. TemplateThe different templates used in the file follow the header information. A template defines how a data stream is to be interpreted by the reader of the file. A template is specified using a skeleton, as shown in figure 6.
A template has a name, which is used to identify the data type being read, when it is encountered. The name is followed by the UUID (Universally Unique IDentifier) of the COM object to be used to read this template when it is encountered. The UUID is followed by a list of members of the template. The member list can be followed by an optional list of restrictions that need to be observed while reading the data or creating the data striucture to hold the read data. DataThis part contains the actual object information. The data part can either store actual data or a reference to the data. This referencing is used for the feature of instancing, supported by the file format. The feature of instancing allows reference to an data set, if it is required at multiple places, instead of replicating all the data elements. Each data object is read using a corresponding template object. All data objects have to belong to one of the templates specified after the header. The data is specified using a template skeleton, as illustrated in figure 7.
Sample Data FileA sample data file, to help understand the file format is presented in appendix A.
|
|||||||||||