Jump to content

Tutorial: Working with start- and power-up positions


RobExplorien
 Share

Recommended Posts

Understanding the .SPB (startposition) and .PWB (power-up position) files in the LEGO.JAM

 

This is my first attempt into creating a tutorial for LEGO Racers.  The tutorial is more like an explanation of the files, and serves to help you on your modding with these files. I already know that many on this forum know how to work with the .SPB and .PWB files, but to those few who just started modding and run into some issues, here it is anyway. I am not going to explain how to extract the LEGO.JAM or how to open the **B-files, that is explained on other topics. However, I can give you a link to the >JAM-extractor and the >Binaryfile-editor. Ofcourse, position-editing has become much easier with grappigegovert's >In-game coördinate viewer, but really understanding what you change will be told here. Remember, before modding, make a back-up of the original LEGO.JAM.

 

When having the JAM-file extracted, you'll end up with a map containing the subfolders: GAMEDATA and MENUDATA. What you want is the former. Opening GAMEDATA will show a list of more folders. Any of the RACEC*R* folders will have an .SPB and .PWB file, as well as the folder TEST. These folders contain all sorts of data about each track in the game. For example; RACEC0R0 = Royal Knights Raceway, RACEC0R1 = Imperial Grand Prix, TEST = Test Track. Navigate through the folder until you bump into either one of the binaryfiles.

 

 

 

.SPB file

 

Opening an .SPB file with the binaryfile-editor will give you code lines like these:

k_27
[6]
{
 k_27
 2
 {
  k_28
  (float)379.492
  (float)210.5133
  (float)0.065082
  k_29
  (float)0.008727
  (float)0.999962
  (float)0
  (float)0
  (float)0
  (float)1
 }
The [6] at the top means that there will be 6 entries below, one for each racer. In this case, the number under k_27 is 2. The code lines below 2 are meant for an AI's position, not something you can mess with, as the startpositions for AI's cannot be changed directly via the .SPB file (for that, you'll have to seek for the >.RRB files). You need to seek for number 0, the number for the player's car. The floats under 0 apply to your car. In the code lines below, you see a brief explanation of the most notable floats.

 k_27
 0
 {
  k_28
  (float)368.3372          //x-position
  (float)193.9604          //y-position
  (float)0.065082          //z-position
  k_29
  (float)0.008727          //x-position rotation
  (float)0.999962          //y-position rotation
  (float)0                 //z-position rotation
  (float)0
  (float)0
  (float)1                 //flip vehicle
 }
How do you work with these values? I've made some simple images to show you what happens when you change a certain value (concerning the first three floats). Changing the x-position to a higher value will result into placing you more to the right of the map, lowering the x-position value will result into placing you more to the left of the map. I guess you can figure out how this will work for y-positioning too. This works for all tracks; take the map like this, and draw imaginary lines over it like seen in the image. Note that the values in code lines do not apply to these maps.

gallery_6631_326_107389.pnggallery_6631_326_235870.png

 

 

I did not forget about the z-position, but it would be hard to show it to you in the same image. Now with a different perspective, see the image below. Changing the z-position to a higher value will place your vehicle higher (but you will fall back down to track level, or remain stuck in the air (if value is too big)), lowering the z-position value will place your vehicle lower (resulting into getting stuck if value is too low).

gallery_6631_326_242881.png

 

gallery_6631_326_135881.png

 

Now we've had the positions, now for the rotation. The rotation is a little more difficult, but not hard to understand either (at least, I hope). With the coördinate viewer I was able to understand it more, although I was very close. Rotation is based on radians in LEGO Racers. I've heard of quaternions being used for rotation, but radians work as well. Just showing you the code lines for rotation again:

 k_27
 0
 {
  k_28
  (float)368.3372
  (float)193.9604
  (float)0.065082
  k_29
  (float)0.008727          //x-position rotation
  (float)0.999962          //y-position rotation
  (float)0                 //z-position rotation
  (float)0
  (float)0
  (float)1                 //flip car
 }
The x-position and y-position for rotation will rotate your vehicle horizontally. As far as I know, rotation values are numbers that range from -1 to 1 (or in mathematical terms, [-1;1]). If you have no experience with radian values, I'll give you some basic values for  the rotationfloats. The image below will be an example.

gallery_6631_326_126318.png

See the green rectangle as your vehicle. This image will work with all track maps in the game (if you take the map as shown in the example). To make the vehicle face any of the arrows (twist them 180 degrees, 90 degrees or 45 degrees), change the rotationvalues to the following:

(Note: Calculate the 'square root-values' in decimals to use them as floats. I used square roots to give you an understanding of the values.)

  • Green arrow: x=0   y=1
  • Purple arrow: x=-0.5√2   y=0.5√2
  • Red arrow: x=-1   y=0
  • Lightgreen arrow: x=-0.5√2   y=-0.5√2
  • Blue arrow: x=0   y=-1
  • Lightblue arrow: x=0.5√2   y=-0.5√2
  • Yellow arrow: x=1   y=0
  • Gray arrow: x=0.5√2   y=0.5√2
Ofcourse you might want to use other angles as well. To give you an example of 30 degree and 60 degree values:

gallery_6631_326_122654.png

I cut the former image to the upperleft 90 degrees of the circle. If you'd like to create these angles (i.e. have your car face these angles), do:
  • Red angle: x=-0.5√3   y=0.5
  • Green angle: x=-0.5√2   y=0.5√2
  • Blue angle: x=-0.5   y=0.5√3
This is basically the principle of radians. I think you can figure out how this would work for the other circle parts as well.

 

The z-position for rotation will change the angle of your vehicle with the surface. To give you an image of what I'm talking about:

gallery_6631_326_8778.png

 

On a flat surface (no gradient), changing these z-position values (for rotation) won't do much, as your vehicle will align with the surface instantly.

The sixth float (//flip vehicle) can make your car turn upside down, when the value of this float is changed to 0.

 

After changing values in this .SPB file, save the file (opt for overwrite) in the correct track folder and you can start recompiling the .JAM.

I hope I explained you well how to modify and understand startpositions.

 

 

 

.PWB file

 

The .PWB files apply to the position and colour (thus effect) of the power-up for a track. You can find them in any RACEC*R* folder. You will find two files with this extension, POWERUP.PWB and POWERUP2.PWB. The former applies to tracks in single, multiplayer or circuit races, the latter applies to tracks in time trials. This division is made because time trial tracks share different power-up layouts than the others. Anyway, when opening a .PWB file with the Binaryfile-editor, you will see code lines like these:

k_27    // Colored Bricks
[27]
{
 k_27    // Colored Brick
 {
  k_28    // Position
  (float)340.7048
  (float)-425.0762
  (float)19.03339
  k_2D    // Green
 }
k_2F    // White Bricks
[12]
{
 k_2F    // White Brick
 {
  k_28    // Position
  (float)-196.6214
  (float)-288.5213
  (float)11.53108
 }
The [27] under '//colored bricks' means that there are 27 coloured power-up bricks on this track, each given a position and colour. The [12] under '//white brick' means that there are 12 white power-up bricks on the same track, each given a position. You know how to modify xyz-positions (of the power-ups), the three floats under k_28 are the xyz-positions for each brick. The k_2* code line under '//colored bricks' defines the colour of the brick (therefore the effect as well). If you'd like to change the colour of a brick, change the * in any of the following letters:
  • k_2A          //Red Brick
  • k_2B          //Yellow Brick
  • k_2C          //Blue Brick
  • k_2D          //Green Brick
Want to add more power-ups to a track (or decrease the amount of power-ups), always make sure that the number of entries below 'k_27   //Colored Bricks' or 'k_2F   //White Brick' is equal to the amount of entries specified inbetween the parenthesis,
  • . To add more power-ups, simply copy a section for one power-up and modify the values.
  • (The in-game coördinate viewer provides you easy positioning of power-ups. Place your vehicle on the position where you'd like to place a power-up, write the coördinates of that position down and change the values in the .PWB file with those coördinates. Then add 5.0 to the z-position float to make the power-up brick align 'perfectly' with the surface. For removal of certain power-ups, use the viewer as well. Place your vehicle on an existing power-up position, write down the coördinates and then look for (almost) identical coördinates of a brick in the .PWB file. Then delete this (identical coördinate) section for the power-up brick. Again, don't forget to change the entry-value inbetween parenthesis when deleting or adding power-ups.)

    Coördinate viewer in action! (try to guess the LEGO set in the background :P):

    gallery_6631_326_223496.png

     

    After modifying, save the .PWB file in the correct track folder (opt for overwrite) and recompile the .JAM.

    I hope I explained you well how to modify and understand the .PWB file. Feel free to correct me if I made mistakes.

Link to comment
Share on other sites

An awesome tutorial! I guessed that the coordinates would work like this but the rotations were a problem to me! Thank you! This will definitely help to edit the tracks.

I only got some things you could add to the tutorial:

 

.spb

After this:

The [6] at the top means that there will be 6 entries below, one for each racer. In this case, the number under k_27 is 2. The code lines below 2 are meant for an AI's position, not something you can mess with, as the startpositions for AI's cannot be changed directly via the .SPB file (correct me if I'm wrong). You need to seek for number 0, the number for the player's car. The floats under 0 apply to your car. In the code lines below, you see a brief explanation of the most notable floats.

Write (kind of) this:

 The other 5 positions are only needed when the player doesn't start at the last (6th) position as in versus mode or against Veronica Volt. So these values only change the player's start positions (even if you never start on position 3,4 or 5).

 

Also, you should add to the z-rotation picture where the front of the car is (I guess it's the right side?).

 

 

.pwb

Add this:

Tip: Here you can use the coordinate viewer to figure out a good position for a new power up ingame because you directly see where it has to go. Then simply copy or remember these coordinates and use them for the new power up.

 

 

You don't have to add these things, but I guess they would help a bit :)

Link to comment
Share on other sites

Also, you should add to the z-rotation picture where the front of the car is (I guess it's the right side?).

 

 

.pwb

Add this:

Tip: Here you can use the coordinate viewer to figure out a good position for a new power up ingame because you directly see where it has to go. Then simply copy or remember these coordinates and use them for the new power up.

 

 

You don't have to add these things, but I guess they would help a bit :)

 

EDIT: Edited the tutorial a bit, with new (better) images and rotation information and extra .PWB modding explanation (with coördinate viewer).

Link to comment
Share on other sites

  • 2 weeks later...
grappigegovert

Great tutorial! It's really clear.


How I interpreted the rotation:
The first three floats are an XYZ vector for where the front of the car is pointing to,
and the last three floats are an XYZ vector for where the top of the car is pointing to.

(inside a sphere like this:)

43d16eG.png

 


Also, thanks for including my coordinate viewer.

Link to comment
Share on other sites

How I interpreted the rotation:

The first three floats are an XYZ vector for where the front of the car is pointing to,

and the last three floats are an XYZ vector for where the top of the car is pointing to.

I explained it like this in another thread but everyone ignored me. This is the correct explanation.
Link to comment
Share on other sites

Fluffy Cupcake

How I interpreted the rotation:

The first three floats are an XYZ vector for where the front of the car is pointing to,

and the last three floats are an XYZ vector for where the top of the car is pointing to.

I explained it like this in another thread but everyone ignored me. This is the correct explanation.

Which would be right here. ;)

Link to comment
Share on other sites

grappigegovert

Yup, it's indeed what origamiguy said.

But I first didn't quite understand what you were saying, until I found it out myself. (English is'nt my native language so I don't understand everything.)

So I thought i'd explain it differently.

 

And, about it being in a sphere, in-game it's stored like that, but in the SPB and PWB files it can be outside that sphere as the game will automatically convert it.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.