Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Curvy: Fast Spline Interpolation

Discussion in 'Assets and Asset Store' started by Jake-L, Feb 14, 2013.

?

Is it fine to release Curvy as a Unity 4.2 package?

Poll closed Dec 27, 2014.
  1. YES, I'm already using Unity 4

    103 vote(s)
    88.0%
  2. YES, but it should work in Unity 3.5 nevertheless

    7 vote(s)
    6.0%
  3. NO, I don't have Unity 4 installed and won't be able to access it in the AssetStore

    7 vote(s)
    6.0%
Thread Status:
Not open for further replies.
  1. SidarVasco

    SidarVasco

    Joined:
    Feb 9, 2015
    Posts:
    163
    Using mesh builder, how come the textures applied messes up when i rotate the parent? I'm trying to interpolate between several segments when one is ending. This works fairly well. I was hoping of making different curves and throw them in prefabs so i can build my tracks that way. But upon rotating the parent game object the data is just wrong.
     
  2. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Never seen this behaviour, just tried rotating a meshbuilder's parent and UV keeps as is. I'll send you a PM for further investigation.
     
  3. lastlevel

    lastlevel

    Joined:
    Mar 26, 2013
    Posts:
    9
    Hi Jake. I am operating in 2D mode in Unity with all control points on the X-Y plane. I have a mesh builder attached to the spline that is set to "Line" mode. Curvy appears to be determining the up vector as the "Y" axis and generating the mech aligned to Y-Axis. I am adding all the control points at runtime and generating the spline manually. I can rotate the CP, but it appears to rotate the HandleIn and HandleOut controls at the same time creating kinks in the first section of the generated mesh. All following meshes are OK, as those CPs are not rotated -90 degrees.

    Is there an easier way to accomplish the same thing?
     
  4. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    2D handling (especially when using Bezier splines) is limited in 1.61, but will be greatly improved in 2.0 (release getting closer). If you can't wait, see here.
     
  5. Ruvane

    Ruvane

    Joined:
    Mar 4, 2015
    Posts:
    1
    Hey Jake,

    Is there a way to create a Spline (either at runtime or before) from a text file containing global coordinates and corresponding normals for orientation? Thanks!
     
  6. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Not builtin, but there are some scripts floating around, see here.
     
  7. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Curvy gui/toolbar seems to be missing in Unity 5 :(

    N
     
  8. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Sorry for being a week offline, I struggled hard with an influenca. I'm sure this can be fixed, will post about this tomorrow.

    Edit: I can't see any problems with the GUI/toolbar in 5.0 here, everything showing like expected!
     
    Last edited: Mar 16, 2015
  9. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Sorry my bad - it seems to be working fine in Unity 5.

    Apologies for any alarm caused.

    Nalin
     
  10. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    I bought Curvy recently, to extrude shapes at runtime controlled by playmaker(so this was my plan :)). Controlling the length of the extrusion.

    But I can´t set the property of "to TF" with playmaker FSM for the "SplinePathCloneBuilder" Script. I really followed the tutorial movies from playmaker. I can change the value in editor and the first time i hit play it jumps to the new value, but then Set Property doesn't do anything. Am I missing something?

    And extruding on linear spline gives really bad results. I know I can fix it with bezier, but it should give better results out of the box!

    Also I would be very happy if there are more playmaker actions for Curvy.

    EDIT:
    Found out that I have to call action "Send Message" "Refresh" after action "Set Property" "to TF" in Playmaker!!
    This takes hours to figure out. But I learnt something ;).

    Michael
     
    Last edited: Mar 25, 2015
  11. Deleted User

    Deleted User

    Guest

    Hi there. I was curious if Curvy would be appropriate for creating a map with smoother coastlines like this:



    I know curvy is really designed for lines, rather than shapes. I was wondering if there was an elegant solution to use curvy for the coastline, but somehow use that around an ordinary mesh with a .PNG texture. My goal is to have a landmass with a spline-based natural coastline, but with a texture inside the shape for more natural-looking grass. (Mainly ignoring the mountains and trees for now.)
     
  12. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    Would I be able to programmatically change the movement speed of an object moving along a spline when the object has already started moving? Would there be any problems if the change in speed occurs 5 times+ a second, such as acceleration?
     
  13. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Yes you can set the speed if you use the FollowSpline script as an example - this is something I do already.

    5+ times a second - not exactly sure though I guess it depends on the actual speed changes / acceleration, as you may need to smooth these out.

    HTH

    Nalin
     
  14. Berserker44

    Berserker44

    Joined:
    Sep 1, 2013
    Posts:
    29
    Hello!

    I have purchased Curvy and I am making a infinite runner. I want to create a number of paths for the player to travel on. When the player reaches the end of the path, I want the player to transfer instantly to another path that has been generated. Kind of like an endless road. I have been trying to use curvy but I am having a hard time having the player go to the next path on runtime. The main problem is that the paths need to be random so the paths need to be loaded and played dynamically.
     
  15. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    Thanks it seems to work well at changing the move speed. Also it had the change path at run time. Which i couldn't get working with other spline tools.

    Though only the Advance Packages had what I wanted.. The Follow-spline example would reset to the starting position if i changed the speed.
     
  16. BortStudios

    BortStudios

    Joined:
    May 1, 2012
    Posts:
    48
    I'm working on something where I need quite a few spline meshes with mesh colliders. Currently I'm using Curvy but, apparently, need to save the spline mesh as a mesh asset and manually attach it to my mesh collider. This isn't only time consuming, but also makes my assets folder cluttered and hard to manage with so many meshes. In addition, each time I change the spline I have to re save the mesh and attach it again.

    Is there a way to make Curvy automatically use its spline mesh as the mesh collider mesh? If not, can that be implemented quickly? I'm also using Prototype, which generates meshes programatically as well and also uses them automatically for mesh colliders, so I know it should be possible

    Thanks
     
  17. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    FollowSpline component resets when changing in the inspector. At runtime this shouldn't happen.

    @BortStudios: Collider handling is improved in the upcoming version. In the meanwhile, does this solution help?
     
  18. BortStudios

    BortStudios

    Joined:
    May 1, 2012
    Posts:
    48
    Yep, I hadn't considered just adding something like that to the Start function of the mesh generator script. Works fine.
     
  19. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    How exactly do you tag a control point to make it a connection point so you can choose which path you follow. I dont seem to to be able to add a connection via spline script. Im looking at the advanced ConnectionWalker Demo and would there by any simple way to ignore the Z axis movement. ie a 2d. I tried all the 5 or so movement types they dont seem to work out.

    Edit never mind i figured it out. You get a different menu if you select two control points

    Just need a way to ignore the Z axis and move along to curve till the X and Y axis are met.
     
    Last edited: May 2, 2015
  20. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    Would splitting a very long path into 2-3 sections then join up with joints improve performance?
     
  21. QFGlenn

    QFGlenn

    Joined:
    Feb 21, 2013
    Posts:
    39
    I am making a rail track system. I have 2 Clone Mesh-BLD objects for the rails and one clone-bld object with the planks. My problem is that at times the rails come too close together to one another, or like when I create bends or twists the objects(both rails + Planks) don't all align.
    Screenshot - 5_12_2015 , 6_47_59 PM.jpg
    I am hoping this new version will fix this problem.

    Screenshot - 5_12_2015 , 6_46_06 PM.jpg
     
  22. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Did you try to use a single spline at the center of the track and offset both rails (-x and +x) and clone the planks without offset?
     
  23. toto2003

    toto2003

    Joined:
    Sep 22, 2010
    Posts:
    528
    hello jake,
    is it possible to have multiple materia,l pattern in one curve? right now i have the choice to assign only one.
    thanks
     
  24. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    The new version will cover multiple materials along an extrusion shape (think of road and banks). Blending materials along the path ("extrusion Z-axis") might be added later, though.

    You can apply for the beta (RC1 is on the way) here!
     
  25. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    While I haven't purchased Curvy yet, I can tell you what our use cases would be:

    1. ziplines, we want to evaluate any point along the spline but also generate a mesh for it.

    2. we need to get the bounding area for the zipline to add a trigger to the whole thing so when player is near it we can begin checking to see if we can grab it.

    3. Be able to get the nearest point to the line in 3D space (player's hand distance from curve), and if it's close enough, get the overall curve t value (or % along it) so we can begin animating the player sliding down it from that position.

    4. In the case of roads, might be interesting if it would render to deferred like a decal so we can feather the edges of the road against say, a mesh based terrain.

    Good looking asset!
     
  26. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    1-3 can easily be done (Bounds are automatically calculated in 2.0).

    Could you elaborate on the fourth point? I'm no graphics artist, so while it sounds interesting, I can't figure out what you want to achieve :confused:
     
  27. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    4. just roads which don't intersect with underlying geometry via command buffers, so it looks ok and non clippy :) but I imagine it would be a pain to develop a decal-ish road system so I'm not really expecting anything :)

    Thanks for reply
     
  28. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Hi, using the PlayMaker actions I need to move an object Xnumber World units along a spline (from a current spline based position) - as a single move.

    Example:

    Object is at TF 0.15
    Object should be moved 55 World units down the spline in one go (not animated) (which could result into something like TF 0.95 - OR TF 0.05 if a loop has occurred)

    I'm stuck, any help would be very appreciated (including C if Playmaker is not your thing)

    Thanks a bunch! :)
     
  29. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    How goes progress? Watching and waiting before buying - must have full compliance with 5 and no issues with how I want to organise the hierarchy.
     
  30. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    I have been using Curvy for ages, and though Playmaker documentation is unfortunately not updated and bugs can hang for months and the developer sometimes thinks it's great to be harsh instead of polite.. I can still recommend Curvy, and yes, as far as I can understand your projects description, it'll be a breeze to make your setup using Curvy.

    There'll be several ways to generate the ziplines, several ways to detect if you are close etc - but it should all be easy and doable in a very short time with Curvy!
     
  31. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Crumbs that's a bit worrying, hearing that the author is harsh and bugs remain. Will shop around, thanks :)
     
  32. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    So, how about Curvy Follow Spline? (Playmaker action) that is apparently not even documented? When should that be used (with reference to Move along etc)?
     
  33. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Well, have a look at http://fluffyunderware.com/pages/unity-plugins/curvy.php - references to utterly outdated Unity version numbers right on the front page.. that's always a great hint of the level of attention ;)
     
  34. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Oh, but hippocoder: I know all the spline libraries, I should think. And frankly, if you want to build mesh (roads and ziplines) I'd still chose Curvy, I do believe it is the strongest in this field, has some very powerful features no other package I know of have there.
     
  35. indie_dev85

    indie_dev85

    Joined:
    Mar 7, 2014
    Posts:
    52
    Curvy is currently best spline solution present here,extensively using it in my project :)
    @Fritsl , in your case i can suggest you the following steps:

    _tf = Spline.GetNearestPointTF(Future position 55 units ahead of current pos)(expensive operation)
    get the updated localsegmentTf --->Spline.TFToSegment(_tf, out_segLocalF)
    last get Position on the spline using ---> posOnSpline = CurvySegment.InterpolateFast(_segLocalF)
     
  36. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    @hippocoder:
    Well, I'm not harsh in general, but polite communication needs at least two polite persons.

    Anyways, Curvy 2 is fully Unity 5 compatible (in fact it has 5.1 as a requirement) and you may want to try the beta (RC1 just completed today). The point with bugs not fixed for ages isn't true for the majority of bugs found in Curvy. It's just that some things can't get "fixed" but need a full rewrite, especially the mesh extrusion problem. Curvy 2 fixes all known longtime problems.

    @Fritsl: I can't give you an answer right out of my head, but I'll look into tommorow morning and post a solution here after that.
     
    hippocoder likes this.
  37. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Using the current set of custom actions this is possible, though not as easy as it should be. New actions will most likely use a better design to make things like that easier. However, there you go:

    What you need is to use the FollowSpline action and a variable "currentTF". Set both "Initial Position" and "Store TF" to this variable. You now can alter currentTF and start the state over to jump to a new starting position. To alter the variable by world units, use CurvyGetValue to convert TF to distance, then AddFloat to the result and CurvyGetValue again to convert the new distance back to TF.

    Note that the result of CurvyGetValue will be clamped, so if you have a looped spline you'll need to divide your new value by the spline's length. The length can be retrieved with the first call to CurvyGetValue as well!
     
  38. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Thanks Jake - and Yes, this is quite a lot of steps to move a GameObject X units down a spline in Curvy :)
    Your solution is much like my own hack, I just thought there had to be a better way for something this trivial.

    Curvy Follow Spline: There is apparently no documentation about this action (as requested earlier) ?
    Would it not be more 'correct' to use 'Curvy Allign to Spline (instad of the undocumeted 'Curvy Follow Spline') ?

    PS: If I'm feeding Curvy Get Value a calculated World units and then draw out TF ('Store TF'), I can get arund the clamping.

    PS 2: Looping causes bugs (in my case I have had severe problems, and I thought it was because of my poor hacks, but apparently natively in Curvy): Take your 'Distances' example scene, and just set speed to something like 100, then press play, wait a short while (like a second or so) then press Pause, and look. It's all messed up. This constantly causes problems on my 'Racing' style games when other Game objects, calculations and more depends on Curvy, and Looping is doing nasty stuff. Skærmbillede 2015-07-10 kl. 12.06.39.png
     
  39. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Looping isn't causing bugs. In fact the Distances example suffers from floating point inaccuracy, that's why the cubes get "out of sync" after a while (or a very short while if setting such a high speed). To address this you would move just one cube and position the others with offset, but I want to keep examples as clean and short as possible.

    Regarding FollowSpline (which is fairly self explainating) vs. AlignToSpline, they both do mostly the same, but FollowSpline constantly advances position based on speed.

    But don't worry, both actions will most likely become obsolete with the new version (I'm just working on PM actions for Curvy 2). Instead you use the regular movement controller component, all properties are exposed and can be read/set from within PlayMaker. In your above example you then just read the "AbsolutePosition" property, add a value and set "AbsolutePosition" again and it will respect the Clamping you've set on the Spline Controller.
     
  40. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    Thanks a bunch Jake, we are all looking foraward to your new releases!

    :)

    I agree that Follow Spline should sort of explain itself, but please understand that with other actions named such as Move Along Spline.. from the users wiewpoint it can be hard to easily understand when to use what when one is not documented at all, and it's easy to be left with the feeling that 'I am not doing this right' and then you get more silly questions in the forums ;)

    Speaking of which: It's kind of silly that you spend so much time documenting, and then your wiki is not searchable. As an example, if I want to search MoveAlongSpline or Move Along Spline - also to see if there are C knowledge to make me understand the Playmaker.. nothing is there.. apparently.

    I mean, now that you spend so much time on it.. Skærmbillede 2015-07-10 kl. 19.19.13.png
     
  41. Fritsl

    Fritsl

    Joined:
    Mar 10, 2013
    Posts:
    211
    OH, Jake, just came to think about this: One of the few areas where Curvy is not the leading Spline package (as of writing this), is the lacking support of 'Drop To Ground':

    2 Simple Editor features:

    ---1:

    Drop to ground [Optional distance]
    [OK]

    ---2:

    Drop to individual transform rotation [Optional distance]
    [OK]
    ---

    - Will need ground or in/outwards object to have a collider (no collider = no movement of that point)
    - Will just do a ray to either ground on world Y, or local Y and set points at [optimal distance] from the first collider hit.

    It used to be possible to use third party tools with Curvy to do this, but for some reason since Unity 5 (as far as I recall), it does not work any longer. (Maybe it was since 4,6 - not sure). Nothing happens now.

    I hope you can see how this should be a fairly simple thing to add to your fantastic package, and how it'd make it even easier to make things such as racing games and other 'groundhugging' and or 'above or below ground' / around sphere etc etc..

    I think this would be the thing that'd make Curvy 100% market leading in 90% of typical use cases ;)
     
  42. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    The current docs are made with Doxygen, so there isn't much I can do about it. In the future only the plain API reference will be done separately with Doxygen while docs/manuals are integrated in the website/Wiki (I hope to find a proper way to integrate doxygen output into the Wiki, but there is no working solution available, and because anyone coding with Visual Studio will see API reference integrated anyways, it's not high priority at all for me). Don't know if MonoDevelop integrates API docs, though. But that's a MD problem...
     
    Last edited: Jul 11, 2015
  43. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Hi Jake,
    I must say I am very happy with Curvy, but why the choice to use 5.1 for the new version?

    Anyway, I have some bug and since I will stick to this version(will use 4.6 for the release of my game), would like your help to fix it.

    When using the spline path clone builder, sometime I don't know why the editor glitch and screw up some values.
    It's probably the editor fault itself, as I have similar issue on some procedural tool I wrote but I need to work around it.

    This end up in resetting the segment length and ApproximationDistances.Length return 0 in DistanceToLocalF and the objects overlap.
    Where is best to place a forced refresh in the code?

    Also now that I have several mesh and clone builder, often the editor freeze at play. I noticed you use an infinite while loop for initialization, could it be there is some racing condition and it never gets out?
     
  44. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Found the bug.
    On _RefreshHierarchy you reinitialize ALL the control points(_InitializeControlPoint), but then in some cases refresh only what's needed thus the part not refreshed become zeroed.

    How do I solve this without risking to break other parts?

    For now I am calling Spline.RefreshImmediately(); instead of Spline.Refresh(), inside the clone builder Refresh, seem to work, don't know if it can create other issues.
     
  45. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    The main decision was to use 5.x for a number of good reasons (mainly better editor coding options) and 5.1 seems to be quite stable. But it should be possible to downgrade to 4.6 (I'll run some checks before release) without much trouble, so you're not neccessarily bound to Curvy 1.6.

    Saying that, upgrading might require some work on your side depending on the features you used and custom code you had, but I'm pretty sure you won't look back once you got your hands on Curvy 2. Just a bit of patience, it won't be long until release.
     
  46. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I have a question concerning dynamic mesh extrusion and LOD groups. I'm building a 1 km long bridge that doesn't need any baked components. Would it be possible to have the dynamic mesh be decimated along a curve. I haven't purchased the asset yet and would like to know how Curvy could help me.
     
  47. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Support for LOD-Groups isn't builtin yet (good idea, though, just added it to my todo's), but meshes can be optimized while extruding. Then only segments are added when a certain angle treshold is reached, resulting in much less vertices if the path isn't very curvy. This optimization does not apply for segments only, but for the extruded shape as well. So if your bridge is straight like most bridges are, you won't have much vertices anyway.

    This applies to Curvy 2.0 (Beta RC1 available), most of it to 1.61, too.
     
  48. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Would it be possible to make this work with a distance threshold as well as the angle threshold? My bridge does have a distinct curve and it varies in height too.

    Maybe I could make some empties along the curve to measure distance.
     
    Last edited: Jul 18, 2015
  49. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    There's a minimum distance parameter for the generator which prevents the creation of too much segments. But perhaps I misunderstood your idea.
     
  50. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    Is the distance parameter per generated mesh or is it global? Could I simply have a high poly mesh be generated close, and a low poly mesh farther off?
     
Thread Status:
Not open for further replies.