Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

LWScene.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software{} you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation{} either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY{} without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library{} if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: LWScene.cpp,v 1.1 2002/02/16 12:41:39 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/TeddyConfig.h"
00026 #if defined( TEDDY_INCLUDE_LW_SCENE )
00027 
00028 
00029 #include "Teddy/Imports/LWSceneParser.h"
00030 #include "Teddy/Imports/LWSceneFile.h"
00031 
00032 
00033 namespace Teddy   {
00034 namespace Imports {
00035 
00036 
00037 void LWSceneParser::LWSC(){
00038     lws_version = file->read_int();
00039 }
00040 
00041 
00042 /*
00043     FirstFrame <frame number>
00044 
00045     example:  FirstFrame 1
00046 
00047     The FirstFrame function provides the starting frame for the rendering process. 
00048     This is a global function for all LightWave functions that use frame 
00049     information
00050 */
00051 void LWSceneParser::FirstFrame(){
00052     first_frame = file->read_int();
00053 }
00054 
00055 
00056 /*
00057     LastFrame <frame number>
00058 
00059     example:  LastFrame 30
00060 
00061     The LastFrame function provides the last frame to be rendered.  This also 
00062     supplies the defaults for the MakePreview function and the current frame 
00063     slider from Layout with the last frame information.  This is a global 
00064     function for all LightWave functions that use frame information.
00065 */
00066 void LWSceneParser::LastFrame(){
00067     last_frame = file->read_int();
00068 }
00069 
00070 
00071 /*
00072     FrameStep <int>
00073 
00074     example:  FrameStep 1
00075 
00076     The FrameStep function provides the number of frames to increment between 
00077     rendered frames during the rendering process.  
00078 */
00079 void LWSceneParser::FrameStep(){
00080     frame_step = file->read_int();
00081 }
00082 
00083 
00084 /*
00085     FramesPerSecond <float>
00086 
00087     example:  FramesPerSecond 30.000000
00088 
00089     The FramesPerSecond function provides the number of frames per second.
00090     This controls the duration of each frame. 
00091 */
00092 void LWSceneParser::FramesPerSecond(){
00093     frames_per_second = file->read_int();
00094 }
00095 
00096 
00097 /*
00098     PreviewFirstFrame nfirst
00099     PreviewLastFrame nlast
00100     PreviewFrameStep nstep 
00101 
00102     The frame range and step size for previewing. These may be unrelated
00103     to the values for rendering. They also control the visible ranges of
00104     certain interface elements, for example the frame slider in the main
00105     window. 
00106 */
00107 void LWSceneParser::PreviewFirstFrame(){
00108     this->preview_first_frame = file->read_int();
00109 }
00110 void LWSceneParser::PreviewLastFrame(){
00111     this->preview_last_frame = file->read_int();
00112 }
00113 void LWSceneParser::PreviewFrameStep(){
00114     this->preview_frame_step = file->read_int();
00115 }
00116 
00117 
00118 /*
00119     CurrentFrame nframe 
00120 
00121     The frame displayed in the interface when the scene is loaded.
00122 */
00123 void LWSceneParser::CurrentFrame(){
00124     this->current_frame = file->read_int();
00125 }
00126 
00127 
00128 void LWSceneParser::Plugin(){
00129     LwsToken tmp;
00130     do{
00131         tmp = file->read_token();
00132     }while(
00133         (tmp != LWS_END_PLUGIN) &&
00134         (tmp != LWS_ERROR     ) &&
00135         (tmp != LWS_EOF       )
00136     );
00137 }
00138 
00139 
00140 void LWSceneParser::EndPlugin(){}
00141 
00142 
00143 };  //  namespace Imports
00144 };  //  namespace Teddy
00145 
00146 
00147 #endif  //  TEDDY_INCLUDE_LW_SCENE
00148 
00149 
00150 /*
00151   The LightWave scene file is a standard ASCII text file that contains the 
00152   information necessary to reconstruct a LightWave Scene.
00153 
00154   In addition to the objects, lights and camera, the scene file contains 
00155   standard Layout settings that are set on a per scene basis.  Layout 
00156   information that is more "permanent" is saved in the LightWave config 
00157   file. (For LightWave Config File information see Chapter 10.)
00158 
00159   The object geometry is not included in the scene file.  For each object 
00160   instance the objects path and filename are listed along with other scene 
00161   specific attributes.  The objects are stored as seperate binary files 
00162   that contain the object geometry along with the objects surface attributes.
00163 
00164   Objects are not saved when the Save Scene function is selected from the 
00165   Scene Menu.  The user is required to save these by going to the Objects Menu 
00166   and selecting either the Save Object or Save All Objects function.  This 
00167   saves each object as an individual file and sets the path and filename that 
00168   will be saved for that object instance in the scene file.
00169 
00170   Values are listed to 6 decimal places.
00171   Position values are given in meters.
00172   Rotation values are given in degrees.
00173   Scaling values are given as a multiplier.
00174   Frame numbers are given as a value greater than or equal to 0.
00175 
00176   Color values are given as an Red, Green, and Blue triple, each with a range 
00177   of 0 to 255.
00178 
00179   TIS: Appears to be floats in range 0..1 in LWSC 3
00180 
00181 The scene files basic structure is divided into separate logical sections.  
00182 Each section relates to a group of LightWave's functions.  These sections 
00183 are arranged in an order similar to the menu structure in LightWave's Layout.  
00184 
00185     Scene
00186     Objects
00187     Lights
00188     Camera
00189     Effects
00190     Render
00191     Layout Options
00192 
00193   The Scene Section consists of the LightWave scene file header and frame 
00194   information.  The functions in this section always produce a listing 
00195   and have no optional functions.
00196 
00197 The following scene functions are listed in the order in which they appear 
00198 in the scene file.
00199 
00200   Italicized entries denote function labels and are not true function names.
00201 
00202         LWSC
00203         Scene File Version
00204 
00205         FirstFrame
00206         LastFrame
00207         FrameStep
00208         FramesPerSecond
00209 
00210 Item Numbers
00211 
00212 When a scene file needs to refer to specific items to establish item
00213 relationships (parenting, for example), it uses item numbers. Items
00214 are numbered in the order in which they appear in the file, starting
00215 with 0.
00216 
00217 Item numbers can be written in one of two ways, depending on which
00218 keyword they're used with. In general, if the type of the item
00219 (object, bone, light, camera) can be determined from the keyword
00220 alone, the item number will simply be the ordinal, written as a
00221 decimal integer. When the keyword can be used with items of more
00222 than one type, the item number is an unsigned integer written as
00223 an 8-digit hexadecimal string, the format produced by the C-language
00224 "%8X" print format specifier, and the high bits identify the item type.
00225 
00226 The first hex digit (most significant 4 bits) of the hex item number
00227 string identifies the item type.
00228 
00229 1 - Object
00230 2 - Light
00231 3 - Camera
00232 4 - Bone
00233 
00234 The other digits make up the item number, except in the case of
00235 bones. For bones, the next 3 digits (bits 16-27) are the bone
00236 number and the last 4 digits (bits 0-15) are the object number
00237 for the object the bone belongs to. Some examples:
00238 
00239 10000000 - the first object
00240 20000000 - the first light
00241 4024000A - the 37th bone (24 hex) in the 11th object (0A hex)
00242 
00243 Blocks
00244 
00245 Information in a scene file is organized into blocks, the ASCII
00246 text analog of the chunks described in the IFF specification.
00247 Each block consists of an identifier or name followed by some
00248 data. The format of the data is determined by the block name.
00249 Block names resemble C-style identifiers. In particular, they
00250 never contain spaces or other non-alphanumeric characters.
00251 
00252 A single-line block is delimited by the newline that terminates
00253 the line. Multiline blocks are delimited by curly braces (the { and }
00254 characters, ASCII codes 123 and 125). The name of a multiline block
00255 follows the opening curly brace on the same line. The curly brace
00256 and the name are separated by a single space. The data follows
00257 on one or more subsequent lines. Each line of data is indented
00258 using two spaces. The closing brace is on a line by itself and
00259 is not indented.
00260 
00261 Individual data elements are separated from each other by a
00262 single space. String data elements are enclosed in double
00263 quotes and may contain spaces.
00264 
00265 Blocks can be nested. In other words, the data of a block
00266 can include other blocks. A block that contains nested
00267 blocks is always a multiline block. At each nesting level,
00268 the indention of the data is incremented by two additional
00269 spaces. 
00270 
00271    SingleLineBlock data
00272    { MultiLineBlock
00273      data
00274      { NestedMultiLineBlock
00275        data
00276      }
00277    }
00278 */
00279