Porting content - Stunt Rally tracks exporter

thomz92

New member
Joined
Sep 8, 2023
Messages
18
I'm new to the forums so I'm somewhat hesitant to ask this - not sure if its a no no.

If we get permission from the creator of "Stunt Rally" (open source racing game using ogre), would anyone be interested in porting tracks over to RoR? I'm not sure how difficult it would be, but I like a lot of the tracks in this game - they look great and have lots of interesting structures (0ad buildings, for example). I don't know much about modding, but since both games use ogre I wonder if it would be fairly easy for the modders on this forum.

If we combine Stunt Rally tracks with the physics/vehicles of RoR, that would seem like a huge win to me.
 
interesting topic, but I don't think it's feasible due to various rules

It looked to me like if you get the author's permission in writing, its fine


Stunt Rally is released under the GNU GPL 3.0. I'd be happy to try to get in contact with the author(s) if some modder on here is interested...

If ogre version is an issue, I think stunt rally 2.6 uses the same ogre version as the current RoR.
 
we need to evaluate all the parameters, the idea may be beautiful, but I don't think it's possible, the big ideas haven't yet been expressed, I don't believe they are in any interest
 
The GPL-3 license allows you to freely modify and distribute if you also release your version under GPL-3. Written permission would be preferred but not required in this case.
While both games share the same rendering engine (Ogre), the process of porting content between them isn't a simple copy and paste job. Stunt Rally's tracks are defined using XML: https://github.com/stuntrally/tracks/
Example file: https://github.com/stuntrally/tracks/blob/master/Aus3-Canyon/scene.xml
It appears the terrain ground textures are also defined through this file. In RoR, terrains use RGB images to define texture layers, which are then setup using an OTC file: https://docs.rigsofrods.org/terrain-creation/terrn2-subsystem/#ogre-terrain-page-config-page-x-xotc. Stunt Rally's heightmaps also are in "F32" format, so you'd have to find a way to convert them to PNG or RAW.

TL;DR: It's possible but quite complicated. It will require someone who's experienced with both games' file formats.
 
While both games share the same rendering engine (Ogre), the process of porting content between them isn't a simple copy and paste job.
I realized that after I made a half-hearted attempt to do it myself with one track :) I imagine that it would be a good deal easier than creating a terrain from scratch, though, wouldn't it? All the pre-made textures and .mesh objects and such. And, I think the XML file calls out the x,y,z positions of the objects, for example, and so once the scale of the terrain is all figured out, I would guess that would be copy/paste. As far as the heightmap format, maybe we could talk to the author on that.

TL;DR: It's possible but quite complicated. It will require someone who's experienced with both games' file formats.
Calling all experienced modders to a challenge! :)
 
- Well firstly, I confirm: no need to ask, our tracks are licensed GPLv3, just like our sources.
Meaning you can use them, as long as you release (any modifications) with the same license. And OFC credit SR original authors.

BTW License I'd say it'd be very good for RoR, to have some GPL tracks and CC resources, since there is almost nothing in FSF RoR version in Linux repos.
And that "get the author's permission" to do anything is seriously the worst IMHO. Is it needed to fix any map or truck in later RoR versions too?

- Secondly, it surely is complex to do. Like almost all is done different way in RoR vs SR, other syntax etc.
But I think I can try it someday. By that I mean probably adding some code (let's call it "SR to RoR export") for Stunt Rally Track Editor. To repeat less and get more tracks done later.

Now as for converting tracks from SR to RoR, here are key aspects:

- Terrain Heightmap
SR 2.x had old Ogre terrain, like in RoR and heightmap sizes: 513, 1025, 2049 etc - easier for RoR.
SR 3.x moved to OgreNext which has: 512, 1024, 2048 etc - easier for me, as I don't develop SR 2 now.
So probably easier from SR 2, but I can't build it anyway. I think from SR3 duplicating last row and column isn't that bad to get that +1.
Both SR have f32 format, this is just 32-bit float for height. I really prefer it so since start. No problems editing, no steps, etc.
So it's a matter of finding max and min value in all these floats and then converting to 16 bit raw integers (0..65535) with max-min scale I think.

- Terrain Blendmap
We generate it in SR from few parameters like each texture layer Height and Angle ranges, and Noise with few own parameters.
So needs to export it from SR editor and save image for RoR.

- Resources
SR has a different appoach and I surely recommend it. We have CC resources (nearly all of them are CC0, CC-BY or CC-BY-
SA), details in topic here. In SR common data, not with each map.
The way I see it RoR just packs each track's or vehicle's resources with it. Which would be wasteful if e.g. same textures or meshes are in few tracks. In SR this is a big deal. Our any track is about 1 to 13 MB. And there is about 1GB of resources total (textures, meshes etc), and about 0.5GB of tracks data.
- Xml
SR uses just 1 scene.xml for whole track's setup.

- Terrain Textures
SR3 has 151 (for 41 sceneries), almost all are CC0, most 1k, few 2k.
Some details here _terrain.txt
Surely there are now even 8k CC0 available on internet (example).

There is that (old) way of having RGB as diffuse and Alpha having specular or something, same with RGB normal and Alpha height or whatever. That was nuts for me and I wrote in SR 2.x code which just joins 2 jpg files on runtime to get that. So yeah all our textures are RGB and jpg (>90%) and are way easier to modify.
So ugh, another step here, new code would need to save from SR for RoR. Or can we just use RGB jpg in RoR, and skip Alpha?

- Horizons
This is new in SR3, extra 1 or 2 bigger terrain(s) for nice view. Can also drive on it in game.
Ogre 1.x terrain uses more batches and is not that optimal as in OgreNext where we can have few w/o even noticing.
So not for RoR. Also BTW SR has triplanar mapping for terrain.

- Meshes: vegetation, objects, buildings
Same as above, almost all are CC-BY etc licensed in SR data/ and available to use on any track. Need to credit authors, for most.
Vegetation is auto placed (similar parameters as for terrain). So SR export would need to write each one for RoR.
In SR 2.x .mesh files have versions around Ogre 1.4 so okay, but some are likely above 1.11 already.
In SR3 .mesh have "2.1 R2" version, for OgreNext, many of them now also have LODs.
We also have a big collection of cave, rock, tree meshes etc, details in data/rocks, trees2, etc.

- Roads
Well can't do much here. You seem to have a different own plugin/code for this. SR has my own code, hence it's so easy to do loops, jumps, pipes, half-pipes, on-pipes etc. It also has 4 LODs, to reduce triangle count further. Code is GPL OFC if you'd want to use it. But has less code for bridge types just 1 now, or borders.
But if roads won't have mesh then they should be at least painted on blendmap, so extra step from roadDensity map.

- Grass, road density.
SR 2 generates roadDensity it in editor and grass density in RTT.
Probably not important at all now. RTT could be saved as image for RoR.

- Surfaces
Another thing, that is completely different in SR and in RoR, other parameters etc. IDK probably not a big deal, but would have to create some surfaces in SR export for RoR for any map to work right.

- Fluids
SR has many possible box areas at any place. And we can drive inside water in SR.
I think RoR can have just 1 water and mud inside terrain.
We can skip this. Not a problem, SR3 is anyway best to enjoy SR tracks :)


TL;DR - terrain is doable, vegetation and meshes too. Best as extra code to export from SR 2.x Track Editor. Roads likely not.

Anyways please let me know if there is even interest in this. I could just get back to making new trees in SR3 and forget this soon.

Either way SR Track Editor is a pleasure to use (yeah I wrote it), as it is the only tool needed to make or edit SR tracks. Blender only to export meshes. I'm even a bit surprised no one hasn't yet used SR editor as an editor for their own GPL, 3D game. Anyway I need to remake all tutorial videos for it since the old ones feel ancient.
I think it still could be potentially better and faster than the more complex process of making RoR tracks using Blender. Well OFC unless you want to learn Blender, which is awesome.


Also anyone has any favorite tracks in SR which you'd like to drive in RoR?
We have SR Tracks browser.
It can also show difference between SR3 and SR2 as there were few improvements (like horizons).
The way I see it is that tracks without bridges (and pipes OFC) from SR would be best. So only with roads on terrain (gray on minimap). Nothing fancy and not small ones.

So: Dunes, Frenzy, Coast, Shore, Slippery, OSquare, Wet, Sunset, Hairpins, PersianCity, MiningCity, Taiga, Sandgrains
maybe also Vast, Cannon, Orange, MudBath, LavaPools, SandyCanyon, LakeCity

Yeah I went through all 228 SR tracks and I think that's probably mostly all above, that would be okay with terrain only and could race there.
More could be just with terrain only to drive, no road.
 
Last edited:
Hah. So I started, and I already have heightmap working and added blended 2nd layer from roadDensity.
This is in SR3 Track Editor now, as just pressing a key. Very early WIP.
Track is Dunes, IIRC is my 2nd track with road ever for SR.
 

Attachments

  • 10_23-59-37`.jpg
    10_23-59-37`.jpg
    224.5 KB · Views: 49
Hey what needs to be unique in all RoR tracks?
I've exported a few of them from SR3 and I see the same names in RoR and it loads same track.
So all these ?
- filename .terrn2
- GUID in .terrn2 file
- Name in .terrn2 file
or anything more?

OK nevermind.
All above and every file needs to have unique track name.
 
Last edited:
Hey what needs to be unique in all RoR tracks?
I've exported a few of them from SR3 and I see the same names in RoR and it loads same track.
So all these ?
- filename .terrn2
- GUID in .terrn2 file
- Name in .terrn2 file
or anything more?
Terrn2 filename should be enough, though it's best for every file to have unique names to prevent conflicts when switching to other maps in the same session.
Excited to to see this progress, SR3 maps look very good.
 
Okay.
Well I got a new tab in SR3 Track Editor for export, just for log info, RoR path and export button.
I need to do terrain blendmap layers next, since it's still just 1 texture and 2nd for road and it's ugly.
And I surely need to combine that diffuse + specular, can't just do RGB diffuse because specular then shines incredibly (broken) bright white.

But man, it's like nothing is the same. Maybe just that 1 is 1 meter, but everything else is different in SR vs RoR.
I'm just remembering all the things I modified to have custom, like my blendmap equations.

IDK is it so in RoR and old Ogre that if I have R,G,B,A blendmap and I want to have 3rd layer visible:
I need to have R,G,B,A = 1,1,1,0 ? Or simply R,G,B,A = 0,0,1,0? Latter I got in SR3.
Well either way some custom code could fix it. Like I had to flip X for road density.

Terrain starts at 0,0 on left top corner, heh in SR it's in middle.
IDK why but I have to set SR x,y,z into RoR as:
half - z, y + Ysize, x + half
where half is world terrain sizeXZ/2 and Ysize is terrain Y range.

IDK what's wrong with Y water level (WaterLine=), but I can't seem to set it to proper height.

Do objects have scale? I'd need x,y,z scale per object in .tobj. I see pos x,y,z and rot x,y,z (which IDK if I get right from quaternion) but no scale x,y,z. Is it possible to add?
Sometimes minimap doesn't render, is black with quite high terrains. I'm guessing camera height has to be rised or so.
Ah and I miss fog, height fog, and setting sun's ambient, diffuse, specular colors, we have various in SR tracks.

But yeah, it's really fun to drive RoR vehicles on SR3 tracks. On couple of tracks I drove with RoR vehicles w/o problems staying on road and even fast.
I did OFC consider few times already the other way (so RoR code in SR) but that'd be a gigantic nightmare to finish and I think even lacking some collisions. We got dynamic objects and basically all done with bullet.

Anyway, I can now export any track from SR and test in RoR, will have own name and creates all needed files.
Will continue OFC, it's quite WIP. Still lots to do.

Here are 20 screens:
 

Attachments

  • t2344`.jpg
    t2344`.jpg
    333.7 KB · Views: 33
  • t1709`.jpg
    t1709`.jpg
    301 KB · Views: 30
  • s2458`.jpg
    s2458`.jpg
    434.9 KB · Views: 27
  • j2479`.jpg
    j2479`.jpg
    189.2 KB · Views: 29
  • h2713`.jpg
    h2713`.jpg
    487.6 KB · Views: 27
  • g2624`.jpg
    g2624`.jpg
    225.8 KB · Views: 30
  • g1330`.jpg
    g1330`.jpg
    416.8 KB · Views: 27
  • f2171`.jpg
    f2171`.jpg
    428.4 KB · Views: 28
  • f1260`.jpg
    f1260`.jpg
    277.2 KB · Views: 26
  • a1827`.jpg
    a1827`.jpg
    269.9 KB · Views: 28
  • a1861`.jpg
    a1861`.jpg
    294.5 KB · Views: 26
  • c1701`.jpg
    c1701`.jpg
    380.8 KB · Views: 26
  • d1748`.jpg
    d1748`.jpg
    224.1 KB · Views: 28
  • d2030``.jpg
    d2030``.jpg
    240.7 KB · Views: 28
  • d2112`.jpg
    d2112`.jpg
    235.7 KB · Views: 28
  • t2558`.jpg
    t2558`.jpg
    256.2 KB · Views: 25
  • u2202`.jpg
    u2202`.jpg
    120.4 KB · Views: 25
  • u2313`.jpg
    u2313`.jpg
    242 KB · Views: 25
  • u2448`.jpg
    u2448`.jpg
    191.2 KB · Views: 25
  • w2083`.jpg
    w2083`.jpg
    393.6 KB · Views: 27
