Jump to content
The Dark Mod Forums

Allow placing entities from the 3D viewport, with automatic alignment to surfaces based on view projection


Recommended Posts

DarkRadiant already offers a lot of features to make things easier for mappers by simplifying and automating certain tasks. Even so creating a map takes a huge amount of time due to how much there is to do overall. When mapping I noticed a huge amount of time is spent on positioning stuff: You right-click in a 2D viewport, go in a menu to spawn your entity, then need to find it and drag it around from at least two different views to place it where it needs to be in all three dimensions... often having to search in a mess of overlapping lines to even find the selection you're working with. Some shortcuts like "floor selection" offer limited help afterward, but even then you usually need to select the wall so you can see the red outline and be sure on how much you need to move that item so it correctly rests against the surface.

I was thinking of a method that could make this a lot easier: Allow placing entities from the 3D viewport as well, based on the distance and direction projected from the view to the spot where you clicked. So let's say you're looking at a brush wall: You click on its surface and get the same menu as in the 2D viewport (eg: Create entity). Once you insert that item, it's automatically positioned so its back rests against that wall (total bounding box), the item also rotated to face toward the camera (in 90 or 45 degree increments). Every wall will need to be accounted for if you're placing your item over an edge or in a corner, ensuring the object fits neatly against all brushes its model's box intersects.

This could help a lot by not making the mapper need to move and rotate everything manually except for small adjustments. In the 2D viewport it's difficult to guess where an item will appear since you don't know its size, plus you still need to go in another 2D viewport to position it in the 3rd dimension not covered by the viewport you spawned it from. This will require math to do line tracing as well as calculating surface / box intersections, but I'm hoping it's doable and some of the code may already exist.

One obvious thing worth pointing out: A normal right-click in the 3D view is used to grab the camera and go into mouselook which we wouldn't want to change. This would need to be implemented as a combination, prolly either control + right-click or shift + right-click. What do you think about this idea?

Edited by MirceaKitsune
Link to comment
Share on other sites

1 hour ago, MirceaKitsune said:

Once you insert that item, it's automatically positioned so its back rests against that wall (total bounding box), the item also rotated to face toward the camera (in 90 or 45 degree increments).

This sounds quite prone to error, considering that you can't really expect a program to figure out which way is forward on a model. Also, a lot of the time you'd want to snap something to something more complex than a wall, i.e. filling up a shelf. I think such tasks will work better if they're supported, but not automated by DR, since programming an automated system that covers the majority of situations sounds like a nightmare.

What could be nice is having a horizontal version of the "Floor selection" button. Since there are 4 possible options (X+, X-, Y+ and Y+) it could help if it were a single button that took the current view direction of the camera (N-S-W-E) into account. A possible downside is that it can be a pain if the mapper constantly has to turn the camera (and reposition it if he still wants to see what he's working on) in order to get things to move into the right direction.

1 hour ago, MirceaKitsune said:

Some shortcuts like "floor selection" offer limited help afterward, but even then you usually need to select the wall so you can see the red outline and be sure on how much you need to move that item so it correctly rests against the surface.

By the way, it gets much easier to align 2 things if you hide the entire rest of the map, i.e. by selecting what you want to work with and then pressing I (invert selection) then H (hide selection). Alternatively, Ctrl + Shift + H.

  • Like 1
Link to comment
Share on other sites

Oh that's correct actually, meshes have varying rotations. For most the front appears to be +Y but some may point toward -Y / +X / -X since there was never a common standard for this, it would be an unpredictable mess then. And we'd want this to work for prefabs too, orientation differs even more there.

Something else we could do then is implement only projection for the active selection? This would still offer the most handy part of the automation: With an entity or a group selected you'd [modifier] + [click] on a surface in the 3D viewport to move it to the grid unit closest to that spot. We can allow the surface detection for models other than just brushes... the algorithm would have to deal with more complex geometry, but it would then cover actions like positioning items in shelves.

Speaking of flooring I just realized: The "floor selection" feature is already doing half of what I'm suggesting here, its code may be possible to reuse! In the -Z axis currently but same concept: It brings the selection to the nearest surface in a given direction. With what I'm thinking the code would only do two additional things: Teleport the active selection to the origin of the camera first, then use the same call but in the camera-to-pointer (where you clicked) direction instead of one axis.

Edited by MirceaKitsune
Link to comment
Share on other sites

Yeah, a kind of "point-and-click" align feature via the Camera sounds quite useful. Maybe there could be a new button next to "Floor selection" that, once clicked, does the alignment as soon as you click somewhere in the Camera. Though that could get screwed up if you click somewhere else. Alternatives like a left-click menu or a hotkey wouldn't be discoverable enough.

That said, I'd already be well served just by a simple horizontal alignment button that asks me whether I want to align my selection north/west/south/east. It also seems much simpler to implement.

  • Like 2
Link to comment
Share on other sites

Fun fact, yesterday I watched the Dark Radiant Tutorial Part 4 from @Springheel
When he was trying to snap a gas light to the wall correctly, he also asked if anyone knew if there's a "floor" feature, but for walls. :D I found this quite amusing since the tutorial series is like 4 years old but it seems like anyone never noticed the usefulness of such a neat feature in that time. :)

"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

Link to comment
Share on other sites

1 hour ago, SeriousToni said:

Fun fact, yesterday I watched the Dark Radiant Tutorial Part 4 from @Springheel
When he was trying to snap a gas light to the wall correctly, he also asked if anyone knew if there's a "floor" feature, but for walls. :D I found this quite amusing since the tutorial series is like 4 years old but it seems like anyone never noticed the usefulness of such a neat feature in that time. :)

I definitely support a "floor selection" version for walls: That feature should at least be turned into a 6 button set for all axes (+ / - for X / Y / Z). I just opened a bug tracker entry for that, combined it with my laser-pointer projection idea since at the end of the day it's kind of the same improvement in different forms.

https://bugs.thedarkmod.com/view.php?id=5714

Link to comment
Share on other sites

3 hours ago, SeriousToni said:

Fun fact, yesterday I watched the Dark Radiant Tutorial Part 4 from @Springheel
When he was trying to snap a gas light to the wall correctly, he also asked if anyone knew if there's a "floor" feature, but for walls. :D I found this quite amusing since the tutorial series is like 4 years old but it seems like anyone never noticed the usefulness of such a neat feature in that time. :)

This is something I suggested a while back, here.

Basically it would work like the floor feature does now, except in all six directions. Let's say you want to align a painting to the north wall of a room. You'd go to your top down window, put the cursor north of the painting, and hit Ctrl-Alt-F or whatever the hotkey combination would be. This seems like a super useful way of aligning objects to walls, lights to ceilings, and such.

My missions:           Stand-alone                                                      Duncan Lynch series                              

                                      Down and Out on Newford Road              the Factory Heist

                                                                                                  A House Call

                                                                                                  The House of deLisle                                                                                                  

                              

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 1 reply
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...