Guide to sequenced textures in LEGO Rock Raiders

From Research Realm
Revision as of 11:28, 1 December 2024 by Ringtail Raider (talk | contribs)
Sequenced textures are frequently used in LEGO Rock Raiders for steam effects

This modding guide for the 1999 video game LEGO Rock Raiders details how to add sequenced textures to models in the game.

What are sequenced textures?

Chief in-game, using NEW_Captain_Point_Qtalk.lws
FACE0001.bmp (sequence), a minifigure face talking and blinking
FACE0001 sequence
Chief's in-game model (left) uses a sequenced texture for his face to simulate him speaking

In the Windows version of LEGO Rock Raiders, sequenced textures are textures that are animated in-game using a series of bitmap files. Sequenced textures can be used in any object that uses LightWave Scene files for animations. In the original game they are mostly used only for particle effects, such as steam, dust, and lava smoke.[1]

Sequenced textures must consist of a series of BMP files ending in numbers. They should be sequential (test if they have to be) and should usually start at 1, though they don't have to (but method 2 will be needed). Numbers are usually padded 2–4 places in the base game (eg. example0001.bmp is 4 places); in practice 2 places should be enough except for very long sequences.

Where sequenced textures can be used

Sequenced textures can be used on the following objects in LEGO Rock Raiders, grouped by their entry blocks in the Main LEGO Config File:

  • All objects that use AE files:
    • MiniFigureTypes {} – Rock Raider minifigures. Only one type is in the final game, though it is possible to add more.
    • BuildingTypes {} – Rock Raider buildings. Many of these make extensive use of sequenced textures for steam effects.
    • VehicleTypes {} – Rock Raider vehicles, though not their upgrade parts; see below.
    • RockMonsterTypes {} – Creatures such as the Rock Monster, Slimy Slug, and Small Spider.
    • Certain MiscObjects {} entries: Barrier, Dynamite, IceCube, OohScary, Pillar (unused), SpiderWeb.
  • All Chief animations found under Advisor {} and AdvisorPositions640x480 {} (or for other resolutions, AdvisorPositionsWxH {}).
  • Most MiscObjects {} entries: BirdScarer, BoulderExplode, BoulderExplodeIce, ElectricFenceStud, Explosion, Freezer, FreezerHit, LazerHit, LavaErosionSmoke1, LavaErosionSmoke2, LavaErosionSmoke3, LavaErosionSmoke4, LaserShot, LongElectricFenceBeam, MiniTeleportUp, PathDust, Pusher, PusherHit, RechargeSparkle, ShortElectricFenceBeam, SmashPath, UpgradeEffect.
  • Lava smoke, which is defined in the game's executable file for some reason.

Sequenced textures can not be used for:

  • UpgradeTypes {} – All upgrades for vehicles and buildings are LWO files added on top of the main object, and are not tied to any LWS files. (Confirm LWS upgrades can't be used?)
  • Certain MiscObjects {} entries: Boulder, Crystal, ElectricFence, Ore, ProcessedOre. (verify that LWS files can't be used for these)
  • World Textures {} – These are applied to flat walls generated by the game engine. Walls and floors can use models in Eye/Shoulder view, but not animations.
  • All interface images, though FLIC animation files can be used in certain instances.

Specifications

The following requirements:[1]

  • The texture files must be 8-bit per pixel (8bpp) BMP files, like all textures in the game.
  • The texture file names must end with numbers. The first texture in the sequence should be numbered 1, though starting with 0 or a later number is possible using method 2. The numbers should be padded to the same number of digits for all textures in the sequence; eg. 0001 being 4 digits. Numbers are usually padded 2–4 digits in the base game; in practice 2 digits should be enough except for very long sequences.
  • The LightWave Object file using the sequenced texture must specify it as such. The LWO should link to the first file in the sequence and contain " (sequence)" immediately after the file path.
  • The LightWave Object file using the sequenced texture must be used in a LightWave Scene animation file. Ideally, the LWS should be the same number of frames in length as the sequenced texture, or a number of frames in length that is divisible by the number of frames in the sequenced texture, to ensure that the texture loops properly. This is not necessary; however, any sequence frames past the end of the LWS animation will be cut off, and certain standing animations are 0 frames long and will not play any sequenced textures.

Using LightWave 3D 5

This section of the guide details how to create a sequenced texture using LightWave 3D 5. Version 5 was first released in 1995 and was updated to version 5.5 in 1997 and version 5.6 in 1998;[2] one or both of the latter two versions were used in the development of LEGO Rock Raiders. For this guide LightWave 3D 5.6 is being used; this version will still run on Windows 10, but users may find its interface difficult compared to later versions.

The LightWave file formats changed starting in version 6, though many later versions can still save LightWave 5 objects and 5.6 scenes. While these later versions still support sequenced textures, and can load LightWave 5 models that use sequenced textures, they will not properly save sequenced textures in the LightWave 5 format. To get around this, either save your model without sequenced textures and then load it into LightWave 5, or follow the hex editing section below.

In LightWave Modeler (write this out)

Using a hex editor

An LWO file in a hex editor; the relevant values mentioned in this guide have been highlighted with different colors:
  4-byte value for FORM
  4-byte value for SURF
  2-byte value for TIMG
  11-byte  (sequence) flag
  8-byte value for IMSQ (optional)

Assuming you already have a way to save textured LightWave 5 models, adding sequenced textures with a hex editor is relatively simple. For this method you may need a basic understanding of hexadecimal numbers, or a calculator that can convert between decimal and hexadecimal numbers.[1] Any functioning hex editor should work for this; the images in this guide use XVI32, a simple and free hex editor that will run on nearly any version of Windows between Windows 95 and Windows 11.

To mark a texture as being sequenced, change its file path to end with " (sequence)" (hexadecimal: 20 28 73 65 71 75 65 6E 63 65 29). For instance, a file path originally reading C:\\Models\example\sample001.bmp would now be changed to C:\\Models\example\sample001.bmp (sequence). Make sure to include the space between the file extension and the parenthesis; note that this uses a true space (0x20) rather than a null character (0x00).[1] Sequences added using this method will not display properly in LightWave, as they are other values usually applied to sequenced textures. However, LEGO Rock Raiders only looks for the flag marking a texture as a sequence and ignores any other sequence properties. If needed, see the optional section below for a fix.

As this edit will change the file length, additional edits are required to prevent the LWO model from being considered invalid. There are three types of values that need to be edited, two of which will have multiple entries to be edited if multiple sequenced textures are used in the same LWO file. Each of these values is stored in the file as a four-byte ASCII word followed by a hexadecimal number of a certain length. These values are:[1]

  • FORM – The LWO file's "magic number" found at its very beginning. Immediately following it is a four-byte value defining the length of the entire file. This value is highlighted yellow in the above image.
  • SURF – Used at the beginning of each surface entry in the LWO file. Immediately following it is a four-byte value defining the length of that surface entry.
  • TIMG – Used at the beginning of each texture entry in the LWO file; these will always be nested within surface entries. Immediately following it is a two-byte value defining the length of the texture's file path, followed by the file path for the texture (or in the case of sequenced textures, the first file in the sequence). Note that LEGO Rock Raiders only cares about the actual texture file name and not its path.

As the (sequence) flag is 11 bytes long, you will need to add 11 (0x0B in hexadecimal) to each of these values. For multiple sequenced textures, you will need to add 11 to each SURF and TIMG value assigned to the entries containing the sequence, and then add 11 multiplied by the number of sequences to FORM. 2 sequenced textures would be 22 extra bytes (0x16 in hexadecimal), 3 sequenced textures would be 33 extra bytes (0x21), etc.[1] Make sure to only edit the SURF and TIMG entry or entries that contain your sequenced textures

Alternatively, you can avoid most of the above by initially changing the file name of the first BMP in the sequence to have 11 extra characters. After the texture has been applied to the model, you can open the LWO file and delete the extra characters to make space for the " (sequence)" flag, without the file length being affected. Another option is to simply add " (sequence)" to the BMP file name before adding it to the model, then edit the LWO to move the placement of .bmp.

  • Example: rename the first file in the sequence abc from abc001.bmp to abc001 (sequence).bmp, then once the LWO file has been saved edit the texture's entry will now read abc001.bmp (sequence).

Be sure to rename the BMP file to remove " (sequence)" or any other extra characters before adding the files to the game.

Optional IMSQ fix

Optional: When saving a sequence using LightWave 5, the LWO file will contain an IMSQ block after the two null characters following the texture path. LEGO Rock Raiders does not require this section to display sequenced textures, but LightWave does. If you want to make your model fully compatible with LightWave, you can add this after each sequence entry; this will add an addition 12 bytes (0x1C) per entry to FORM, SURF, and TIMG. The values following IMSQ are:

  • 2 bytes: The length in bytes of the IMSQ entry. This seems to always be 00 06.
  • 2 bytes: Frame Offset. Default is 0
  • 2 bytes: Loop Sequence and Interlaced options. 00 00 for all disabled (default), 00 01 for Loop Sequence checked, 00 02 for Interlace checked, 00 03 for both.
  • 2 bytes: the Sequence Loop Length. Default is 30 (00 1E)

References

  1. 1.0 1.1 1.2 1.3 1.4 1.5 Sokol, Alan (December 20, 2017) [October 14, 2017]. "Animated Textures on Models". Rock Raiders United. Archived from the original on November 13, 2024.
  2. Scott, Dean A.; Vost, Ben (11 September 2024) [2002]. "LightWave History: All the versions of LightWave - so far". LightWave 3D. LightWave Digital. Archived from the original on 26 November 2024. Retrieved 30 November 2024.