Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to generate mesh on spline at runtime?
#1
I've been watching some of your tutorials on generating and extruding a mesh on top of an existing spline in the editor using Curvy Generator (maybe I missed one), but I generate my spline at runtime and would need to add a mesh and slowly extrude it from start to end of the spline at runtime by script.  I did find "CreateMesh()" in the API page, but not really sure how I would use it to add my mesh and extrude it.

Any help would be greatly appreciated  Blush
Reply
#2
Hi

Setup your generator in edit mode.

At runtime, assign the input spline after you create it: InputSplinePath.Path:
https://api.curvyeditor.com/860/FluffyUnderware.Curvy.Generator.Modules.InputSplinePath.html?q=inputsplinepath#FluffyUnderware_Curvy_Generator_Modules_InputSplinePath_Path

Set the extrusion range at runtime: BuildShapeExtrusion.From and BuildShapeExtrusion.To:
https://api.curvyeditor.com/860/FluffyUnderware.Curvy.Generator.Modules.BuildShapeExtrusion.html?q=buildshapeextrusion#FluffyUnderware_Curvy_Generator_Modules_BuildShapeExtrusion_From

The list of a generator modules: CurvyGenerator.Modules:
https://api.curvyeditor.com/860/FluffyUnderware.Curvy.Generator.CurvyGenerator.html?q=CurvyGenerator#FluffyUnderware_Curvy_Generator_CurvyGenerator_Modules

I hope this helped
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Also script E51_InfiniteTrack, used in scene 51, might help you if needed.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#4
(07-06-2023, 10:33 AM)_Aka_ Wrote: Hi

Setup your generator in edit mode.

.....

Hi! Just wanted to let you know that I was able to accomplish it using your help Smile

Two questions, though.

Is there a function to have the "BuildShapeExtrusion.To" value follow the Spline controller object's relative position (0 - 1)? So this way, it would be as if the Object on the spline is creating a "trail" as it moves, then restarts on loop. 
(*** Edit:  I accomplished it by "tweening" a value from 0 - 1 and simply applying it to the SplineController.position and "BuildShapeExtrusion.To" at the same time. Although, it seems as though there is an automatic "EaseInOut" function applied to the SplineController, or is it something I'm doing unintentionally somewhere that I can't find? ***)

Also, I have to assign a specific Layer name to objects for my camera to see them, so I need to add the layer name to the extruded mesh, but it seems as the extruded mesh ("Create Mesh_5_Mesh000" under "Create Mesh" object on the Generator gameobject) resets the layer name to default whenever its extrusion value is changed. Is there a way to default it to my layer name without having to change it every update?

EDIT #2: Gosh darnit. I figured out the layer problem too haha. I'm so sorry! You made an option for choosing layer on the CreateMesh component. You thought of everything in this plugin. I love it! 
I still haven't figured out the "EaseInOut" issue of the Spline Controller though, as mentioned in my first edit.
Reply
#5
Hi
The To value is a relative distance.
The relative distance of a point is equal to : distance_of_the_point_from_the_spline_start / length_of_spline
In the case of a point defined by the position of a spline controller, the value would be:
yourSplineController.AbsolutePosition / yourSplineController.Spline.Length
I hope this helped
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
Maybe I don't understand what you mean, but I have a value that I'm "lerping" from 0 - 1 in 2 seconds for example. I apply that value to the .To value and to the Spline Controller position (both using the "relative" option). The Spline's "BuildShapeExtrusion.To" animates perfectly linearly, but the SplineController.Position Eases in and Out for some reason. Even when I manually move the position slider, I can see it slows down at the end.
Reply
#7
The solution is to use the absolute position in the controller, and instead of lerping between 0 and 1, you lerp between 0 and spline_length

The issue you encounter is because the relative position of the controller is not evenly distributed along the spline. This is explained here:
https://www.youtube.com/watch?v=rP0zuAEoVJw&list=PLatR0iPtXq-xxul-Ys-vQSLMaLXQnaU65&index=4
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#8
(07-18-2023, 10:59 AM)_Aka_ Wrote: The solution is to use the absolute position in the controller, and instead of lerping between 0 and 1, you lerp between 0 and spline_length

The issue you encounter is because the relative position of the controller is not evenly distributed along the spline. This is explained here:
https://www.youtube.com/watch?v=rP0zuAEoVJw&list=PLatR0iPtXq-xxul-Ys-vQSLMaLXQnaU65&index=4

Worked like a charm! 

Thanks again for your superb customer service!
Reply
#9
you are welcome
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 21 04-17-2024, 10:57 AM
Last Post: _Aka_
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_

Forum Jump: