Object from Text |
The object from text element will form a 3D object according to the definition entered as a text parameter. The object definition complies with the format of DirectX files (file suffix *.x).
A simplified example of a DirectX object definition (a rectangular triangle):
Mesh { // start of object definition
3; // number of following vertices
1;0;0;, // coordinates of vertex 0
0;0;0;, // coordinates of vertex 1
0;1;0;; // coordinates of vertex 2
1; // number of following faces
3;0,1,2;; // face 0
MeshNormals { // start of definition of normals in vertices
3; // number of following normals
0;0;-1;, // normal of vertex 0
0;0;-1;, // normal of vertex 1
0;0;-1;; // normal of vertex 2
1; // number of following faces
3;0,1,2;; // face 0
} // end of definition of normals
MeshTextureCoords { // start of definition of texture coordinates
3; // number of following texture coordinates
1;1; // texture coordinate for vertex 0
0;1; // texture coordinate for vertex 1
0;0;; // texture coordinate for vertex 2
} // end of definition of texture coordinates
} // end of object definition
The example given above is a recommended format to form an object in the Peter application. As the first item, the definition contains a list of the vertices' coordinates. At the list beginning the number of vertices is quoted. The number of vertices is followed by the vectors of the vertices' coordinates. Individual vector numbers are terminated by a semicolon, each vector (i.e. each group of 3 numbers) is terminated by a comma, only the last one is terminated by a semicolon.
The list of vertices is followed by the list of faces. At the list beginning the number of faces is quoted. Hereafter individual faces follow. First, each face contains a data about the number of the following vertex indices. After a separating semicolon follow the face's vertex indices (starting with index 0), separated by a comma from one another. The last index is followed by a semicolon character. The definition of each face is terminated by a comma, the last face is terminated by a semicolon.
The face definition is followed (but still inside the object definition) by the definition of normals. The definition of normals has the same architecture as the object definition (it contains a list of normals and a list of faces with indices of normals). The number of normals and the number of normal faces should correspond to the number of vertices and to the number of object faces.
The definition of normals is followed by the texture coordinates definition. At the definition beginning the number of texture coordinate pairs is given, followed by a list of coordinates, each containing 2 items. The first item is the texture horizontal coordinate (ranging between 0=left and 1=right), the second item is the texture vertical coordinate (ranging between 0=up and 1=down). Individual items are terminated by a semicolon, the entire list is terminated by a terminator semicolon.
Depending on the DirectX file format definition the object definition may contain more data. If frames are utilized, several objects are created according the frames' definitions. The identification code of the connected objects is not accessible in the program. Therefore, in such objects the surface, the texture or alike cannot be determined. If the object definition contains the object's texture, then the texture is read out of the file specified. The precondition is the texture being in the BMP or JPG format (Formats PPM and TGA are not supported). If an object contains several material definitions, the object material is set pursuant the first of the definitions. From the other materials only the diffuse color definition is used.
The element returns the
identification number of the created object. After object creation is, in some cases, needed to use the
object normalization (different 3D editors use different object scales) and
calculate normals. To create objects you can use the
MilkShape editor, which you can find on the distribution CD-ROM of the Peter application.
Full Html Context Help of The Peter - Gemtree Software & Children Programming