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

Teddy::Imports::LWLayer Class Reference

LWLayer. More...

#include <LWLayer.h>

Inheritance diagram for Teddy::Imports::LWLayer:

Inheritance graph
[legend]
Collaboration diagram for Teddy::Imports::LWLayer:

Collaboration graph
[legend]
List of all members.

Public Methods

 LWLayer (LWModel *model, const std::string &name, U2 flags, Vector pivot, int parent)
 Constructor for submeshes. More...

virtual ~LWLayer ()
 Destructor. More...

LWClipgetClip (VX clip_index)
LWModelgetModel ()
void processLayer ()
 Returns true if next layer. More...


Protected Methods

bool processChunk ()
 Process a LWOB & LWO2 file chunks. More...

void pointList ()
void polygonList ()
void faceList ()
void surfaceList ()
void curveList ()
 LWOB Read curve list. More...

void patchList ()
 LWOB Read patch list. More...

void surface_sc ()
void vertexMapping_ID4_U2_S0_d ()
void polygonTags_ID4_d ()
void envelope_U4_sc ()
void clip_U4_sc ()
void surf_S0_S0_sc ()
void boundingBox_VEC12_VEC12 ()
void descriptionLine_S0 ()
void comments_S0 ()
void thumbnail_U2_U2_d ()

Protected Attributes

int parent_layer
 Parent layer number. More...

Vector pivot
 Pivot point of layer. More...

U2 flags
 Layer flags. More...

LWFilef
LWModelmodel
 Model which contains this Layer. More...

std::string description_line
std::string commentary_text
string_to_Model models
string_to_LWSurface surfaces
U4_to_Vertex vertices
 These are shared among surfaces. More...

U4_to_Face faces
U4_to_LWEnvelope envelopes
U4_to_LWClip clips
U4 num_vertices
U4 num_faces
U4 num_surfaces
U4 num_envelopes
U4 num_clips
U4 current_surface
Vector bbox_min
Vector bbox_max

Detailed Description

LWLayer.

Todo:
docs

Definition at line 73 of file LWLayer.h.


Constructor & Destructor Documentation

Teddy::Imports::LWLayer::LWLayer LWModel   model,
const std::string &    name,
U2    flags,
Vector    pivot,
int    parent
 

Constructor for submeshes.

Definition at line 60 of file LWLayer.cpp.

References bbox_max, bbox_min, current_surface, Teddy::SysSupport::dmsg, f, flags, Teddy::SysSupport::M_LWO, model, num_clips, num_envelopes, num_faces, num_surfaces, num_vertices, parent_layer, pivot, Teddy::Imports::U2, and Vector.

Teddy::Imports::LWLayer::~LWLayer   [virtual]
 

Destructor.

Definition at line 108 of file LWLayer.cpp.


Member Function Documentation

void Teddy::Imports::LWLayer::boundingBox_VEC12_VEC12   [protected]
 

LWO2 Bounding Box

BBOX { min[VEC12], max[VEC12] }

This is an optional chunk which can be included to store the bounding box for the vertex data in a layer. The min and max vectors are the lower and upper corners of the bounding box.

Definition at line 874 of file LWLayer.cpp.

References bbox_max, bbox_min, and f.

Referenced by processChunk.

void Teddy::Imports::LWLayer::clip_U4_sc   [protected]
 

LWO2 Image or Sequence Definition

CLIP { index[U4], attributes[SUB-CHUNK] * }

Each CLIP chunk defines a image which can be used for applying as a texture map in surfaces. The term 'clip' is used to describe these since they may be time-varying sequences or animations rather than just stills. The index identifies this clip uniquely and may be any non-zero value less than 0x1000000. The attributes which define the source imagery and modifiers follow as a variable list of sub-chunks

Definition at line 803 of file LWLayer.cpp.

References clips, Teddy::SysSupport::emsg, f, Teddy::SysSupport::M_LWO, num_clips, and Teddy::Imports::U4.

Referenced by processChunk.

void Teddy::Imports::LWLayer::comments_S0   [protected]
 

LWO2 Commentary Text

TEXT { comment[S0] }

This is another optional chunk which can be used to hold comments about the object. The text is just like the DESC chunk, but it can be about any subject, it may contain newline characters and it does not need to be particularly short.

Definition at line 905 of file LWLayer.cpp.

References commentary_text, and f.