Last edited:
Cryham in person! You da bomb. Really excited to see you and this work. Love Stunt Rally as well - thanks for all the work you do! Me and my kids appreciate it :)
 
Last edited:
Also anyone has any favorite tracks in SR which you'd like to drive in RoR?
Yes!! If the roads don't translate yet, though, some of these won't be nearly as cool.

Top Twist, Mining City, Shore, Slope city, to name some of my current favs. I have yet to explore a lot of the others, though.
 
Great. Thanks. I'm glad you like what I do.
I will try with roads too later. Will see how it goes. Surey RoR has its own road generation, but if positions and rotations match maybe it won't be bad IDK yet. Definitely would be good to have some bridges on SR tracks in RoR, even to make them drivable around.
 
Right
Could you set the topic to e.g. "Porting content - Stunt Rally tracks exporter"? Since it's officialy working now.

I had some good progress.
Got blendmap somewhat working. Still rather buggy though. I get weird specular shines at places with some sun angles, and some stripes maybe wrong blendmap sizes IDK. And kind of looks good only at 6:30 or some time when road, grass and terrain match brightness.

Road is working surprisingly well. I usually can drive tracks with bridges around. Needs some testing.
Still I am only setting road points yaw angle and I see that roll changes.
It's probably like you wrote that yaw only works. Would be best if roll angle worked too in RoR roads..
So obviously bridge entries aren't perfect, they're only so in SR ;)

Got Caelum setup also auto written for some original colors.
But I've actually never seen fog in RoR yet. IDK why. I think I got cg-toolkit installed finally.

I also got some grass and mostly not on road.
Started with race script and checkpoints but ugh they're also skewed, bad yaw angle, even if it's same as for road.
How do I define size and of checkpoints? Is it just by bounding box from mesh?

Next are trees, rocks, objects, buildings etc. I think I'll have to use SR 2 meshes. Convert back to v1 from SR3 during export would be way slower.
 
Last edited:
And here are another 20 screens. Started with vegetation too.
 

Attachments

  • j0279`.jpg
    j0279`.jpg
    318.8 KB · Views: 25
  • j0323`.jpg
    j0323`.jpg
    409.4 KB · Views: 25
  • j0391`.jpg
    j0391`.jpg
    439.8 KB · Views: 22
  • j0502`.jpg
    j0502`.jpg
    427.3 KB · Views: 22
  • u1046`.jpg
    u1046`.jpg
    151.3 KB · Views: 27
  • v1066`.jpg
    v1066`.jpg
    219.9 KB · Views: 28
  • v1079`.jpg
    v1079`.jpg
    479.4 KB · Views: 26
  • v1082`.jpg
    v1082`.jpg
    396.2 KB · Views: 27
  • j0276`.jpg
    j0276`.jpg
    407.3 KB · Views: 26
  • j0253`.jpg
    j0253`.jpg
    311.7 KB · Views: 24
  • i0386`.jpg
    i0386`.jpg
    173.9 KB · Views: 22
  • a0169`.jpg
    a0169`.jpg
    348.9 KB · Views: 25
  • a0189`.jpg
    a0189`.jpg
    324.8 KB · Views: 23
  • b0980`.jpg
    b0980`.jpg
    238.2 KB · Views: 27
  • c0148`.jpg
    c0148`.jpg
    384.1 KB · Views: 27
  • f0212`.jpg
    f0212`.jpg
    225.4 KB · Views: 27
  • f0293`.jpg
    f0293`.jpg
    329.4 KB · Views: 23
  • g0220`.jpg
    g0220`.jpg
    435.1 KB · Views: 25
  • g0336`.jpg
    g0336`.jpg
    437.2 KB · Views: 25
  • w1114`.jpg
    w1114`.jpg
    351.1 KB · Views: 27
This is fantastic - I wondered if RoR could 'borrow' stuff from StuntRally at some point, but this unfolds so fast and so smoothly that I'm stunned. I really need to check forum more, kudos to @thomz92 for ringing me up. I'll try to help with what I know.

I completely agree that RoR lacks decent bundled terrain objects - we have a few (garage, marina, ferry slip, train depo) but no vegetation whatsoever and hardly any houses.

The terrain system is full of traps in regard to scaling/rotations/positioning. All our bundled meshes have wrong axes (Z=up) and code auto-compensates by rotating. Scaling in ODEF is also "Z-up" IIRC. OGRE was always "Y=up", so either the old devs failed to export meshes right or they were contrarian to the concept of Y being up. The rotation params of procedural roads are completely wacky, some axes seem to work in world space, some in local. I tried to figure how to do banked road at some point, but failed.

