zeffii / TubeTool

generate tubing between two selected polygons (now supports 2 objects simultaneously in edit mode) b2.8+
GNU General Public License v2.0
292 stars 28 forks source link

Awesome Concepts for a truly L33T TubeTool addon #24

Open toomanydemons opened 5 years ago

toomanydemons commented 5 years ago

This is where I will submit ideas for TubeTool based on what I believe 'might' be possible programmatically (though maybe not actually feasible). These ideas are based on my experience as a level designer and hardcore modeler (someone who does a lot less coding and a lot more vertex pushing).

This is a lot of what I do: https://gyazo.com/c9ce1896f7489bc913f11a7154fe625c

After playing with Tube Tool extensively since its first release, one thing I like to do is create complicated patterns of wiring and tubes of varying thickness between two or more locations. Usually I will generate multiple curves manually, and then go back and adjust the curves by their handles.

I imagined it would be incredible to generate multiple pipes/wires between two whole areas. It would be unfathomably awesome. Here is an example of how I would imagine it to work:

With TubeTool, imagine being able to select two groups of faces (such as Group A with 7 selected (adjacent) faces and Group B with 6 selected (adjacent) faces, and generating connections between all of the faces randomly, from one group to the other (rounding to the nearest even number; in the above case, 6 curves would be generated and the seventh face in Group A would be ignored). Group A connects all its faces to Group B with curves. Each one would wind its own way to a random face in the opposite group.

In theory this seems like this would lead to a lot of intersecting pipe paths. Sometimes this does happen, but in practice, doing the above example manually, very little (or no) cleanup is actually required in a lot of instances. Also it may be a small matter to subdivide all created curves and push the center division point away from all other points by a set margin, so that intersections are even less frequent.

On the same note--As a power trip for the programmer who is insane--you could set the number of subdivisions in the curves by an input number. The distance each point is pushed away from the collective center at each division could also be variable. I believe this sort of functionality would all but erase most intersections.

The result of this kind of functionality would be the (very) rapid creation of crazy wire patterns that would naturally weave around each other between two locations. This would be ideal for quickly illustrating jumbles of wires in industrial & scifi backdrops, tangled rope & rigging, or even good-looking vine/root patterns for more natural settings.

Possible additions would be the ability to scroll a random seed for thickness among the various curves or a random seed for face connections among the two groups (though that last one may cause some lag issues... )

I believe this sort of functionality would be extremely useful and very functional. You would have yourself a bad ass Tube Tool that will go down in the history books.

toomanydemons commented 5 years ago

Pardon all the edits... I'm always in a hurry and never happy with presentation : P

toomanydemons commented 5 years ago

Another beautiful idea I've thought about a few times: connecting two points with a curve that only bends at right-angles (or also 45 degree angles), such as the ones generated by the Pipe Nightmare addon. Except between two faces.

As you can see, most of my ideas are for hard surface application... guilty as charged ^_^

zeffii commented 5 years ago

there's several approaches to multiple sets of faces (start, end)

start, end

let's use some ascii

# 1.  a single pass (start, end)
A-----B  
# 2.  or (all faces are matched)
A1-----B1
A2-----B2
A3-----B3
A4-----B4
# 3.  or/and (picking one start face, and multiple end faces) (with ability to flip direction)
A-----B1
A-----B2
A-----B3
A-----B4

bevel shape

the kind of geometry used for the extrusion

taper shape

ability to pick a shape curve from the scene (or library) that can be used to set the bevel width / curve thickness from start, end

it is scriptable already

the whole reason this addon, and all my other add-ons exist is because i wanted to solve my own problems when they became too "niche" or difficult to explain. so i learned to script/code.

toomanydemons commented 5 years ago

All of those are great ideas.

Considering that my artist brain runs the show, I would know far less about the intricacies of making half the functions I dream up. I'm absolutely positive that my rudimentary assessment of the logic required to make this stuff happen would cause you to smirk at best and roll your eyes at worst :D

The most I can do is throw ideas out there !

zeffii commented 5 years ago

there are two stages to being an artist.

  1. use tools provided by others
  2. make your own tools when others don't see the brilliance of your ideas.

when i have time, i'll show you how you might script the automated tubing of many many faces with different settings.

toomanydemons commented 5 years ago

I would love to see that first-hand. I know the basics of python and I've coded my own tools before, though nothing too advanced. Usually my addons are just for running commands on multiple objects (such as clearing custom normal data on a hundred cubes). The most advanced addon I ever made was one that cut out all penetrating geometry from a watertight object. A perfect clean cut. It was helpful to prevent texture overdraw for game engines. That said, my chief love is making models. All the way back to when I was a kid, putting them together with plastic and glue with my Dad. For a multi-face tool like the one I propose, I've run into countless instances where I wished I had such a tool. If you could help me make it work, I'd gladly take the lesson to heart, and be grateful for it. Thanks!

zeffii commented 5 years ago

most of this stuff is about persistence, not intellect :) no ETA, i'm not in my dev environment.

zeffii commented 5 years ago

i've seen that 2.8 now has a new thing called "face_maps", which i think is supposed to be similar to vertex_groups, but based on faces. ( in my eyes ideal for what we want here.. ) .