Referenced by processChunk.

void Teddy::Imports::LWLayer::curveList   [protected]
 

LWOB Read curve list.

Definition at line 437 of file LWLayer.cpp.

Referenced by processChunk.

void Teddy::Imports::LWLayer::descriptionLine_S0   [protected]
 

LWO2 Description Line

DESC { description-line[S0] }

This is an optional chunk which can be used to hold an object description. This should be a simple line of upper and lowercase characters, punctuation and spaces which describes the contents of the object file. There should be no control characters in this text string and it should generally be kept short.

Definition at line 891 of file LWLayer.cpp.

References description_line, and f.

Referenced by processChunk.

void Teddy::Imports::LWLayer::envelope_U4_sc   [protected]
 

LWO2 Envelope Definition

ENVL { index[U4], attributes[SUB-CHUNK] * }

Each ENVL chunk defines the time-varying curve for a single parameter channel. The index is used to identify this envelope uniquely, and can have any non-zero value less than 0x1000000. Following the index is a series of sub-chunks, which are like normal IFF chunks except that their sizes are specified by short integers instead of longs. The number of sub-chunks may vary depending on the complexity of the envelope, so sub-chunks should be read from the file until as many bytes as the chunk size specifies have been read. New types of sub-chunks may be introduced as the program capabilities increase, but any unknown sub-chunks may be skipped over by using their size.

Definition at line 779 of file LWLayer.cpp.

References envelopes, f, num_envelopes, and Teddy::Imports::U4.

Referenced by processChunk.

void Teddy::Imports::LWLayer::faceList   [protected]
 

Todo:
Support for points and lines

LWOB POLS { ( numvert[U2], vert[U2] # numvert, surf[I2] )* }

This chunk contains a list of all the polygons in an object. Each entry consists of a short integer specifying the number of vertices in the polygon followed by that many short integers specifying the vertices themselves (as indices into the points list) followed by a short integer specifying which surface is used by the polygon (as an index into the surfaces list). The number of vertices in a polygon currently may vary from one to 200. The vertex list for each polygon should begin at a convex vertex and proceed clockwise as seen from the visible side of the polygon (LightWave 3D polygons are single-sided, except for those whose surfaces have the double-sided flag set). Polygons should be read from the file until as many bytes as the chunk size specifies have been read.

Since the points in the PNTS chunk are referenced using two-byte integers, the effective maximum number of points in a LightWave object file is 65,536. This is an inherient limitation of this current format.

A negative surface number for a polygon indicates that the polygon has detail polygons (which are drawn on top of the main polygon and may be coplanar with it). In this case, the next number in the file is a short integer specifying how many detail polygons belong to the current polygon. This is followed by a list of those detail polygons, where each entry is of the same format as described above for regular polygons (except that the detail polygons cannot have details of their own). The list of regular polygons then resumes. To determine which surface is used by a polygon with a negative surface number, the absolute value of that number should be used. Note, however, that detail polygons are mostly obsolete, so even though they may be recognized by LightWave and old files contain them, they should be ignored.

Definition at line 321 of file LWLayer.cpp.

References Teddy::SysSupport::dmsg, Teddy::SysSupport::emsg, f, faces, Teddy::SysSupport::M_LWO, model, Teddy::Models::Model::Model, models, num_faces, num_surfaces, num_vertices, Teddy::Imports::U4, and vertices.

Referenced by processChunk.

LWClip * Teddy::Imports::LWLayer::getClip VX    clip_index
 

Definition at line 186 of file LWLayer.cpp.

References clips, and Teddy::Imports::VX.

LWModel * Teddy::Imports::LWLayer::getModel  
 

Definition at line 181 of file LWLayer.cpp.

References model.

void Teddy::Imports::LWLayer::patchList   [protected]
 

LWOB Read patch list.

Definition at line 443 of file LWLayer.cpp.

Referenced by processChunk.

void Teddy::Imports::LWLayer::pointList   [protected]
 

Todo:
Make use of real pivot point

LWOB and LOW2 PNTS { point-location[VEC12] * }

This chunk contains a list of the X, Y, and Z coordinates of all the points in an object. Since each coordinate has three components, and each component is stored as a four byte floating point number, the number of points in an object can be determined by dividing the size in bytes of the PNTS chunk by 12.

By convention, the +X direction is to the right or east, the +Y direction is upward, and the +Z direction is forward or north. For models of real-world objects, the unit size is usually considered to be one meter. The coordinates are specified relative to an object's pivot point. See the LightWave Modeler manual for more information about LightWave 3D's geometric conventions.

Points in the PNTS chunk are numbered in the order they occur, starting with zero. This index is then used by polygons to define their vertices. The PNTS chunk must be before the POLS, CRVS, and PCHS chunks in the file.

Definition at line 219 of file LWLayer.cpp.

References Teddy::SysSupport::dmsg, Teddy::SysSupport::emsg, f, Teddy::SysSupport::M_LWO, num_vertices, pivot, SCALE, Teddy::Imports::U4, Vector, and vertices.

Referenced by processChunk.

void Teddy::Imports::LWLayer::polygonList   [protected]
 

LWO2 Polygon List

POLS { type[ID4], ( numvert+flags[U2], vert[VX] # numvert )* }

This chunk contains a list of polygons for the current layer. The 'type' code indicates the polygon type and can be FACE, CURV, PACH, or possibly other values. Each entry starts with a short integer specifying the number of vertices in the polygon. The 6 high-order bits of the number of vertices are flags bits with different meaning for each polygon type, so there are a maximum of 1023 vertices per polygon. The vertex list is the specified number of two or four byte VX vertex indices (relative to the most recent points list). The vertex list for each polygon should begin at a convex vertex and proceed clockwise as seen from the visible side of the polygon (LightWave 3D polygons are single-sided, except for those whose surfaces have the double-sided flag set). Polygons should be read from the file until as many bytes as the chunk size specifies have been read.

Definition at line 552 of file LWLayer.cpp.

References Teddy::SysSupport::dmsg, Teddy::SysSupport::emsg, f, faces, flags, Teddy::Imports::ID4, Teddy::SysSupport::M_LWO, num_faces, num_vertices, Teddy::Imports::U2, Teddy::Imports::U4, and vertices.

Referenced by processChunk.

void Teddy::Imports::LWLayer::polygonTags_ID4_d   [protected]
 

LWO2 Polygon Tag Mapping

PTAG { type[ID4], ( poly[VX], tag[U2] )* }

This chunk contains the all the tags of a given type for some subset of the polygons defined in the preceding POLS chunk. The type of the tag association is given by the first element of the chunk and is an normal 4-character ID code. The rest of the chunk is a list of polygon/tag associations. The polygon is identified by its index into the previous POLS chunk, and the tag is given by its index into the previous TAGS chunk. Any number of polygons may be mapped with this type of tag, and mappings should be read from the file until as many bytes as the chunk size specifies have been read.

Polygon tags types and their values are extensible, but there are some pre-defined types. The SURF type tags each polygon with the name of its surface. In LightWave 3D terminology, a "surface" is defined as a named set of shading attributes and may be described in the object file in SURF chunks. Another pre-defined type is PART which describes what aspect of the model each polygon belongs to, and SMGP which names the smoothing group for each polygon. Not all polygons have a value for every tag type, and the behavior for polygon which lack a certain tag depends on the type.

Definition at line 676 of file LWLayer.cpp.

References Teddy::Models::Model::add, Teddy::SysSupport::dmsg, Teddy::SysSupport::emsg, f, faces, Teddy::Imports::ID4, LWFILE_OPTION_SKIP_MATERIAL_M, Teddy::SysSupport::M_LWO, model, Teddy::Models::Model::Model, models, surfaces, Teddy::Imports::U4, and Teddy::Imports::VX.

Referenced by processChunk.

bool Teddy::Imports::LWLayer::processChunk   [protected]
 

Process a LWOB & LWO2 file chunks.

Definition at line 114 of file LWLayer.cpp.

References boundingBox_VEC12_VEC12, clip_U4_sc, comments_S0, curveList, descriptionLine_S0, Teddy::Imports::did, Teddy::SysSupport::dmsg, envelope_U4_sc, f, faceList, ID_BBOX, ID_CLIP, ID_CRVS, ID_DESC, ID_ENVL, ID_ICON, ID_LAYR, ID_LWLO, ID_LWO2, ID_LWOB, ID_PCHS, ID_PNTS, ID_POLS, ID_PTAG, ID_SRFS, ID_TAGS, ID_TEXT, Teddy::SysSupport::M_LWO, model, patchList, pointList, polygonList, polygonTags_ID4_d, surf_S0_S0_sc, surface_sc, surfaceList, thumbnail_U2_U2_d, Teddy::Imports::U4, and vertexMapping_ID4_U2_S0_d.

Referenced by processLayer.

void Teddy::Imports::LWLayer::processLayer  
 

Returns true if next layer.

Definition at line 81 of file LWLayer.cpp.

References Teddy::Models::Model::children, Teddy::SysSupport::dmsg, f, Teddy::SysSupport::M_LWO, model, Teddy::Models::Model::Model, and processChunk.

void Teddy::Imports::LWLayer::surf_S0_S0_sc   [protected]
 

Todo:
Material inheritance

LWO2 Surface Definition

SURF { name[S0], source[S0], attributes[SUB-CHUNK] * }

Each SURF chunk describes the shading attributes of a particular surface. These chunks begin with the name of the surface being described plus the name of the source surface. If the source name is non-null, then this surface is derived from the source surface. The base attributes of the source surface can be overridden by this surface, and texture blocks can be added to the source surface. The material attributes follow as a variable list of sub-chunks.

Definition at line 833 of file LWLayer.cpp.

References Teddy::SysSupport::dmsg, Teddy::SysSupport::emsg, f, Teddy::SysSupport::M_LWO, and surfaces.

Referenced by processChunk.

void Teddy::Imports::LWLayer::surface_sc   [protected]
 

LWOB SURF { name[S0], attributes[SUB-CHUNK] * }

Each SURF chunk describes the surface attributes of a particular surface. These chunks begin with the name of the surface being described. Following the name is a series of sub-chunks, which are like normal IFF chunks except that their sizes are specified by short integers instead of longs. It is likely that the variety of sub-chunks will grow as new surface attributes are added to the program, but any unknown sub-chunks may be skipped over by using the size. Sub-chunks should be read from the file until as many bytes as the chunk size specifies have been read.

Definition at line 460 of file LWLayer.cpp.

References Teddy::SysSupport::emsg, f, Teddy::SysSupport::M_LWO, and surfaces.

Referenced by processChunk.

void Teddy::Imports::LWLayer::surfaceList   [protected]
 

Definition at line 266 of file LWLayer.cpp.

References Teddy::Models::Model::add, f, model, Teddy::Models::Model::Model, models, num_surfaces, and surfaces.

Referenced by processChunk.

void Teddy::Imports::LWLayer::thumbnail_U2_U2_d   [protected]
 

LWO2 Thumbnail Icon Image

ICON { encoding[U2], width[U2], data[U1] * }

This optional chunk contains an iconic or thumbnail image for the object which can be used when viewing the file in a browser. The encoding is a code for the data format which can only be zero for now meaning uncompressed, unsigned bytes as RGB triples. The width specifies the number of pixels contained in each row of the image. The data consists of rows of pixels (RGB triples for now), and the height of the image is determined by the length of the data.

Definition at line 923 of file LWLayer.cpp.

References Teddy::SysSupport::dmsg, f, Teddy::SysSupport::M_LWO, Teddy::Imports::U1, and Teddy::Imports::U2.

Referenced by processChunk.

void Teddy::Imports::LWLayer::vertexMapping_ID4_U2_S0_d   [protected]
 

LWO2 Vertex Mapping

VMAP { type[ID4], dimension[U2], name[S0], ( vert[VX], value[F4] # dimension )* }

This chunk contains a set of floating point vectors associated with a set of vertices. Each one has a type which is a four-character ID code, a dimension and a name string. After that follows a list of vertex / vector pairs, with the vertex given by a vertex index in VX format and an array of "dimension" floating-point values. There can be any number of these chunks, although they should all have different types or names.

Some possible type codes are TXUV for UV mapping coordinates, MNVW for MetaNURBS vertex weights, MORF for vector offsets defining an alternate object shape, SPOT for alternate vertex positions, RGBA for coloring, etc.

Definition at line 500 of file LWLayer.cpp.

References Teddy::Imports::did, Teddy::SysSupport::dmsg, f, Teddy::Imports::F4, Teddy::Imports::ID4, ID_MNUW, ID_MORF, ID_RGBA, ID_SPOT, ID_TXUV, Teddy::SysSupport::M_LWO, Teddy::Imports::U2, and Teddy::Imports::VX.

Referenced by processChunk.


Member Data Documentation

Vector Teddy::Imports::LWLayer::bbox_max [protected]
 

Definition at line 127 of file LWLayer.h.

Referenced by boundingBox_VEC12_VEC12, and LWLayer.

Vector Teddy::Imports::LWLayer::bbox_min [protected]
 

Definition at line 126 of file LWLayer.h.

Referenced by boundingBox_VEC12_VEC12, and LWLayer.

U4_to_LWClip Teddy::Imports::LWLayer::clips [protected]
 

Definition at line 119 of file LWLayer.h.

Referenced by clip_U4_sc, and getClip.

std::string Teddy::Imports::LWLayer::commentary_text [protected]
 

Definition at line 113 of file LWLayer.h.

Referenced by comments_S0.

U4 Teddy::Imports::LWLayer::current_surface [protected]
 

Definition at line 125 of file LWLayer.h.

Referenced by LWLayer.

std::string Teddy::Imports::LWLayer::description_line [protected]
 

Definition at line 112 of file LWLayer.h.

Referenced by descriptionLine_S0.

U4_to_LWEnvelope Teddy::Imports::LWLayer::envelopes [protected]
 

Definition at line 118 of file LWLayer.h.

Referenced by envelope_U4_sc.

LWFile* Teddy::Imports::LWLayer::f [protected]
 

Definition at line 109 of file LWLayer.h.

Referenced by boundingBox_VEC12_VEC12, clip_U4_sc, comments_S0, descriptionLine_S0, envelope_U4_sc, faceList, LWLayer, pointList, polygonList, polygonTags_ID4_d, processChunk, processLayer, surf_S0_S0_sc, surface_sc, surfaceList, thumbnail_U2_U2_d, and vertexMapping_ID4_U2_S0_d.

U4_to_Face Teddy::Imports::LWLayer::faces [protected]
 

Definition at line 117 of file LWLayer.h.

Referenced by faceList, polygonList, and polygonTags_ID4_d.

U2 Teddy::Imports::LWLayer::flags [protected]
 

Layer flags.

Definition at line 108 of file LWLayer.h.

Referenced by LWLayer, and polygonList.

LWModel* Teddy::Imports::LWLayer::model [protected]
 

Model which contains this Layer.

Definition at line 110 of file LWLayer.h.

Referenced by faceList, getModel, LWLayer, polygonTags_ID4_d, processChunk, processLayer, and surfaceList.

string_to_Model Teddy::Imports::LWLayer::models [protected]
 

Definition at line 114 of file LWLayer.h.

Referenced by faceList, polygonTags_ID4_d, and surfaceList.

U4 Teddy::Imports::LWLayer::num_clips [protected]
 

Definition at line 124 of file LWLayer.h.

Referenced by clip_U4_sc, and LWLayer.

U4 Teddy::Imports::LWLayer::num_envelopes [protected]
 

Definition at line 123 of file LWLayer.h.

Referenced by envelope_U4_sc, and LWLayer.

U4 Teddy::Imports::LWLayer::num_faces [protected]
 

Definition at line 121 of file LWLayer.h.

Referenced by faceList, LWLayer, and polygonList.

U4 Teddy::Imports::LWLayer::num_surfaces [protected]
 

Definition at line 122 of file LWLayer.h.

Referenced by faceList, LWLayer, and surfaceList.

U4 Teddy::Imports::LWLayer::num_vertices [protected]
 

Definition at line 120 of file LWLayer.h.

Referenced by faceList, LWLayer, pointList, and polygonList.

int Teddy::Imports::LWLayer::parent_layer [protected]
 

Parent layer number.

Definition at line 106 of file LWLayer.h.

Referenced by LWLayer.

Vector Teddy::Imports::LWLayer::pivot [protected]
 

Pivot point of layer.

Definition at line 107 of file LWLayer.h.

Referenced by LWLayer, and pointList.

string_to_LWSurface Teddy::Imports::LWLayer::surfaces [protected]
 

Definition at line 115 of file LWLayer.h.

Referenced by polygonTags_ID4_d, surf_S0_S0_sc, surface_sc, and surfaceList.

U4_to_Vertex Teddy::Imports::LWLayer::vertices [protected]
 

These are shared among surfaces.

Definition at line 116 of file LWLayer.h.

Referenced by faceList, pointList, and polygonList.


The documentation for this class was generated from the following files: