Skip to content

Terrev/LWO-to-OBJ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LWO-to-OBJ

image

A quick and dirty tool for converting Rock Raiders models (.LWO + .UV) to OBJ, just cause I got annoyed there was nothing that handled the texture mapping properly/at all (generating UV coords from the planar texture info, or loading them from the occasional .UV files).

Animations/full creatures and buildings etc are another deal entirely (.LWS files; scenes comprised of LWOs), I make no promises as to if/when I might tackle that but it'd be in a separate, more extensive project.

Select/multiselect as many LWOs as you want and it'll plop the OBJs/MTLs right along side 'em, just remember LRR puts some things in special "Shared" folders so if some textures aren't present, look there.

You can also dump LWOs as XMLs and back again, to make simple tweaks easier (changing texture paths, colors, etc without a hex editor) or to more easily debug why one model may be crashing the game or whatever (comparing it with a working file, removing/changing chunks until it works, etc). It handles the bulk of the chunks used by the game's models (certainly all the chunks the game actually reads), others it doesn't recognize just have their raw hex dumped (so if for some reason you need to tweak them you still can).

Note that due to the nature of floating point numbers, unless you tick the boxes for it, it won't turn those into text by default (it'll dump the raw contents as you'd see in a hex editor instead), to avoid minuscule differences creeping in (you probably won't need to be editing these by hand 99% of the time anyway) . Practically speaking it won't matter in-game even if that does happen, you'd never see a visual difference. It just makes direct file comparison easier when things match truly 100%.

If you wanna know what the hell you're even looking at in the XMLs, here's some format documentation that explains it:

http://www.martinreddy.net/gfx/3d/LWOB.txt

https://sandbox.de/osg/lightwave.htm

The only inaccuracy I found was that angles (i.e. surface smoothing angles) seem to be stored in radians, not degrees. But that doesn't even matter because LRR doesn't read/use any chunks like that. In fact, the only chunks (and SURF sub-chunks) the game pays attention to are:

SRFS
CRVS
POLS
SURF
	TIMG
	COLR
	CTEX
	TTEX
	TFLG
	FLAG
	TSIZ
	TCTR
	TRAN
	DIFF
	LUMI
	REFL
	SPEC
	GLOS

And not even all of those are actually used in practice - same goes for the surface and texture flags.

Oh yeah, and the 4th (supposedly unused) byte in color chunks is typically 00 but the exporter in Lightwave 8 writes FF instead. It's probably of no importance.

Some other notes:

  • Rock Raiders often leaves certain textures unfiltered to create an appearance of crisp seams between bricks on low resolution textures, but sometimes their choices on what textures to do it on were a bit weird - the Power Station is a great example. Basically, if something looks too blurry when you think it should look sharp, try messing with the settings for the texture in whatever program you're using (i.e. in Unity, enable point filtering for the texture under Filter Mode). image
  • Chief's models are flipped on X, inside out. His animation then scales him to -1 on X, making the faces appear the right way around, but with flipped vertex normals. Why? So the lighting from the cursor - behind him - makes him appear lit from the front. I've included an option to flip models on X, so you can get Chief's models as they appear once animated in-game.
  • Vertex normals are generated by the game at runtime, and the game ignores any smoothing angles that may be set in the LWO; hard edges are purely handled by which verts are welded/unwelded.
  • Rock Raiders often adjusts the scale of misc things in the animations (like the minifigure head), keep an eye out for that if you're assembling these together manually.
  • Rock Raiders also has a bug/oversight(?) where models with external .UV files are given unintentional hard edges wherever there's UV seams. If you want the Lava Monster for example to look accurate to its in-game appearance, rather than what the artists likely intended, just do the same thing in a modeling program of your choice. I'm not adding that functionality to this exporter cause it's almost certainly just a bug in the game to begin with, and more importantly it'd be a pain to impliment here lol

Some screenshots of converted models in another program:

image

image

image

image

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages