Scene FilesNovember 9, 2001 This document describes the LWSC version 3 file format for 3D scenes used by LightWave 6.0 and later. At this point, it's an incomplete rough draft that's missing descriptions of most of the keywords. But the introductory information will allow you to parse the file at least, and the semantics of most of the keywords can be deduced. If you've worked with version 1 of the format (version 2 was an unreleased interim format), version 3 will seem quite familiar. Scene files are still text files containing keyword-value pairs. The most important difference is in the way keyframe data is stored, but obviously there are many others comprising features not available in LightWave prior to 6.0. Item Numbers When a scene file needs to refer to specific items to establish item relationships (parenting, for example), it uses item numbers. Items are numbered in the order in which they appear in the file, starting with 0. Item numbers can be written in one of two ways, depending on which keyword they're used with. In general, if the type of the item (object, bone, light, camera) can be determined from the keyword alone, the item number will simply be the ordinal, written as a decimal integer. When the keyword can be used with items of more than one type, the item number is an unsigned integer written as an 8-digit hexadecimal string, the format produced by the C-language "%8X" print format specifier, and the high bits identify the item type. The first hex digit (most significant 4 bits) of the hex item number string identifies the item type.
The other digits make up the item number, except in the case of bones. For bones, the next 3 digits (bits 16-27) are the bone number and the last 4 digits (bits 0-15) are the object number for the object the bone belongs to. Some examples:
Blocks Information in a scene file is organized into blocks, the ASCII text analog of the chunks described in the IFF specification. Each block consists of an identifier or name followed by some data. The format of the data is determined by the block name. Block names resemble C-style identifiers. In particular, they never contain spaces or other non-alphanumeric characters. A single-line block is delimited by the newline that terminates the line. Multiline blocks are delimited by curly braces (the { and } characters, ASCII codes 123 and 125). The name of a multiline block follows the opening curly brace on the same line. The curly brace and the name are separated by a single space. The data follows on one or more subsequent lines. Each line of data is indented using two spaces. The closing brace is on a line by itself and is not indented. Individual data elements are separated from each other by a single space. String data elements are enclosed in double quotes and may contain spaces. Blocks can be nested. In other words, the data of a block can include other blocks. A block that contains nested blocks is always a multiline block. At each nesting level, the indention of the data is incremented by two additional spaces. SingleLineBlock data { MultiLineBlock data { NestedMultiLineBlock data } } Envelopes An envelope defines a function of time. For any animation time, an envelope's parameters can be combined to generate a value at that time. Envelopes are used to store position coordinates, rotation angles, scale factors, camera zoom, light intensity, texture parameters, and anything else that can vary over time. The envelope function is a piecewise polynomial curve. The function is tabulated at specific points, called keys. The curve segment between two adjacent keys is called a span, and values on the span are calculated by interpolating between the keys. The interpolation can be linear, cubic, or stepped, and it can be different for each span. The value of the function before the first key and after the last key is calculated by extrapolation. In scene files, an envelope is stored in a block named Envelope that contains one or more nested Key blocks and one Behaviors block. { Envelope nkeys Key value time spantype p1 p2 p3 p4 p5 p6 Key ... Behaviors pre post } The nkeys value is an integer, the number of Key blocks in the envelope. Envelopes must contain at least one Key block. The contents of a Key block are as follows.
The Behaviors block contains two integers.
The source code in the sample/envelope directory of the LightWave plug-in SDK demonstrates how envelopes are evaluated. Scene
Objects
|