Search Unity

Ribbon tool (water/roads/etc.) [WIP]

Discussion in 'Made With Unity' started by sagron6015, Aug 20, 2010.

  1. sagron6015

    sagron6015

    Joined:
    Apr 19, 2010
    Posts:
    32
    Here's my first attempt at a decent water tool - with editor gizmos and all :). Should work with w/e you feel like making it (roads, etc.). Not sure if I did things the best way or not - but feel free to offer criticism and (better!) suggestions.

    Only thing you edit in the editor right now after adding the component is the nodes along the blue spline in the middle. (Move/Rotate or Scale to affect width and depth)

    First screenie is the designed river. Second and third include the generated mesh (during play in editor and game views) with a basic water material and script applied (I could have done pro but figure basic is what most ppl will use)

    Basic Tutorial:
    http://www.screentoaster.com/watch/stUE9UQEdARFtXRlpeUlJbXlFX

    NEW
    *Added ability to use a texture on a node which overrides the non-local texture.
    *Meshes are now an easy way of selecting nodes (when in scene mode).
    *Now mesh is only updated when gizmos are drawn OR updateMesh is called (if you want to kick off a custom update).
    *A prefab is used for instantiation of nodes (RibbonTool prefab is used if none is dragged into the prefab spot in the script).
    *Mesh detail controls how many triangle strips are in between each node, default is 1 - set at 5-10 to get smooth curves.

    Licensing:
    Free to use for anything and do whatever you want with it: I do ask for you to give me credit somewhere and let me know what it's being used for... although neither one is strictly necessary

    Todo:
    Clean up some of the operations (would be nice to reduce some calcs/list ops)?
    Check for nulls in more places (which would add support for deleting nodes)
    Make adding/deleting nodes better (adding at a custom location/deleting at all)
    Make frame that's shown into a collider
    Snap to terrain option
     

    Attached Files:

    Last edited: Oct 10, 2010
  2. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    I'd look for a rail making tool ;)
    Where you just click on some points on the terrain to make a nice curvy rail track.

    Good work so far!
    Keep it going :)

    Ethan
     
  3. reveriejake

    reveriejake

    Joined:
    Jul 8, 2007
    Posts:
    819
    Looks good so far! Keep up the good work!
     
  4. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Looks great! Nice work!

    As far as more to-dos, my suggestion would be road intersections. They haven't been figured out yet with the few road editors on the forum. That is a much needed feature.
     
  5. sagron6015

    sagron6015

    Joined:
    Apr 19, 2010
    Posts:
    32
    It is and it isn't hard to do intersections - right now on the generated mesh I'm giving it a straight-forward uv map. Easiest ways to do an intersection by my thoughts are:

    1: use a shader/script on the mesh that applies edging to the mesh after it's generated

    2: generate a material and handle overlapping uv's by applying an intersection texture to that part instead of the full road texture

    3: let the user set portions where a different texture (or different transparency) should be applied

    Nice thing is for railroad type thing as above you can just use a bump-mapped transparency shader to apply gravel and raised rails/slats - or you could have rails/slats and transparent on the rest so you see the ground below it.

    Edit: I'll post a sample of a railroad pic as soon as I fix up some of the UV mapping scaling.
     
  6. sagron6015

    sagron6015

    Joined:
    Apr 19, 2010
    Posts:
    32
    Fixed uvs, added detail level. Posted a transparent bumped diffuse railroad pic - I'm no artist though :). Doesn't work too well for the edges - not sure how to fix that. I'll work on intersections and then see about posting some of the code - Right now my code is in one script and it uses two others (SplineInterpolator and TangentSolver).
     
  7. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    Haha cool stuff ;)

    Looking forward to testing the code!
     
  8. Pyroman311

    Pyroman311

    Joined:
    Aug 14, 2010
    Posts:
    87
    Looks promising. Keep it up!
     
  9. sagron6015

    sagron6015

    Joined:
    Apr 19, 2010
    Posts:
    32
    First code posted - no intersections yet but hopefully that'll come in the next few days.

    See req's in first post to install

    Basic instructions:
    1. Create an empty game object
    2. Select it and add component ribbon
    3. Set number of nodes in properties
    4. Select node in list (under your game object) and edit away
    5. Add materials/shaders to game object
    6. Run!

    Note: Most changes made during runtime aren't saved
     
  10. sagron6015

    sagron6015

    Joined:
    Apr 19, 2010
    Posts:
    32
    Removed a sort which caused nodes to be read incorrectly after 10. Still working on intersections.
     
  11. sagron6015

    sagron6015

    Joined:
    Apr 19, 2010
    Posts:
    32
    New version posted (finally), see notes in original thread.
     
  12. DukeOfDesmo

    DukeOfDesmo

    Joined:
    Oct 29, 2008
    Posts:
    67
    Any chance of a tutorial explaining how this works? (not just how to use it). It would be very handy for me as a learning tool!
     
  13. sagron6015

    sagron6015

    Joined:
    Apr 19, 2010
    Posts:
    32
    How the code works or how the tool itself works? Just posted a link to a vid tutorial of setting up the basics.
    Edit: Nm, reread your post :p. At some point I'll write up a tut on how the parts work.
     
    Last edited: Oct 11, 2010