View Full Version : Question about Lightwave object file format

10-08-2003, 06:49 PM

I am writing some code to load and parse a lightwave object (LWO) file. I have sucessfully read each chunk in the file, but I am having some trouble parsing the data within the POLS chunk.

According to the Lightwave object file format specification at http://www.newtek.com/products/lightwave/developer, the first four bytes in the chunk (after getting the chunk tag ID and chunk size) should be characters, indicating the type of polygons defined in the POLS chunk. But, alas, when I grab the first four bytes, they are not characters...

Could anyone familiar with the format offer any advice on parsing the data in the POLS chunk?

Tony Chamblee

10-09-2003, 08:10 AM
Tony, I can confirm that what you say is correct. My own code reads these four bytes and checks that they are "FACE". If not I don't process the chunk so I cannot comment on other situations. My only useful suggestion is to check your chunk reader is actually reading from the correct position in the file.

Good luck.

10-10-2003, 02:46 AM
Thank you for the reply. I have checked, and I am certain my chunk reader is in the correct position in the file...it parses the entire file and prints out the name and size of each chunk. I have viewed the object file with a hex editor, and it appears to confirm that the next four bytes are not characters. The object file is included with Lightwave 6.1 in the sample objects...I believe it is under Objects\Robots\ApeBot\Jaw.lwo, or something similar to that, if you want to check it out.

The funny thing is, I modified my chunk reader to assume that there were not four characters there; I just assume the next item is the number of vertices (because it's obvious from the hex editor that numerical values are immediately after the characters 'P''O''L''S' and then the four bytes indicating chunk size), then the actual vertices follow...and my file reader works fine. It will scan through the POLS chunk and print out all the vertices.

I'll just keep hacking at it.

Best of luck,


10-10-2003, 03:58 AM
Yeah, the bytes are 0x00000278, which doesn't make sense to me unless the ID is missing. Strange thing is that it still loads in modeller. Maybe someone from NewTek can explain it.

10-10-2003, 02:14 PM
Maybe it's some sort of way to minimize file size. Perhaps if the very next byte is not a character, if perhaps it is zero, then you should assume that the polygons are FACE polygons, since they are the most common type. But why would this not be included in the file specification?

Where could I contact someone from NewTek to ask about this? Is it possible for me to get a reply on this forum?

10-10-2003, 04:10 PM
Generally it's impossible to get a reply from Newtek here, despite the "Support" in the forum title. Try emailing them but don't expect a quick answer :rolleyes:

Adrian Lopez
10-11-2003, 01:49 AM
It's probably a file-format issue.

If you open the Jaw.lwo file and save it as NewJaw.lwo you'll notice that NewJaw.lwo contains the expected values. Furthermore, if you compare the two files you'll notice that Jaw.lwo contains the string LWOB after the first 8 bytes, whereas NewJaw.lwo contains the string LWO2. Files with LWOB must refer to the pre-6.0 object format.

Is the LWOB format documented somewhere?

10-11-2003, 04:27 PM

Thank you Adrian. I hadn't even noticed that there were two different formats for the object files. I'm pretty sure this will solve all of my problems.



10-11-2003, 04:37 PM
I have few frends how are making engins for Lightwave. If you want you can visit oure page www.addict-labs.org and there you have demos who was all made on Lightwave.

There you have about polys

Polygon List
POLS { type[ID4], ( numvert+flags[U2], vert[VX] # numvert )* }
A list of polygons for the current layer. Possible polygon types include:
"Regular" polygons, the most common.
Catmull-Rom splines. These are used during modeling and are currently ignored by the renderer.
Subdivision patches. The POLS chunk contains the definition of the control cage polygons, and the patch is created by subdividing these polygons. The renderable geometry that results from subdivision is determined interactively by the user through settings within LightWave. The subdivision method is undocumented.
Metaballs. These are single-point polygons. The points are associated with a VMAP of type MBAL that contains the radius of influence of each metaball. The renderable polygonal surface constructed from a set of metaballs is inferred as an isosurface on a scalar field derived from the sum of the influences of all of the metaball points.
Line segments representing the object's skeleton. These are converted to bones for deformation during rendering.
Each polygon is defined by a vertex count followed by a list of indexes into the most recent PNTS chunk. The maximum number of vertices is 1023. The 6 high-order bits of the vertex count are flag bits with different meanings for each polygon type. (Currently only two flags are defined: the low two bits are continuity control point toggles for CURV polygons. Other flags may be defined in the future.) When reading POLS, remember to mask out the flags to obtain numverts.
When writing POLS, 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 polygons are single-sided (although double-sidedness is a possible surface property), and the normal is defined as the cross product of the first and last edges.

10-11-2003, 06:35 PM
You might want to try using code from the Lightwave object loader in the SDK (if you're using LW02 files). I've written parsers to read specific information from files before (e.g., just points and polygons), but it tends to get messy. The code in the SDK loads everything for you, plus it's relatively clean and seems to work very well.

10-12-2003, 12:30 AM
The documentation for scene files in the developers section is incomplete...does anyone know where I can find some information on parsing the scene files?

Adrian Lopez
10-12-2003, 03:09 PM
The limited documentation is really disappointing. Right now I'm trying to figure out how Layout interprets curves with mixed key values, because the way it behaves does not agree with the description in the SDK docs. For instance, when a Bezier span is preceded by a TCB, Hermite, Linear or Stepped span, it seems that the p5 curve parameter of this preceding keyframe is used as a tangent for the beginning of the Bezier span.

Frustrations aside, it should be possible to figure out most scene file blocks by comparing each block to its counterpart in Layout. You can modify settings in Layout - or the values in the scene file - to deduce the syntax and semantics of each scene file block. For example, if you compare the ShadowOptions block to the shadow options in Layout you'll notice that the ShadowOptions value is an OR'ed combination of 3 different flags: 0x04 for Receive Shadow, 0x02 for Cast Shadow, and 0x01 for Self Shadow.

I hope LW8 comes with complete documentation for the Modeler and Layout file formats.

10-12-2003, 03:15 PM
Sometimes I don't even bother parsing the scene file but instead write a LScript which saves just the data I need in an easily parseable format. Depending on what you're doing, though, this may not be a solution.

10-12-2003, 03:58 PM
Hmm... I need to be able to load scene files and render/animate scenes created in Layout. I am a member of the Laboratory for Recreational Computing at the University of North Texas. I am currently engaged in a personal research project writing a 3D game. I need to be able to parse the data contained in a scene file and render/animate a character. I can parse Lightwave object files, but because of the limited documentation about scene files, the process is painstakingly slow.

I've managed to find the documentation for version 1 of the scene file format, so perhaps I'll use that and try to work through the differences between formats 3 and 1.

By the way, I'm also looking for an experienced 3D modeler to create character animation, if anyone is interested.

Thank you all again for your help.

Adrian Lopez
10-12-2003, 04:43 PM
There's a more complete version of the scene file docs here (http://mywebpages.comcast.net/erniew/lwsdk/docs/filefmts/lwsc.html), although it's still not complete.

10-12-2003, 06:52 PM
No bone information is covered in that scene file?


04-24-2009, 07:51 AM

Another question about LWO format :
I have a VMPA (and not VMAP) chunk, with always a 8 bytes size

does someone knows what it is ?