Regarding the checkpoints, yes they're rotated wrong, I ran into it while working on missions:https://github.com/RigsOfRods/rigs-of-rods/pull/3018, this is what I noted in the example mission def file:
Code:
; Generic checkpoints, processed depending on 'mission_type'
; Tip: use survey map to create AI waypoints + 'Export' button in Top menubar -> Vehicle AI panel.
;      Copy the exported waypoints from RoR.log and remove the JSON formatting.
; Advanced tip: use `road_editor.as` to generate AI waypoints from procedural roads, then follow above Tip.
begin_checkpoints

    ; This directive adds an extra rotation to all lines following it. Default value is no rotation (0, 0, 0).
    ; Syntax: 'add_rotation degreesX, degreesY, degreesZ'
    ; By convention, the checkpoint objects are defined sideways (facing X axis),
    ; but here we use rotations from the procedural roads which face Z axis.
    ; PORTING NOTE: The checkpoints in current map scripts don't need this, they're pre-rotated.
    set_extra_rotation 0, 90, 0
   
        531.462830, 0.300006, 486.630127, 0,    179.891647, 0
; ----- snip -----
end_checkpoints

Apparently I'm late to deliver all this info, sorry about that, let me know if there's something I can investigate.

For the roads and other things specific to SR, there's an option to bypass the 'terrn2' system altogether and set them up completely by our scripting. Or manipulate them in-game via script. We have this API:
Hopefully this is somewhat useful to you.
 
Last edited:
Okay thanks for info. I was wondering if developers are also on forum, or just busy IRL. I'd rather not use Discord.
Also just realised how many things are started on branches in PRs and not merged.

So I have many questions. Some I could find some way to check, but surely an answer would be faster.

Since there will be a lot of SR content, common on many SR tracks, I think the best way would be to produce SR data packs with terrain textures, rocks, trees, buildings, objects etc. This is also good (CC0, CC-BY or CC-BY-SA) data for RoR and any future tracks.
The other way is including all needed data with each track, but this makes tracks big, and data redundant.

I'm using some recent dev build, it has Ogre 1.11 mainly. The other is Ogre-14 branch I have built from sources which looks worse.
Does RTShaderSystem work in dev builds? What would be a .material example with diffuse and normal map using RTSS?

But is it possible now to have such packs?
E.g. I just packed 1 track terrain textures into terrain.zip, and I've put it in:
/home/ch/.rigsofrods/mods
/home/ch/_p/rigs-of-rods-dev2/content
/home/ch/_p/rigs-of-rods-dev2/resources
or all files in:
/home/ch/.rigsofrods/mods/terrain/
And I always see black terrain. Am I missing something? Seems only way working is having textures inside track dir.

Few questions for blendmap, just to confirm, I think all are yes:
1. How many terrain layers is max? Is 5 still okay?
2. Is R,G,B and A channel supported in blendmap.png?
3. Are different sizes okay? E.g. road blendmap 1024 and terrain blendmap 512?

Wow I think I found out why I get this weird white specular spots on terrain. This was quite annoying.
Was once is gone when I changed time, but after a few seconds appears back.

I tried both 0 or 1 in .otc for these
SpecularMappingEnabled=1
LightmapEnabled=1
and still same. Seems these don't work.

I fixed it by having 0 for Alpha in diffuse+specular, so basically no specular at all. Only this gives me normal looking terrain now.

For me it'd be best if I could just use jpg files for terrain textures (so only RGB, not RGBA so diffuse, no specular, normal, no height).

Plus jpg are way smaller. Seriously, all SR terrain textures converted to png are 727 MB! and in jpg 213 MB. If I had to put them with every track (not all as a pack) that's even worse (adds like 30 MB to even a small track).
If this is not only for me so, then it's a bug, and so there's even no reason for png or dds terrain textures.
Could be something with my setup, after all I don't see shadows, I have no fog or rain. And I think I got CG toolkit installed. Anyways I'm on Debian 12 with GL and AMD GPU.

Here is a screen from SR track editor, on new tab after track export to RoR. I think this is already good but could still change.
 

Attachments

  • 17_03-01-39`.jpg
    17_03-01-39`.jpg
    222 KB · Views: 21
  • 17_03-32-53`.jpg
    17_03-32-53`.jpg
    319.8 KB · Views: 20
Last edited:
Back
Top