Search Unity

[RELEASED] Curvy 2 - the ultimate spline solution

Discussion in 'Assets and Asset Store' started by Jake-L, Sep 29, 2015.

  1. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I'm trying to decide whether to use this or another asset for a new project. The project leans toward quite heavy procedural generation at runtime, so many of the offline editing tools probably don't come into play. I'd like to generate completely new random paths at runtime (ie like a road or tunnel) and then a) extrude various geometry along it but varying it quite a bit as it goes, ie not just one extrusion for the whole thing. And then b) placing random objects along the path at runtime as well (which might themselves be procedurally generated or simple meshes). It seems like I'd have to sort of start from scratch at runtime and use the API to do this? Or is there a way to sort of set up a template or sample scene and then modify the curves and randomize the placements at runtime and have curvy auto-update the meshes?
     
  2. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    That's totally up to you. You can create templates or prefabs and change parameters at runtime or build anything from scratch using the API, or mix both as you see fit.

    In fact there is no gap between "offline editing tools" and runtime API, the toolbar "just" uses Curvy API.
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    But I guess my question is... can I create like a whole level offline, multiple spines with extrusions, multiple objects randomly placed along it etc... and then at runtime, 'randomize' that design and have curvy just automatically refresh all the meshes and object placements TOTALLY automated, or do I need to dip into some API stuff?
     
  4. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I've just stumbled into another problem, I had 8 splines in the scene and my frame rate went from 60fps to <15 fps,
    after hours of trial and error it turned out to be the 'show gizmos' check box on the curvy spline script advanced settings. turning off all 8 'show gizmos' got me back to 60 fps. you might want to look at what causes such a performance hit in the editor.
     
  5. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    In my experience, drawing gizmos and handles is actually very very slow so that kind of makes sense. Having a lot of them is probably not a good thing.
     
  6. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Yes, Gizmos in editor can cost performance, but on a decent dev machine you don't notice any big performance drops. If it does, lower EditorResolution in the preferences or disable "Show Gizmos" at the spline - it will be only shown then if part of a selection.

    @imaginaryhuman: You'll need at least get references to the objects in question and set properties.
     
  7. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I've a top of the range fast as it can go iMac, 10 splines on screen showing gizmos killed the fps.
     
  8. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    That's weird. Can you give me some details about the splines? Spline type, Spline lengths and perhaps total number of segments?
     
  9. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Sure, there are 10 GameObjects in the scene each one with a CurvySpline attached. Each one has only 3 control points. its easier to upload some images so here they are: Screen Shot 2015-10-24 at 5.04.53 pm.png Screen Shot 2015-10-24 at 5.04.42 pm.png

    I've turned off the gizmos as you can see. Turn them on and my in editor frame rate plumes to an unusable figure.
     
  10. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    I'd hazard a guess the problem is the length of eight kilometers (if I'm looking at the stats right), which is forcing the scene view to draw few thousands of cache points. Are you sure you need cache density that high for a spline of that size?
     
  11. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Yes 8k is about right. It's a path for ships to follow in an ocean so needs to be that big. How do I reduce the points on the spline?
     
  12. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    See that Cache Density setting? Enable Orientation visualization in the toolbar View menu to see the density for yourself, and drag that Cache Density slider to the left.

    Also, if most of your paths will use a scale like that, I'd also recommend changing maximum number of cache points per unit in Curvy preferences. Cache Density is a relative setting, so tweaking the PPU value down can make Cache Density values like 20 or 50 produce a reasonable number of points for your big paths.
     
  13. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    On top of that, if you only want a lower Gizmo rendering resolution, lower SceneViewResolution in the preferences.
     
  14. fivebits

    fivebits

    Joined:
    Feb 4, 2015
    Posts:
    9
    Hi,

    I'm trying to have a control point follow a game object. I thought CurvyConnection component would do that, but I see that only works for Spline-to-Spline connections.

    What's the recommendation on the best way of doing this?
     
  15. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Control Points are regular GameObjects, so just alter the transform of the Control Point. Have a Component that moves the Control Points' GO toward your target. After you changed the Control Point's position, the spline needs to know about it and update itself. To do this, either enable "Check Transforms" on the spline or get a reference to the Control Point component and call CurvySplineSegment.SetDirty() on the Control Point directly.
     
  16. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    310
    Very noob question: how do I instantiate a Curvy Spline via code? I think I have a sight problem, I couldn't find anything in the docs! In my current project I make heavy use of code-created splines and meshes. Also, how easy is it to set up a Generator via code, for extruding a mesh?
     
  17. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Just instantiate the spline GameObject like you would do with any other GameObject (e.g. by using prefabs).

    To setup generators, the easiest method is to set them up manually, save them as a prefab and then set parameters after instantiation. Adding modules completely from scratch at runtime is possible as well (use CurvyGenerator.AddModule()), but you'll need to link each output slot to a matching input slot then (e.g. myModule.Output[0].LinkTo(anotherModule.Input[0]))
     
  18. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    310
    Unfortunately this is not a solution, I believe I also need access to the CurvySpline component in order to add more points and switch between Closed/Open spline. Instantiating GameObjects with CurvySplineSegment component attached, and adding them inside the CurvySpline transform, causes an "ArgumentOutOfRangeException: Argument is out of range:".
    My excuses, I didn't specify that I also generate new nodes and modify them at runtime.

    Also, I don't now if it's a problem of mine, but I can only reference these classes in my code, and they are marked as obsolete:
    -GLCurvyRenderer
    -CurvyInitialUpDefinition
    -CurvyMeshSegmentInfo
    -CurvyVectorRelative
    -CurvyVector
    Am I missing a namespace?

    -EDIT-

    Ops, sorry, I rushed it too much. I found everything under the FluffyUnderware namespace. For some reasons it didn't import correctly the first time, I had to import it again. Thanks! :)
     
    Last edited: Oct 25, 2015
  19. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
  20. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    Hi Rod. No, unfortunately that's impossible right now. The asset supports extrusion, not mesh deformation at the moment. You can still replicate tracks like those easily with a small Curvy Generator setup (by replicating the cross section for rails/foundation and extruding it along a path, and instancing sleeper models along a path) - we include some complex examples of railroad scenes. But you can't use models like ones in that pack directly. Mesh deformation along the path is in the roadmap, but yeah, not available right now.
     
  21. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Jake L. @bac9-flcl

    Curvy 2 seems the most powerful curve solution in asset store. I really like it.
    Currently, I just use it to control how flying characters move in my mobile games.

    I have some performance related questions.

    1) SplineController (SplineController.cs) has a "Use Cache" option in "General" Section on inspector.
    What exactly does that option indicates? I saw it is as false by default.
    How to set/use this option in an appropriate way?

    2) CurvySpline (CurvySpline.cs) has a "Using Pooling" option that is set as true by default.
    How the pooling thing works here? For example, if I want to destory this CurvySpline object, what is the appropriate way to do destroying to makes sure the destroyed CurvySpline is pooled correctly?

    3) I found "Cache Density" of CurvySpline (CurvySpline.cs) can be set as much lower (e.g. 10) than default 50, and my flying missiles and birds still work well. Thus, I should set this as low as possible? Does this parameter has much impact on performance? In what kind of situations, I need high values for "Cache Density"? For example, in a scenario, I keep changing control point positions frequently?

    4) I may want to use huge number (100~200) of CurvySpline&SplineController in my scene to simulate many missiles. One pair of CurvySpline&SplineController is for one missile. Since all sample scenario I saw so far is using Curvy to drive several ships/trains, I am wondering if my massive-missile scenario will run efficient on current mobile devices. What are most important performance-related parameters I need to pay attention for my massive-missile scenario?
     
    Last edited: Nov 8, 2015
  22. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I posted this in the fluffyunderware forums, but I'm desperate and need a solution fast so I'm posting here as well. I know my issue is with an earlier version of Curvy, but the previous forum thread has been closed. So, here goes:

    I fired up a couple of projects that I haven't worked on in a while and suddenly Curvy wasn't showing its editor or any of the in-editor splines/control points, etc. I finally found out that my new anti-virus had quarantined CurvyResources.dll. So, I restored the dll and set it as a trusted source. But it still doesn't work anymore. I've deleted and re-imported the asset and still nothing. I've turned off anti-virus and still no go. Somehow it's been broken beyond just the CurvyResources.dll, but I have no clue what's wrong. I get no console errors and the game still runs and uses curvy splines just fine, but nothing as far as the curvy editor and visuals in the scene are working.

    I even tried a re-boot and still no go. I am, however, able to verify that Curvy is recognized by Unity. In Preferences, it is clearly visible with all the default settings. I'm baffled as to why this isn't working.

    upload_2015-11-7_17-30-45.png

    Any ideas what could be wrong?

    I'm using Unity 4.3.7 for Wii U and Curvy 1.61. This is the same version of Curvy I used when everything was working before.
     
  23. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    If enabled, cached values will be used instead of calculating on the fly.

    Currently, only Control Points are pooled, i.e. disabled/enabled instead of destroyed/created at runtime. Pooling is handled by the _CurvyGlobal_ GameObject and you won't need to do anything, it just works out of the box. Just be sure to add and delete Control Point with CurvySpline's API methods.
    Basically, Cache Density defines how many cache points your spline use for a world unit. Read here for more details!

    Like many other parts of game dev, there is no default recommendation on how to get the most performance out of the system, because it depends on too many parameters. Knowing the system and your game requirements is the key.

    First, you should know that Cache Points data is calculated at spline initialization time or when you change the spline. Then, to see how your cached spline looks like for Curvy, enable "Approximation" and "Orientation" in the view settings.

    To get an idea what cache settings results in what performance, run the Performance example scene (perhaps on your target platform) and play with the various options.
     
  24. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    It's weird that CurvyResources.dll triggered your AV because it only contains embedded images used by the editor. Nothing more, not a single line of code, nothing harmful in any way. Did you tried disabling your AV completly before importing Curvy?
     
  25. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I haven't tried disabling AV during a fresh import, but I can give that a try. I'm not real happy with this AV anyway. It seems to think everything is malicious, including Unity itself. But that was resolved by making Unity trusted. But doesn't seem to have worked for Curvy. I'll try it though.
     
  26. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Nope, it still doesn't work. So it is probably no longer the AV that's a problem. I am at a loss. I've been using Curvy for a long time and never had a problem and suddenly this happens. There must be something causing the editor stuff to fail. Still no errors at all, but no editor controls in the scene and I can no longer see the splines or control points in the scene. All I get when I click on a control point is the transform widget at the position in the scene where the CP is supposed to be.
     
  27. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Finally figured out what was up. After fixing the quarantined file, it should have worked fine. However, I found that my editor Layers had everything turned off except UI. I guess I did that when I was working on the UI and didn't realize it. Very strange that I didn't track it down sooner, but I didn't try to work on other scene elements until just a little while ago and then I realized I couldn't see them either. Sorry for the bother.
     
  28. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Jake L.

    Thanks a lot for your answering.
    I am still a little bit for some parts.

    I am wondering why SplineController.UseCache is set as false by default, while CurvySpline.CacheDensity is not set as 0 by default? By default, "CurvySpline.CacheDensity=50" already provides decent calculated caches, and "SplineController.UseCache=false" does not use the existed caches?

    For ControlPoints pooling, I read related source code a little bit.
    I set some breakpoints in Vistual Studio to try to understand how ControlPoints pooling works.
    I found if I use GUI tool (Draw Spline) in toolbar to create ControlPoints, CurvyGlobalManager.Instance.ControlPointPool.Pop() is called.
    But If I delete the whole CurvySpline object in hierarchy,
    CurvyGlobalManager.Instance.ControlPointPool.Push() is not called? That means if I want to do pooling over ControlPoints, I cannot simply call Destory(CurvySpline object)? Instead, I have to manually call CurvySpline.Delete(ControlPoints) before I destroy the whole CurvySpline object?
     
  29. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    The main reason is because Orientation needs precalculated values, so CacheDensity is set by default. Calculating position directly may result in a smoother movement for some splines, so we disabled Fast

    You're right, this is a design flaw and this shouldn't be neccessary. We'll fix this, thanks for pointing this out!
     
  30. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    @Jake L.

    I see. I plan to mainly use Catmull Spline. I will use SplineController.UseCache=false by default.

    Thanks for your confirming.

    In addition, I saw some awesome railroad scenarios in Curvy asset. These scenarios contain some complex tree editors. But I didn't find any detailed video tutorial or manual for Curvy Generator.
    On related webpage ( http://www.fluffyunderware.com/curvy/documentation/generator/start ), you mentioned that "But that's just the regular use case, and we have some great plans for the future".

    I guess you guys are still developing/polishing the Curvy Generator?
    When Curvy Generator is polished enough, you will provide detailed video tutorials/manuals for it?
     
  31. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    We're planning to make a CG video as soon as possible (once we solve the audio recording issues) - I believe there is already enough material to warrant a video, no need to wait for future releases. All sample scenes with those railroads I've made rely solely on existing, ready features, not on some custom scripts or yet unreleased features. :)

    If you have any questions about setup of those scenes, feel free to ask! Aside from that, good way to learn CG is to try the included presets. For example: create a new scene, create a simple spline, create a Curvy Generator object, open the Curvy Generator editor from it's inspector, right click in the empty space, choose the Shape Extrusion preset - this will create a simple node graph for extruding a cross section along a path and generating a mesh from the resulting volume. Then just plug your spline into the Input Spline Path node, and voila - you should start seeing a mesh generated out of the graph and it's inputs! Then play with the Input Spline Shape and Shape Extrusion node settings (e.g. play with resolution in Shape Extrusion or remove internal spline from Input Spline Shape node, plugging a second custom spline there instead, like I did in the advanced extrusion sample scene). :)
     
    Dan2013 likes this.
  32. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    310
    Looks like I found a severe bug.
    I made a Generator with a Shape Extrusion template and modified the original shape to be something like an upside-dow "U" shape. I then added a personal material to the output and set different values in the UV Offset and UV Scale, inside the Volume Mesh component. Finally I saved the whole generator GameObject as a prefab in my project folder.

    I came back to the Volume Mesh component, clicked on Add Material Group, and Unity crashed. After I opened the project, the prefab was missing all the components inside it, Transforms too.

    EDIT: looks like an isolated case, it didn't happen again even doing the same things.
     
    Last edited: Nov 14, 2015
  33. Charles-Van-Norman

    Charles-Van-Norman

    Joined:
    Aug 10, 2010
    Posts:
    86
    Hi, just purchased your product and I am looking at the "26_CGExtrusionExtendedUV" scene. I want to define a shape and extrude it along the spline but I cannot figure out how to do this with your Wizard. Is there a video or explicit step by step guide? Thank you
     
  34. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Sorry for the delay, didn't get an alert mail from the forum this time. CG introduction video is in production and should arrive soon(tm)...
     
  35. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Curvy 2.0.3 released
    • (NEW) Added Pooling example scene
    • (NEW) Added CurvyGLRenderer.Add() and CurvyGLRenderer.Delete()
    • (FIX) CG graph not refreshing properly
    • (FIX) CG module window background rendering transparent under Unity 5.2 at some occasions
    • (FIX) Precise Movement over connections causing position warps
    • (FIX) Curvy values resetting to default editor settings on upgrade
    • (FIX) Control Points not pooled when deleting spline
    • (FIX) Pushing Control Points to pool at runtime causing error
    • (FIX) Bezier orientation not updated at all occasions
    • (FIX) MetaCGOptions: Explicit U unable to influence faces on both sides of hard edges
    • (FIX) Changed UITextSplineController to use VertexHelper.Dispose() instead of VertexHelper.Clear()
    • (FIX) CurvySplineSegment.ConnectTo() fails at some occasions
     
    bac9-flcl likes this.
  36. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    +++ Breaking News +++ Curvy Generator Tutorial Video just arrived +++ Breaking News +++ Curvy Generator...+++

     
    Last edited: Jan 27, 2018
    overthere likes this.
  37. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    If anyone has questions about generators, feel free to ask here. Tell us what you're trying to achieve, or what sample scene setup you're having trouble understanding, and we'll try to help.

    This should be covered in the beginning of the video above. The only special thing about that scene is how extrusion in it is using control point metadata to drive UV mapping. I mention that later in the video during dissection of the railtrack scene, but feel free to ask if some particular detail is still unclear! :)
     
  38. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Hi,
    Thanks for the video but it looks like there is a problem with the audio after 16 min 45 sec of it. Also image goes black after 20 minute.
    Will take a look later again.
     
  39. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Doh! Just uploading a corrected version! Thanks for reporting!
     
  40. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    elbows likes this.
  41. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    200
    I saw Curvy was updated to Version: 2.0.3 yesterday. Is this little issue fixed in the current version?
     
  42. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    I have a question. Does this product support multiple cross-sections (and blending between them) along a path? This looks fantastic.

    Probably a little more bizarre a request but I would love to define a planar shape via two paths (interpolated between them) does the generation system make it possible to define my own component that could possibly do this?
     
  43. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Of course!
     
    Dan2013 likes this.
  44. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Shape morphing isn't in yet, but on our ToDo-list and should be available in one of the next updates.

    Blending shapes, i.e. mixing shapes to be used by whole extrusions, is already possible.

    In general the Generator system is extendable, so you can create your own modules to do even the most bizzare things :)
     
  45. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    That's good enough for me. The API and the fact that exposes everything from design time at runtime is why I am purchasing this.
     
  46. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    What happened to CurrentTF? With FollowSpl;ine being replaced by SplineController, I no longer see the CurrentTF field. How do we check for reaching end of spline now?
     
  47. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Use RelativePosition, it equals TF in case of the SplineController. If you want to just know when the end (or any Control Point) is reached, consider using Events. This way you won't need to inherit a custom controller just for that.
     
  48. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    Hey Jake, i have Curvy for a long time, but just updated to the last version from the asset store without checking the version requirements and it doesn't import in Unity 4.5.2.
    Is it still compatible with U4?
    If not, where can i get an older version of Curvy?

    Thank you!
     
    Last edited: Nov 22, 2015
  49. Jake-L

    Jake-L

    Joined:
    Oct 17, 2009
    Posts:
    397
    Sorry, Curvy 2 needs Unity 5.0+. I'll send you a PM regarding the old version.
     
  50. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    And here is a new trailer!



    Sorry for 720p, had some issues exporting the video in higher resolutions and YT compressed the crap out of it. Here is OneDrive download with a less compressed version (and if I'm not mistaken, the preview player on the download page delivers less compressed video right in the browser too): http://1drv.ms/1P2tKYF

    First few shots depict a showcase scene I'm releasing soon, and the rest of the trailer shows the sample scenes already included in the package.

    Pretty much everything in the video is spline-based. Forcefield in the first few shots? Skinned geospheres with bones shifted over Curvy Splines using Curvy Controllers. Cars? Curvy Controllers. Glowing cables? Curvy Generator based extrusions. Diagrams on the screen? Spline-based points. Railroad objects? Volume and spline based object scattering. And so on. :D
     
    elbows likes this.