The API seems incomplete at present, but eventually it would allow you to have what i'd like to call "named faces" ( so A1, A2...An -> B1, B2...Bn as above )

then, rather than iterating the following code 6 times, and picking 2 faces at random in each. you would just pass the two face_maps or whatever.

The following code would run on a subdivided Cube, and generate 6 tubes.

import bpy
import random

def deselect_faces(obj):
    for f in obj.data.polygons:
        f.select = False

def select_random_faces(obj):
    indices = random.sample(set(range(len(obj.data.polygons))), 2)
    for idx in indices:
        obj.data.polygons[idx].select = True

# active obj deselect all
obj = bpy.context.active_object
bpy.ops.object.mode_set(mode='OBJECT')

# pick 6 pairs of faces to apply tube to
for i in range(6):
    bpy.ops.object.mode_set(mode='OBJECT')
    deselect_faces(obj)
    select_random_faces(obj)
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.add_curvebased_tube()
zeffii commented 5 years ago

and the operator takes a literal fuck-tonne of arguments

of which these are useful to the scripter

>>> bpy.ops.mesh.add_curvebased_tube()
base_name="TT_tube", 
subdiv=4, 
tube_resolution_u=12,
handle_ext_1=2, 
handle_ext_2=2, 
show_smooth=False, 
show_wire=False, 
main_scale=1, 
point1_scale=1,
point2_scale=1, 
flip_v=False, 
flip_u=False, 
equal_radii=False, 
toomanydemons commented 5 years ago

holy cow, I need to get into coding in 2.8 I suppose. Maybe some of the tools I imagine could actually be done using this system.

One thing I tried working on awhile back was a pipe tool that consisted of a 1-click solution for changing an edge into a pipe with an adjustable bevel for turn-angles in the edge. As I recall, there was just no way to make a live bevel option for a curve and so I abandoned the project.

One thing I do a whole lot of is scifi stuff. It seems like every other team of indie artists is working on a scifi project. Essentially what it boils own to is "Pipe Porn". In the future, all the pipes and wires go on the outside of the walls...

Creating intricate, complex pipe & wire patterns is one of the more time-consuming and difficult aspects of environment art. Walking around in DOOM and Wolfenstein, I can't imagine the hundreds of hours that went into the walls.

Since it's a key feature of quite a few environments, especially industrial settings, it has been my mission to acquire every pipe/wire-oriented tool I can find and am always keeping my eye out for more.

So as I said, I'm pretty sure you could make some decent cash creating a good and detailed addon to handle this aspect of the modelling chore.

toomanydemons commented 5 years ago

Hmm I don't see an option in the operators for beveling the points of a curve. So I suspect the only way to pull off a 90-degree stair-step connection tool that has beveled corners would be to start with an edge, bevel the verts and then convert it to a curve.

toomanydemons commented 5 years ago

I've taken the time to better illustrate my concept for this addon, which I believe would make it an ultimate tool for environment work (even though it's already pretty great !)

I've illustrated it with screenshots here to avoid mis-explaining my dream concept. Take the time to look at them and please tell me if you think it's even possible ! Even if it were $100 I would immediately pay for an addon that could do this:

1: Connection by right-angles. I believe this would best be done by coding a grid-system that makes the curve follow the nearest path to the destination square:

https://gyazo.com/c1f21477bcd252bd3ce03e974663f779 https://gyazo.com/628bd5ae64adaf9ebb6a79168f482949

2. Beveling the hard angles of the connected path:

https://gyazo.com/e90c2e13e43500304968911bf85a1916

3. Support of multiple curves:

https://gyazo.com/50b31f2515f7aba7c3ed2f2f3464eb23 https://gyazo.com/cb5e41fd51c1ff905d04744fc0aaa7c8

4. Random width applied to each curve. As you can see from the screenshot here, intersections don't harm the overall effect, though a grid-system may allow for coding a clean path for each curve:

https://gyazo.com/0282f2d62d43c14a6c0955f5cd289a3a

This final screenshot is the ultimate goal. It's also what I believe the Pipe Nightmare addon should've been. This is my dream tool and what I believe would be a very powerful hard surface weapon. In fact I believe it would become one of the most-used addons by hard surface artists in Blender. I don't think there's anything like it out there currently, for any software.

toomanydemons commented 5 years ago

I believe a specialist is required to construct a tool like this one. I am more an artist and less a coder. Even with my deeper knowledge of vector space, it would take a long and in-depth research of Python, Blender's API, and coding in general by me to reach this result in a custom tool, and I'm usually working on something for someone all the time (even now) as a supplementary income.

That said, I would gladly pay for (and worship) a tool like this one. With 2.8 out, and tools like this one, right up there with DecalMachine and Hard Ops, then figuratively speaking: Maya, Modo and Max can all breathe Blender's exhaust fumes.

zeffii commented 5 years ago

i'll study those images/descriptions in the next couple of days.

I will show you an example of how you might use Sverchok for this (it has many Curve features), but i'm still porting it to 2.8. Also it's easier to show images like you have, thanks for those.