Search Unity

[Published] Spline plus- Spline mesh deform

Discussion in 'Assets and Asset Store' started by elseforty, May 21, 2018.

  1. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    i understand what are you trying to achieve, i'll tell you how i did it for Node Speed and Node Scale
    and hope it helps you with your problem
    Node Scale and Node Speed are handled the same way, so we will take Node Speed as example
    what i'm doing is storing Node speed value in the node class


    instead of calculating the interpolated value of speed every frame , i'm calculating it during initial spline draw, or when spline shape is modified, then i'm caching the interpolated speed value in an array which has the length of branch vertices, in another word each vertex of the branch will have the equivalent speed value.
    this is done in the SplineCreationClass.cs CubicBezier( ) method

    i'm not using real time interpolation because it is slow, the part where you determin the two nodes where the follower is located between is kind of a complex calculation, specially if the branch has more than two nodes,


    when the initial spline drawing calculation is made, branches gets transformed into arrays of vertices, tangents, normals ,speed, scale and other arrays, nodes are not somehow part of the branch anymore when path following, all the arrays are the same length, they works together, no need for any precalculations

    you can use all this to add something similar that will help you get your problem resolved, it is not going to be simple but it is doable
     
  2. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    @villaman i'll see what i can do to improve UVs scaling, in the meantime have you tried material settings ,it can help with scaling alot
     
  3. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi @doukisan , why you would need spline with mesh capping feature for that , as far as i know unity sprite system offers that for free, all you have to do is provide an atlas with transparency
     
  4. doukisan

    doukisan

    Joined:
    Nov 26, 2015
    Posts:
    15
    I'm aware of the Unity Sprite Shape tool, if that's what you mean, and that's kind of what I'm looked for, except I want to do it in 3D... I was looking for a solution that make it possible to do it with 3D models
     
  5. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi,
    i'll be updating Spline Plus and Spline Mesh deform this week, here is the most important head lines in the new update
    - New smart efficient nodes adding logic
    - Nodes adding not working properly on branches with free nodes is now fixed
    - All source code is now under the namespace "ElseForty" to avoid Ambiguity "using ElseForty;"
    - All Scene view menu items actions can now be found in the inspector as many users have resquested that

    - Scene view popups now allow node selection change when open
    - Follower settings window throwing null ref exception when changing selection in scene hierarchy bug fixed
     
  6. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi @doukisan
    if that is what you want then here is a video of the spline mesh deform extrude with cap only to have a better look on what you will get,
    if you have other questions let me know,
     
  7. jcochran

    jcochran

    Joined:
    Oct 9, 2015
    Posts:
    8
    im looking at buying this asset. im making a 2.5d side scroller with branching paths. what i would like to do is be able to follow a path only a certain points on the map. lets say im in an open area of the map where i can freely roam around, but then i want to go up a mountain path around the mountain. the mountain path is the spline that i would follow. at a certain point along the path i need to be able to jump across a gap, so i would be leaving the initial spline, jumping over a gap, and landing on another spline. can spline+ do this? i need to be able quickly leave and follow splines.
     
  8. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi @jcochran
    you can do that but you need to do some extra coding to be able to have the effect you want ,
    you can see something similar to what are you trying to achieve in the demo video bellow starting at 1:10
    the character can move freely using keyboard but once it gets close to the empty game object IN "in yellow" it gets instantly snapped to the spline and become a spline follower
     
  9. jcochran

    jcochran

    Joined:
    Oct 9, 2015
    Posts:
    8
    is that code freely available?
     
  10. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    the scene in the demo video is already included in the package with the code but you still need to make your own version, if you are good with programming i'd say go for it
     
  11. mgrugl

    mgrugl

    Joined:
    Mar 1, 2017
    Posts:
    23
    Hi, I tried to build the City_Road demo scene to iOS and got the following build error:
    Assets\ElseForty\SplinePlus\Plugins\SPFile.cs(237,9): error CS0104: 'Object' is an ambiguous reference between 'UnityEngine.Object' and 'object'
    Any help fixing this would be appreciated. I am using Unity 2021.1.14f1 URP
     
  12. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi @mgrugl
    try changing the line 237 in SPFile.cs from
    Code (CSharp):
    1.       Object.Destroy(externelSPData.SplinePlus.gameObject);
    to this
    Code (CSharp):
    1.       UnityEngine.Object.Destroy(externelSPData.SplinePlus.gameObject);
    let me know if it works for you
    best regards,
     
  13. mgrugl

    mgrugl

    Joined:
    Mar 1, 2017
    Posts:
    23
    Thank you very much for your swift reply! This fixed the build error. Could this adjustment be part of a future update of Spline Plus?
     
  14. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Sure this fixe will be included in the next update
     
    Mark_01 likes this.
  15. C1B0

    C1B0

    Joined:
    Nov 23, 2018
    Posts:
    6
    In uity2021.2, after importing spline plus into a plain project, when I right-click on the scene view with the game object with spline plus attached selected, the context menu does not appear and I am in the move perspective mode. I cannot create a spline.
    Is this a known issue?
     
  16. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi C1B0
    Did you add spline plus through the menu tools=>Spline plus ? it should be done this way
     
  17. C1B0

    C1B0

    Joined:
    Nov 23, 2018
    Posts:
    6
    I added it using that procedure.
    I've attached a video that reproduces the process for you to watch.
    Sorry for the Japanese environment.
     
  18. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Thanx for the video, I’ll test it on a unity 2021.2 today and get back to you
     
  19. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    @C1B0 i've tested it, it works for me, i'm on a mac machine by the way,
    anyway when adding the first node ever the right click menu is disabled by default because the user is forced to nodes adding mode, just click in your scene view to add the first node, when it is added you can freely open up the right click menu after,
    let me know if this works for you,
     
  20. C1B0

    C1B0

    Joined:
    Nov 23, 2018
    Posts:
    6
    I tried that process but could not add the first node.
    I also tried the same thing with unity 2019/2020 and it seems to have the same problem with those versions.
    I'm using windows 11 environment, maybe there is a problem with the environment this editor runs in?
     
  21. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    i
    I don't really know about this, i haven't tested the package on Unity with windows 11 environment yet, this could potentionlly be the problem,
    do you have the ability to test the package on windows 10, just to be sure it is a windows 11 problem,
    at the moment, i'm travelling, unfortunately i don't have access to a windows machine.
     
  22. Gamoyo

    Gamoyo

    Joined:
    Nov 6, 2018
    Posts:
    4
    Hello elseforty, i just bought your asset spline mesh deform and it does not works for me. The editor window can't show the spline plus component and there are some nullreference in the console window. it appens with every demo scene i tried.see the screenshot. I tried the asset with Unity 2020 and 2019. i'm on windows 7. Thanks for your help.

    splinemeshdeform_bug.jpg
     
  23. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi @laurentfernandez
    i downloaded and tested the package from the asset store on a unity 2019 window 10 and mac big sur, it is working as expected, it seams like you have banner image that hasn't loaded,i can tell this from the error you are getting (line 81) SplinePlusEditor.cs
    can you check in your project folder if you already have these images as in the screenshot bellow, if not please reimport the package
    also do you have the ability to test the package on a windows 10 machin, there could be some incompatibility issues with windows 7 and the recent versions of unity since it is no longer supported


    let me know if this works for you
    Best regards
     
  24. Gamoyo

    Gamoyo

    Joined:
    Nov 6, 2018
    Posts:
    4
    Thanks for your quick answer, i have the pictures in the right folder. I tried to reimport it but it's the same. I don't have other pc with windows 10 to try it. splinemeshdeform_bug2.jpg
     
  25. Gamoyo

    Gamoyo

    Joined:
    Nov 6, 2018
    Posts:
    4
    i had this message when opening the project splinemeshdeforme_bug3.jpg
     
  26. Gamoyo

    Gamoyo

    Joined:
    Nov 6, 2018
    Posts:
    4
    it seems that SplinePlusEditor.FindAssetPath( does not find the files on my pc
    if i replace this :
    if (Banner == null) Banner = new GUIContent((Texture2D)EditorGUIUtility.Load(SplinePlusEditor.FindAssetPath("Banner.png") ));
    with the full path:
    if (Banner == null) Banner = new GUIContent((Texture2D)EditorGUIUtility.Load("Assets/ElseForty/Other/Media/Banner.png" ));
    it works
     
  27. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    @laurentfernandez yeah, seams like "System.IO.Directory.GetFiles()" found in "SplinePlusEditor.FindAssetPath("")" is not working, i guess it is not supported in windows 7, the only solution i can see is hardcore the url of the assets just like what you did above, in total you will have arround 17 assets url to hardcode
    look for the asset in your project window ,right click , copy path will help you get this done quickly
     
  28. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Hi @elseforty

    can your tool be use to create a road network and also fast build the heightmap to match the road as Easy Roads 3D does ?
     
  29. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    @Vagabond_ Hi, unfortunatly spline mesh deform does not offer that feature. what it can help with is desin the spline system for complex roads since it supports branching,
     
    Vagabond_ likes this.
  30. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    55
    Hi there,

    Please may I ask, how can I add an event in code (not via the inspector) to detect when a follower is on a branch, and, how can I then tell that follower which branch to take (based on my own logic, not keyboard or random) ?

    Thanks so much for your help and best wishes from Australia

    John
     
  31. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi @jh092
    I'm afraid there is no API for this use case, you will need to find your way by checking the source code, to stear you toward the right direction, events are tied to follower object,you can access the events list by doing this
    MyFollower.Events

    it is a list of SplinePlusEvent object and this is its representation
    Code (CSharp):
    1.     public class SplinePlusEvent
    2.     {
    3.         public string EventName = "Your event name here";
    4.         public UnityEvent CustomEvent = new UnityEvent();
    5.         public List<EventBranch> EventBranches = new List<EventBranch>();
    6.         public bool Show_Event = true;
    7.         public Event_Type Event_Type = Event_Type.Branch;
    8.         public KeyCode KeyCode = KeyCode.Space;
    9.     }
    i think this can help you to add events in code,
    i hope i have helped a little bit
    let me know in case you have other questions

    Best regards,
     
  32. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    concerning the second question i think you are looking for this method if i'm not mistaken

            SplinePlusAPI.Follower_Set_Branch(Follower follower, int branchKey)
     
  33. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Hey,

    Just about to get the new bundle, do we we need Spline + to be able to use Spline Mesh Deformer?

    I am pretty sure this is the case, but would just like clarification.
    Much thanks
     
  34. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi,
    You don't need Spline Plus, it is already included in spline mesh deform,
    Best regards
     
    nathanjams likes this.
  35. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Wow, that is awesome news!
    Thank you!
     
  36. michaelcgossage

    michaelcgossage

    Joined:
    Mar 13, 2019
    Posts:
    1
    Hey,

    I am having trouble loading .sp files at run time. Seems to work up until the mesh deformer tries to load in meshes. Is there a best practice for loading the splines and applying the mesh deform at runtime?

    I am calling:
    Code (CSharp):
    1. SPFile.ReadSplinePlusFile(pathTo.SPfile, alreadyCreatedSPData);
    This is the error in the console:
    KeyNotFoundException: The given key '0' was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <612a2c65aaf843d698f8d38b2ad7654a>:0)
    ElseForty.DeformedMesh.DrawMesh_Branches () (at Assets/ElseForty/SplineMeshDeform/Plugins/DeformedMesh.cs:244)

    I have managed to get a spline to partially load by pre-creating the deform mesh components and a short branch using the Api commands. The branch spline is then overwritten by the load function but I don't think this will scale well and it looks like it doesn't link the final node when drawing the mesh.

    Sorry if this has been answered already.
    Any help would be greatly appreciated!
     
  37. Geelfan

    Geelfan

    Joined:
    Oct 29, 2020
    Posts:
    2
    Hallo elseforty,
    I have problems with "Spline Mesh Deform v.4.03" (win 7 - Unity 2021.3.11)
    1. Navigation in Scene - View is not not working as expected.No RightMouse moves possible.
    No more object selection is possible.
    ( "the plugin is "breaking" my editor view. After doing some Spline Plus related things, I just have the hand cursor and can't click anything, also not right-click anything ".)
    2.Is it possible to deactivate the Popup Menue when doing Right Mouse Click
    3.The spline Gizmo is vanishing from Scene-view when entering Play-Mode.
    4.The Manual says : "Click on the node in your scene view to select a node."
    but in my case it is "Double-Click" (essential and important to know)?
    5.Is it possible to Generally adjust the Settings or do I always again have to do that for every new SplinePlusGameObj?

    I can`t continue exploring this interesting Asset and... any help would be greatly appreciated!
    Greetings
     
  38. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Similar issues to @Geelfan - the scene view navigation works initially after opening Unity but stops once I start playing with the Spline+ in the scene

    And in the Keyboard_Navigation scene I get this error:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. ElseForty.SPData.OnBeforeSerialize () (at Assets/ElseForty/SplinePlus/Plugins/SPData.cs:53)
    In Unity 2021.3.12 URP and Spline Mesh Deform 4.03
     
  39. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    @elseforty

    Is this asset still being supported? I see the last update is from over a year ago. I can't really use the asset atm because of the issues listed above, mainly loosing control of navigation in the scene view.

    Reading the comments above, have you confirmed that this works on Windows 11?
     
    Last edited: Nov 3, 2022
  40. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    @nathanjams @Geelfan Sorry for the late relpy , i was away for few days,
    @Geelfan i would love to help resolve these issues , can you record me a video so i can have a better look , i can't seem to replicate this on my windows 10 or mac os environement, i think this is OS related issue since you're using windows 7
    @nathanjams i have recieved simlar complains about incompatibilty issues with windows 11 and spline mesh deform, i have only tested the package on windows 10 and mac os environments , i'll try to have access to a windows 11machine to have a look at this issue by monday
     
    nathanjams likes this.
  41. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi michael,
    i haven't had the chance to test that feature on runtime, so i can't really tell what is going on, i think the compiler is complaining about a missing branch with key 0,
    can you share with a simplied version of the project so i can have a better judgment,

    Sorry for the late relpy again
     
    Last edited: Nov 6, 2022
  42. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    There is no rush as long as you are going to address it. Much appreciated.
     
  43. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi Nathan,
    i got the chance today to check spline mesh deform on a windows 11 machine and it seams like everything is working as normal, no exceptions, the unity version i used is 2021.3.2f1 LTS and windows 11,
    can you share with me your environment details and the errors your getting
    thanx
     
  44. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Hello,

    Thanks for looking into this so quickly!

    In the Keyboard-Navigation scene there is a path error when you press play:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. ElseForty.SPData.OnBeforeSerialize () (at Assets/ElseForty/SplinePlus/Plugins/SPData.cs:53)
    And how do you released the mouse so you can use the Unity navigation tools? I couldn't see anything about that in the docs.

    I'm using Unity 2021.3.12 and the latest Win 11
     
  45. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    Hi Nathan,
    to get back to the selection mode just press escape in your keyboard,
    concerning the exception, it is not fatal, it happens only once when you press play, sometimes it does not appear at all, i think Unity serializer is causing this,
    to get rid of it completely just replace the OnBeforeSerialize() in the SPData.cs with code bellow
    Code (CSharp):
    1.  
    2. public void OnBeforeSerialize()
    3.         {
    4.             if(Keys == null) Keys = new List<int>();
    5.             if(Values == null) Values = new List<Branch>();
    6.             Keys.Clear();
    7.             Values.Clear();
    8.             if (DictBranches != null)
    9.             {
    10.                 foreach (var branch in DictBranches)
    11.                 {
    12.                     Keys.Add(branch.Key);
    13.                     Values.Add(branch.Value);
    14.                 }
    15.             }
    16.         }
    let me know if this works for you
    thanx
     
  46. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Hi,

    Ok, yes, the SPData is now fixed but the Esc key on my keyboard is not returning mouse control. Doesn't matter what scene i try, as soon as I click on the Spline component I can not get back my mouse control to default Unity Navigation.

    Not sure if it makes a difference but I am on an MSI Laptop. The Esc key works in all other scenarios with other assets and computer functions.

    Thanks for looking into this. Let me know if there is anything else I can provide
     
  47. Geelfan

    Geelfan

    Joined:
    Oct 29, 2020
    Posts:
    2
    Hi elseforty,
    as "nathanjams" wrote...I also still have the Problem : "the Esc key on my keyboard is not returning mouse control",
    to have normal Navigation Control and using the "Right Mouse-Navigation Options" in the Editor-View.
    The "Hand-Tool" is not being released.
    The "Eye-Tool" doesn`t work anymore.
    And I cannot select any Game-Object as long the "SplinePlusObj" is selected in the Hierarchy.
    (tested in BuiltIn and URP 2021.3.11 in an empty Scene)
    I don`t assume it`s an OS related issue in windows 7, because all my other hundreds of Assets don`behave that way.

    Therefor again my Questions (a Yes or No would be ok for me):
    1.Is it possible to deactivate the Popup Menue (for Node and Branch - Possibilities) when doing Right Mouse Click ?
    2.Is it possible to Generally adjust the "Settings"-Parameter or do I have to do that for every new SplinePlusGameObj?

    Thank you very much for your help and answers.
    Geelfan
     
  48. elseforty

    elseforty

    Joined:
    Apr 3, 2018
    Posts:
    290
    @nathanjams @Geelfan
    can you please confirm to me that when you're on the branch adding mode the spline plus inspector looks like this


    if you click esc it changes to this

    i hope you understand it is hard to debug if i can't replicate the issue on my end but we will certainly find a solution for this issue, no worries

    @Geelfan
    concerning your questions
    1- it is possible to do that, but you need to change the code, it is simple, look for this c# file named SceneViewDisplay.cs , then comment line 14 "SceneViewUI(sPData, selectedNode);"
    and that's it, this will disable the mouse right click menu if it is causing you troubles
    2- unfortunatly the settings are spline gameobject tied, not a global scope thing that gets applied to all spline plus game objects in your project,
     
  49. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Hey

    Maybe its just me. sometimes it works and sometimes it doesn't .

    Once I've played with it more I'll post back when I can describe it better.

    Thanks for your time
     
    Last edited: Nov 9, 2022
  50. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Hmm

    Yeah, it keeps locking on me. The Esc key doesn't do anything.

    if i first open the project and then click in the scene I can navigate fine. Click on the Spline object I get the Spline editor tools. Click on a branch (child) and I can navigate freely again. However, if I click back on the Spline object the navigation tools gets stuck on the Spline tool. I can not get back to Unity's tools. Esc doesn't work, clicking on another object doesn't work.



    Pressing the Esc button does not make a difference at all.

    Thanks again
     
    elseforty likes this.