RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
995 stars 175 forks source link

Procedural road editing using AngelScript #2976

Closed ohlidalp closed 1 year ago

ohlidalp commented 1 year ago

This introduces scripting API for full procedural road management and also bundled script "road_editor.as" which allows interactive road editing!

screenshot_2022-11-28_12-26-39_1

To start the editor script, open console and say "loadscript road_editor.as".

Features:

You can also script custom meshes using addQuad() and addCollisionQuad(). AngelScript API documentation will be available at https://developer.rigsofrods.org/d4/d07/group___script2_game.html once this PR is merged.

CuriousMike56 commented 1 year ago

Very nice! Hopefully later on it'll be possible move road points the same way as other objects, (Character freezes in place, use arrow keys to adjust position + press R to switch rotation axis)

ohlidalp commented 1 year ago

@tritonas00 requested an option to export road points as AI waypoints. I added 2 sliders to specify a range, and an export button: screenshot_2022-11-29_01-07-15_1 While at it, I also implemented an import of AI waypoints as procedural road points, with the same controls: screenshot_2022-11-29_00-59-10_1

ohlidalp commented 1 year ago

@CuriousMike56 Hopefully later on it'll be possible move road points the same way as other objects

Eventually yes, but not in this PR. That logic is hardcoded and somewhat dirty (reuses existing hotkeys), I don't want to extend it any further.

ohlidalp commented 1 year ago

Road smoothing is real! smoothing! UPDATE: now supported by the TOBJ file format! I actually developed this a year ago and it's been collecting dust in my git fork, I'm happy I finally integrated it.

ohlidalp commented 1 year ago

It's complete. Not perfect but helpful. Hotkeys:

    // Road editing
    {"ROAD_EDITOR_POINT_INSERT",        "Keyboard EXPL+INSERT",         _LC("InputEvent", "insert road point") },
    {"ROAD_EDITOR_POINT_GOTO",            "Keyboard EXPL+G",              _LC("InputEvent", "go to road point") },
    {"ROAD_EDITOR_POINT_SET_POS",      "Keyboard EXPL+M",              _LC("InputEvent", "set road point position") },
    {"ROAD_EDITOR_POINT_DELETE",        "Keyboard EXPL+DELETE",         _LC("InputEvent", "delete road point") },
    {"ROAD_EDITOR_REBUILD_MESH",        "Keyboard EXPL+B",              _LC("InputEvent", "regenerate road mesh") },
finished