Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Attach any two nodes together via mouse #2973

Open
CuriousMike56 opened this issue Nov 23, 2022 · 2 comments
Open

Attach any two nodes together via mouse #2973

CuriousMike56 opened this issue Nov 23, 2022 · 2 comments

Comments

@CuriousMike56
Copy link
Collaborator

This is a feature request I've been thinking about for a while (plus I'm sure it was requested at least once on the old forums), the ability to attach any two nodes together by selecting them with the mouse. Would give the player a lot more ways to interact with multiple actors. Also would allow you to attach anything that doesn't have ropables.
Here's how I'm thinking it could be implemented:

  • Hovering over a vehicle while holding ctrl or another key would show the nodes closest to the mouse
  • When selecting the first node, it'll be highlighted in a different color
  • Then you highlight the node you want to attach to, and click the middle mouse button to attach.

Could also further expand this by also being able to attach the two nodes using ties with a ImGui menu to adjust the strength.

@tritonas00
Copy link
Collaborator

This is a great idea

@ohlidalp
Copy link
Member

ohlidalp commented Nov 24, 2022

^I'm thrilled. I've had things like this on my mind for a long time. In fact things like this are the new gameplay mechanic I've been envisioning.

Presently you can't add extra nodes or beams to an actor on the go. The n/b buffers are exact fit. Previously there were pre-defined sizes (1000 nodes, 5000 beams IIRC) but I removed those. My idea is to create one dummy global actor with spare nodes/beams and take from there. It would be a little inefficient with regard to sleeping state, but whatever.

The node highlighting is easy to do, just look into my FlexbodyUI which already has code for calculating screen position of world elements and finding those closest to mouse.

I think it would be fantastic to implement this as script. The node highlighting and selection is already possible: we have DearIMGUI script bindings (#2840) and game.getScreenPosFromWorldPos() script func https://developer.rigsofrods.org/dc/d63/class_script2_game_1_1_game_script_class.html#ad626d3883bc042fa65726be158a5a48b (added recently). Applying forces to nodes or adding beams is not possible ATM but can be added as I described above. Note there's also game.getMousePositionOnTerrain() https://developer.rigsofrods.org/dc/d63/class_script2_game_1_1_game_script_class.html#ab4a9c422e3f25dd6f4e60925b6ec5405 that I coded for road-editing a while ago, may be useful for fixed nodes. It's also fitting that just a day ago I introduced the RefCountingObject framework in #2971, so you can use that PR as tutorial for adding new script objects.

BTW this is where our existing mouse/actor interaction code lives: https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gameplay/SceneMouse.h, https://github.com/RigsOfRods/rigs-of-rods/blob/master/source/main/gameplay/SceneMouse.cpp - it doesn't resolve mouse/node selection in screen space like I do, but directly in world space by creating virtual sphere around nodes and raycasting to find intersection. There's always more than one way to do things I guess.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants