Search Unity

SplineMesh, the plugin to create curved content

Discussion in 'Assets and Asset Store' started by methusalah999, Dec 14, 2017.

  1. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Glad to hear it. Please ask if you need any support.
     
  2. SatyPardus

    SatyPardus

    Joined:
    Oct 7, 2016
    Posts:
    7
    Hello. I love this plugin. It saved me a huge amount of time and a big headache.
    Though I have a few problems to understand.

    First of all, how would I use the MeshBender and SplineMeshTiling in a way, that it repeats a mesh along the spline and then stretches it to fill out the remaining space? (Not adding half a mesh at the end)
    Second thing would be, how do I go about implementing some sort of LOD for the generated meshes? I want my players to be freely able to build pipes and lines, but it seems like a bad idea to just use the full mesh on all distances.

    Any push in the right direction would be greatlly appriciated. The whole mesh bending math goes way over my head.
     
  3. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    About the spline filling, many solutions:
    - using curve space and "stretch" fill mode will correctly fill the entire spline, but the meshes scale may vary from curve to curve, depending on the length of each curves.
    - You can repeat the mesh with a constant scale, and fill the remaining space with a stretched last mesh, by creating your own tiling script.
    - Alternatively, you could find the best scale by dividing the spline length by the number of meshes you want to fill in, to obtain both a constant scale and no remaining space at the end. Done again with a custom tiling script.

    Please note that creating your own tiling script is not a big deal at all. SplineMesh as been made to be extanded this way, as it is impossible to provide a simple tiling script that works in all situations. Just make a copy of SplineMeshTiling to begin with and look at the code, it will be done in no time. Of course, I can provide assistance on this part if required.

    About LOD, i'm afraid there is no built-in support for LOD in SplineMesh. You will need to modifiy the tiling with something like that:
    - add the different LODs of the mesh as parameter in the custom tiling script,
    - bend all the versions of the mesh instead of the base mesh,
    - store the resulting MeshRenderers in the corresponding LOD group.

    Good luck !
     
  4. SatyPardus

    SatyPardus

    Joined:
    Oct 7, 2016
    Posts:
    7
    Thank you so much for the tips. I'll try to implement them.
     
    methusalah999 likes this.
  5. tooupi_unity

    tooupi_unity

    Joined:
    Mar 30, 2020
    Posts:
    1
    Hey, I downloaded yesterday SplineMesh plugin and I encounter two issues:

    1) Example Tentacle script behaves like it's not working. I'm changing values of start and end scales but mesh remains without any changes. Applies both to new splines and example "4.Tentacle" from showcase scene. Not sure If I'm missing some steps on how to do it

    2) I'm using mesh that have socket-like ending, because of that next mesh is appearing at the height of sticking out elements instead of place where it would fit to the socket, leaving gap between. Is there a way to make next mesh appear closer to the previous one?
    I uploaded a screen so It will be more apparent what am I talking about. So far I'm moving segments by hand to fit them

    I would be glad to hear any tips on how I can manage those cases
     

    Attached Files:

  6. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    ExampleTentacle is indeed bugged, thanks for the report ! To make it work, please add
    spline = GetComponentInParent<Spline>();
    at the top of the OnValidate method, line 30. The spline variable is only set when the component is enabled, which was the case before because it was executed in the editor view.

    About overlapping your meshes, I understand the need but no, you won't be able to do that with the script SplineMeshTiling. This script will place the meshes one after the other, using their limit vertices in the x axis.

    BUT ! SplineMeshTiling is a convinent script because it covers 80% cases, but it is definitly made to be replaced by your own custom script whenever you reach its limits. This is not a big deal at all. Please start by duplicating SplineMeshTiling and digging into the CreateMeshes() method.

    There is no complexity here. SplineMeshTiling mission is only to help users to define their own tiling and manage the generated object life cycle. You will be able to place your meshes at the correct distance from one another in no time. Of course, I can provide further assistance if needed.
     
    tooupi_unity likes this.
  7. MSoderberg

    MSoderberg

    Joined:
    Jun 14, 2019
    Posts:
    20
    Hello. I want to thank you for this free and amazing asset.

    I have made my own Bezier cubic curve and I am looking at your code to get inspiration/help how to bend meshes along my curve. I simply want to replicate what is done with the "Basic pipe" example in the showcase scene.

    What I don't understand is how the mesh is drawn in the Scene view. All that is needed is to add a Spline component and Spline Mesh Tiling component and then adding my mesh to the Spline Mesh Tiling component for it to work. But there is no Editor script for the Spline Mesh Tiling component, so how does Unity know how to show the mesh in the Scene view? I thought this was done using an Editor Script using OnSceneGUI(). Also the Spline Editor script does not seem responsible for this, but maybe I am wrong?
     
  8. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Editors are not responsible for any game logic that run during play mode.

    To draw bent meshes, SplineMesh replies on standard Unity mesh rendering. It generated the needed game objects and assign the bent mesh to their meshFilter component. You will find that creation step in many examples of SplineMesh, starting with the basic SplineMeshTiling, in the CreateMeshes method.

    Please note that a game object pool is used to avoid creating gameobject unnecessarily.
     
  9. Yurei-Okami

    Yurei-Okami

    Joined:
    Sep 8, 2014
    Posts:
    2
    Hi. First of all, the asset is great. It helped me a lot getting cables to work in this minigame I'm making for my VR game.

    The only problem is that I need the cable to "Update In Play Mode", but the mesh doesn't move unless Static Batching is unchecked. The issue is that since the game is for VR, the performance bottleneck can be pretty tight and reducing the number of batches with Static Batching would really help in that aspect.

    Is there no way to get the meshes to update in play mode and still keep Static Batching?

    I'm using Unity 2019.3.4f1.
     
  10. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    This is indeed a good question. deactivating the static batching was a good woraround but it is not a valid fix.

    I don't know much about this Unity bug and about the static batching in general, but here are two leads to follow :
    - Originaly, the bug was appearing when you canceled a build. When the bug was here, it was forever and only a Unity re-install was resolving the issue. It is now marked as fixed, but it may be worth to try with a fresh Unity install.
    - The static batching accurs on the scene scale, as far as I understand it. There may be a way to mark the mesh as not being part of the scene when the scene start, for example by removing the mesh and add it again in your script, or duplicate the mesh into a new one. The idea is to create the mesh after the batching has finished.

    I don't know if any of this will work, but i'm very interested in any information on the subject, as this bug has annoyed a lot of SplineMesh users for a long time now.
     
  11. Yurei-Okami

    Yurei-Okami

    Joined:
    Sep 8, 2014
    Posts:
    2
    Hi, thanks for such a quick response!

    After reading it I decided to see what I could do so I took a look at the mesh generated by SplineMeshTiling and noticed it gets set as static when created. After unchecking Static, it began to move as supposed to. It doesn't fix the bug, but since I don't use many spline meshes in the scene I can certainly afford to have them as non-static.
    I believe that is a fairly acceptable workaround for most people facing the same issue I did \o/
     
  12. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Indeed, if you need the mesh to update it can be consdered ad non static of course. So the generated game objetcs are static by default? That's my bad.

    I've changed the line 111 of SplineMeshTiling to
    res.isStatic = !updateInPlayMode;
    . Should be better in most cases, as you mentionned.

    Thanks for the help !
     
  13. Kalcen

    Kalcen

    Joined:
    Sep 19, 2016
    Posts:
    11
    First off, this has to be some of the most fun I've had with a plugin, and the fact that its open source and free is amazing, thanks so much!!

    I am trying to control camera rotation by treating the spline as an animation timeline, pretty sure all I need for this is to get a tracked object's projection sample to read as a point in time along the spline. The difficult part is that the plugin makes it very easy to find the time along the current curve, but I'm looking for the time in the spline as a whole. I did look at the ExampleFollowSpline script for some hints, but it looks like the way that script finds the curve index is by comparing the rate to the node count, and in my case the tracked object could enter the spline from any arbitrary point, not just at the "start position" so the "rate" would be harder to track in this case.

    Is there a way that I'm overlooking that would allow me to identify the curve index of the projection sample, so that i can add that to the projection sample's time value?
     
  14. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    So you want the time in spline space of a projected point? This is indeed a good question.

    You could duplicate the Spline.GetProjectionSample() method and "out" the curve on which the sample is found.

    But I would choose another solution : adding the curve in each spline sample. It's only a reference and it won't be a big deal for perfs.

    This will require modification in SplineMesh code, though. In CurveSample, add a field and the initializer in the constructor like this :
    Code (CSharp):
    1.     public readonly CubicBezierCurve curve;
    2.     public CurveSample(Vector3 location, Vector3 tangent, Vector3 up, Vector2 scale, float roll, float distanceInCurve, float timeInCurve, CubicBezierCurve curve) {
    3.         this.location = location;
    4.         this.tangent = tangent;
    5.         this.up = up;
    6.         this.roll = roll;
    7.         this.scale = scale;
    8.         this.distanceInCurve = distanceInCurve;
    9.         this.timeInCurve = timeInCurve;
    10.         this.curve = curve;
    11.         rotation = Quaternion.identity;
    12.     }
    Then in CubicBezierCurve, where the only call the CurveSample constructor occurs, add the curve reference like this:
    Code (CSharp):
    1. private CurveSample CreateSample(float distance, float time) {
    2.     return new CurveSample(
    3.         GetLocation(time),
    4.         GetTangent(time),
    5.         GetUp(time),
    6.         GetScale(time),
    7.         GetRoll(time),
    8.         distance,
    9.         time,
    10.         this);
    11. }
    I'm pushing the code to SplineMesh github repository, because I beleive the curve reference could help in more situations like yours.

    Then, you just have to loop through the spline's curve list until you meet sample's curve, and doing some little math like this (pseudo-code):
    Code (CSharp):
    1. float cumulatedTime = 0;
    2. foreach(var curve in curves){
    3.     if(curve != sample.curve){
    4.         cumulatedTime ++;
    5.     } else {
    6.         cumulatedTime += curve.timeInCurve;
    7.         break;
    8.     }
    9. }
    10. var result = cumulatedTime / spline.curves.Count;
    Oh, and @Kalcen and @Yurei-Okami if you like SplineMesh, please show me some love by writing a short review on the asset store !
     
  15. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Hi,
    thx for creating this asset. Looking forward to use it. Is mixing the Contortionist example with the Interval example possible (RepeatOnSplineSpace)? I want to move multiple tiles along the spline and when one reaches the end of the spline it should restart (seamlessly connected to its successor, now being its predecessor).
     
  16. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    There are no example currently with a mesh cut in the middle, because the scale of the mesh along the spline is computed by finding the vertices with minimum and maximum X coordinate.

    Cutting a mesh should not be a problem but you will have to modify the MeshBender code a little I think.
     
  17. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Wow, very quick reply.
    What I am interested in is replicating this effect:
    https://www.artstation.com/artwork/BmN5G6
    Maybe there's a better way to do this with your asset. Else I will take a look at the MeshBender as you suggested.
     
  18. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    You can simply hide the start and the end inside another object. If it's acceptable visually, then everything is more simple. You will only need to place as many meshes as it fits on the spline, starting from an offset that increase over time. When the offset is as large as a mesh, the you reset it to zero and so on.
     
  19. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    I started experimenting with a custom script that merges the offset over time behaviour of the contortionist example and the tiling example. Currently it looks like I am doing something wrong or my mesh is too dense - the tiled mesh updates quite slow. Parallel to this I started looking into using vertex shaders to move meshes along splines and found this one:
    https://github.com/leon196/CurveModifier
    This should speed things up significantly and I already got ideas how to manage multiple tiles moving along the same spline.
     
  20. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    I've animated this over-tesselated rope for testing purpose, at 120fps on an i5. A big number of vertex is indeed the most important performance hit in SplineMesh. And even if you can get a decent fps, SplineMesh is using only the CPU, and it will be ok only if the game in general does not already lack CPU.

    SplineMesh don't include a GPU solution, but it should not be a problem. You will need to give the curves' base samples to your shader with a compute buffer, and translate the MeshBender logic into HLSL code in vert method.

    Remeber that doing so will lead to the mesh not being bent on CPU side, so you won't be able to get a bent collider either.

     
  21. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Collider is not so important right now. I could probably live with a simplified collider cylinder (invisible) at some point later in development. Thx. :)
     
  22. Roritamashi

    Roritamashi

    Joined:
    Jan 27, 2018
    Posts:
    8
    i have a problem with this


    Assets\Scripts\SplineMesh\Scripts\Bezier\CurveSample.cs(84,24): error CS7036: There is no argument given that corresponds to the required formal parameter 'curve' of 'CurveSample.CurveSample(Vector3, Vector3, Vector3, Vector2, float, float, float, CubicBezierCurve)'
     
  23. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Fixed on the github repository. Sorry for the inconvenience.
     
    Roritamashi likes this.
  24. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Posts:
    102
    Hi There,

    Thanks for this awesome free! asset.
    I'm looking to do the following:

    I would like to control the mesh that is generated along the spline to only cover a certain percentage of the spline and be able to animate this percentage.

    This would result in a road that can be built along the spline over time.
    Ideally the UV map would also "follow" the percentage.
    Think of a toilet paper roll where you would pull the paper out of the roll.

    Has anyone made something similar on top of this? Otherwise i would start having a go at it. probably starting from SplineExtrusion.

    Thoughts and hints appreciated.
    Best regards,
    Tom
     
  25. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    The growing root example seems to be exactly what you are looking for. Have you already found it in the showcase scene?
     
  26. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Posts:
    102
    I did and you're right off course.. actually "the contortionist " playing with scale and rate also will do what i'm after. perfect! thanks for that!
     
    methusalah999 likes this.
  27. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Hi,

    Great asset. thank you for that.

    We have a small issue, we are generating a mesh in runtime that goes up and down depending the action made by the player. the issue is, that the whole mesh is clipping at each update. Do you heard about this issue?

    I'm sorry I didn't notice this thread so I posted the question in the review. You should add the thread link in the documentation if possible.

    Thank you so much for your support
     
  28. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Indeed, i will add a link to this thread in the product description.

    Abbott you issue, can you please post a video or screenshots to show the issue? I'm not sure to understand what's happening.

    Also, can you edit your review so we don't leave an unanswered question on it? Thanks in advance.
     
  29. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    sure thing, I will search on how edit the review.

    please find in the link below a screen record of the issue
    https://drive.google.com/open?id=1jtO7o5iFk46HB8BRu6UD8SXUDKnLz_LZ

    FYI, we used the example bridges to build this prototype
     
    Last edited: Apr 30, 2020
  30. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Posts:
    102
    I'm trying to optimise GC creation and speed when doing computes all the time.
    working for mobile VR (Quest) and CPU is currently the bottleneck when meshes get heavy and node counts are increased.

    CurveSample.GetBent() now creates no garbage anymore but still accounts for +-15% of CPU time.
    (reusing and caching objects instead of creation new ones each frame)

    CubicBezierCurve.GetSampleAtDistance() would benefit the most from optimizing both from GC and performance hit pov.

    MeshUtility.Update accounts for the other half of GC but CPU time is limited.

    Capture.JPG

    Any optimization wizards willing to help on those?

    Tom
     
  31. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    The mesh is not drawn
    The mesh seems not to be drawn at some frames. Are you using a custom shader?

    My best guess is that the spline or curves are collapsed in some situation, like a scale set to zero, or all spline nodes set to the same coordinates. Is the mesh double-faced? If not, it could be the mesh being back faced for some reason.

    It seems to happen synchronously with changes in the direction of the camera. Can you tell me more about the construction and update of the spline?

    Also note that the bending of the mesh occurs in update method. The spline and curves, however, are changed immediately. If you change them during the lateUpdate, or after the mesh bender update, you may notice an offset of one frame.
     
  32. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    GetSampleAtDistance creates a new sample by lerping the two closests. So you will have a new sample for each vertex of your mesh.

    Fact is, the mesh is generally layered and you will often find yourself asking for samples at the same distance.

    It may be useful to cache samples and reuse them for the same input distance (+-e an epsilon for float precision).

    Mesh update is more of a brutal array change. You can try and recycle arrays, instead of reallocate them using loops. This may help GC but will also be more intense for the CPU.
     
  33. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    FYI we used the example Bri
    THank you or you quick reply. I will share your answer with my developers and get back to you very soon
     
  34. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Posts:
    102
    MeshBender.FillOnce has such a sampleCache but it's cleared everytime?
    sampleCache will only work in that function if useSpline is true.
    Changed it so that cache is being used for both conditions with an epsilon that makes sense for my project.
    Shows a nice improvement in unity profiler inside the IDE but on quest it still feels the same.
    Need to fix the fact that i can't profile on device anymore.
     
  35. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Hi Again,

    after sharing your feedback to my dev, this is our response :
    The mesh seems not to be drawn at some frames. Are you using a custom shader?
    => No Custom Shader

    My best guess is that the spline or curves are collapsed in some situation, like a scale set to zero, or all spline nodes set to the same coordinates. Is the mesh double-faced? If not, it could be the mesh being back faced for some reason.
    => we are using the same mesh that bridge example So yes it's double faced

    It seems to happen synchronously with changes in the direction of the camera. Can you tell me more about the construction and update of the spline?
    => We are using Mesh extruder to generate new nodes. But the mesh extruder is clipping at each new node generated (even on the examples using mesh extruder, it's clipping)

    Also note that the bending of the mesh occurs in update method. The spline and curves, however, are changed immediately. If you change them during the lateUpdate, or after the mesh bender update, you may notice an offset of one frame.

    So to explain more what we are doing, we are generating a kind of road and when the player swipes up, the road goes up and when he swipes down, the road goes down. to do that we took the bridge example and we generate nodes when road is change direction (up or Down). Maybe mesh extruder isn't the right way of doing things ?

    could you please advise us ?

    Thank you for your time
     
  36. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    I see. Extrusions are created at frame 'n' and the extrusion update occurs ont the frame 'n+1'. This is invisible with the SplineMeshTiling because the objects are pooled and recycled (so they remain visible in the meantime), which is not the case for SplineExtrusion.

    The fastest fix will be to update the extruded segments on the LateUpdate method. Please go in ExtrusionSegment.cs, line 130, and change the Update method for a LateUpdate
    private void LateUpdate() {
    . This way, the extrusion will be updated immediatly after the node addition, in a single frame.

    I've ran a few tests with extrusion being updated in the LateUpdate and it seems to work well. But you still may find regression bugs. If so, a more elegant and backward compatible solution would be to implement a game object pooling in SplineExtrusion, as it is done in SplineMeshTiling.

    That being said, as stated in the code comment, spline extrusion is mainly used for prototyping. It's slower than a plain old mesh being bent by the MeshBender class, as done in the SplineMeshtiling.

    Also, you will encounter a performance issue if you don't clean the previously generated road on the fly. Adding a node causes the whole spline to regenerate and will become slower and slower the more nodes you have.
     
  37. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Thank you very much for your support and help. Using mesh bender was enough to resolve our issue. We note your advice about performance and we are deleting old nodes to enhance it.
     
    methusalah999 likes this.
  38. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Glad to hear it. And if you like SplineMesh, please write a review on the store, it's gold to me.

    Have fun bending things !
     
  39. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Posts:
    102
    Trying to get the "timeOnSpline" from a CurveSample.

    I'm using spline.GetProjectionSample to get the nearest sample from a Vector3 near the spline.
    Then want to use meshBender.SetInterval(spline, timeOnSplineValueImLookingFor)
    to draw the mesh up to that point.. but i'm stuck at finding the percentage of where that CurveSample is on the whole of the Spline.

    Thanks for any help!
     
  40. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    I've added this feature recently. You can find it on the github repository.

    The idea was to include the curve object into the sample, so you can find the time or distance on the spline by iterating through the curves
     
  41. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Posts:
    102
    found it.. works!
    for future reference:
    Code (CSharp):
    1.  
    2.         CurveSample c = spline.GetProjectionSample(lookAt.localPosition);
    3.  
    4.         float totalLength = 0;
    5.         foreach(CubicBezierCurve cb in spline.curves)
    6.         {
    7.             if (cb == c.curve)
    8.             {
    9.                 totalLength += c.distanceInCurve;
    10.                 totalLength = totalLength / spline.Length;
    11.                 break;
    12.             }
    13.             totalLength += cb.Length;
    14.         }
    15.  
    16.  
    EDIT: mmm, neither distanceInCurve or timeInCurve is exactly correct it seams.. for now i've taken the biggest value of the 2 (Math.max) but something weird is going on there.

    EDIT 2: fixed the code, thanks again for the insights Methusalah!
     
    Last edited: May 4, 2020
  42. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Let me clarify.

    Either you work in distance, or you work in time. These two data are not representing the same value, as time will go faster or slower, depending on the curvature along the curve. So:
    - to work with distances, you cumulate the curves' lengths, add the sample distance, then divide by the spline length.
    - to work with time, you cumulate 1 for each curve, add the sample time, then divide by the number of curves in the spline.

    Hope it's clearer.
     
    Tom-Goethals likes this.
  43. vincewins

    vincewins

    Joined:
    Dec 19, 2016
    Posts:
    21
    I started writing an editor extension for that purpose, but I could not get the job done.
    I guess I will have to dig deeper and learn more about vertices and tris..

    If someone wants to take matters into own hands, here is what I came up with so far: https://pastebin.com/ZTP6YLR1
     
    methusalah999 likes this.
  44. vincewins

    vincewins

    Joined:
    Dec 19, 2016
    Posts:
    21
    Another thing I can contribute is a small change to SplineEditor.cs at around line 82:

    Code (CSharp):
    1.             // disable game object transform gyzmo
    2.             // if the spline script is active
    3.             if (Selection.activeGameObject == spline.gameObject) {
    4.                 if (!spline.enabled) {
    5.                     Tools.current = Tool.Move;
    6.                 } else {
    7.                     Tools.current = Tool.None;
    8.                     if (selection == null && spline.nodes.Count > 0)
    9.                         selection = spline.nodes[0];
    10.                 }
    11.             }
    12.             // draw a bezier curve for each curve in the spline
    13.             foreach (CubicBezierCurve curve in spline.GetCurves()) {
    14.                 Handles.DrawBezier(spline.transform.TransformPoint(curve.n1.Position),
    15.                     spline.transform.TransformPoint(curve.n2.Position),
    16.                     spline.transform.TransformPoint(curve.n1.Direction),
    17.                     spline.transform.TransformPoint(curve.GetInverseDirection()),
    18.                     CURVE_COLOR,
    19.                     null,
    20.                     3);
    21.             }
    22.             if (!spline.enabled)
    23.                 return;
    24.  
    This makes the spline gameObject movable again, if the spline script is deactivated.
     
  45. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    Integrated, thanks !
     
    vincewins likes this.
  46. Morganicism

    Morganicism

    Joined:
    Oct 6, 2015
    Posts:
    2
    Hello. I'm looking forward to trying this tool, but I'm running into an issue that's stopping me from doing much. I can select nodes and move them, but I can't add any new ones to a spline. The inspector says that no spline is selected, so it won't let me add a new node. Am I doing something wrong? I'm using the HD render pipeline, maybe that's causing some problems? Thanks.
    upload_2020-5-7_15-53-25.png
     
  47. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    This is a former known bug that is supposed to be fixed since SplineMesh 1.3 I think. The workaround was to ensure that only one inspector windows was open at a time.

    Please check that you have only one inspector window, and if possible, install the last version of SplineMesh. If the problem remains, please tell me.
     
  48. Morganicism

    Morganicism

    Joined:
    Oct 6, 2015
    Posts:
    2
    Thanks for your help, that may have been the issue. I was using version 1.3.2. Seems like it's working now after removing the extra inspector tab I had. After restarting it still works when I have multiple inspectors open, so I'd say it's all good.
     
    methusalah999 likes this.
  49. fullerfusion

    fullerfusion

    Joined:
    Dec 2, 2018
    Posts:
    22
    Hi, I love the asset and I have had it now for over 5 months. I have two questions for you.

    1) Custom Mesh. The asset came with a couple of prefabs, like the cylinder prefab that could be used for testing. Now, I want to have my own custom mesh for the Spline Mesh. If you want to put your own custom mesh on the spline that is repeatable along the spline. What are some requirements that are needed when creating a custom mesh? What should the export settings be? Size requirements, file format, etc?

    2) Repeating & Tiling Texture. The Spline Mesh allows the cylinder mesh to repeat but every time I try to apply a texture it does not repeat. I don't see an option that allows textures to repeat. Is there any way we can have repeatable/Titling texture for our meshes?
     
  50. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    643
    1) There is only one requirement for your mesh to bend : havind enough vertices along the bending axis for the curvature to be smooth. On an extruded object like the cylinder, you will end up with creating layers of vertices that are only used to bend the mesh. On meshes with high tesselation like a human body, it may not be necessary to add any more vertex, depending on the smoothness you need.

    2) If we are talking about a mesh, UV are preserved. So if you see stretched texture, it's most likely that you have a stretched mesh. To tile the mesh many times along the spline you can either:
    - use repeat mode in spline space. The scale of the mesh along the spline axis will determine the length of the mesh to repeat.
    - use stretch mode, but in curve space. Each mesh will scale along the spline axis to fill the space between two spline nodes.

    If we are not talking about a mesh, but a 2D shape extruded with SplineExtrusion component, then you just have to change the U scale in the SplineExtrusion inspector.
     
    fullerfusion likes this.