Spline Mesher - Mesh Deforming - Fences, pipes, path, roads and more!

Asset Store | Documentation

2 Likes

Asset is now live! A 50% launch discount will run until April 9th.

This thread may be used for support, report issues and suggest improvements :slight_smile:

1 Like

Hi, Iā€™m testing Spline Mesher and so far its pretty good and it looks like it will work well for the road system Iā€™m creating for my game. Its a minor issue but I did notice at one point the side mesh separated out from the road mesh. Not sure how that happened but I couldnā€™t see a way to realign them automatically. If there is a way they can be realigned please let me know. Thanks Alexi

does this work on unity 2021?

Can the Spline be changed at Runtime or only in Editor?

Would you mind sharing a screenshot or two? Iā€™m not sure what you mean by ā€œside meshā€, that being a mesh offset to the left/right of the spline?

Not officially, itā€™s not a version Iā€™m developing or testing for. But Iā€™ve imported it into a 2021 project and thereā€™s no compile errors, and all the functionality seems to work as it should!

Splines arenā€™t officially supported in 2021, so you canā€™t install the package. Itā€™s possible to do this manually in the Package Manager by choosing ā€œAdd package by nameā€ under the ā€œ+ā€ icon:
9730558--1391389--upload_2024-3-27_10-32-12.png

All the functionality sits in runtime code, so thatā€™s certainly possible. If you were to programmatically alter a spline, one thatā€™s also assigned to a (or more) Spline Mesher component, the mesh updates as well.

1 Like

Is it suitable for ancient city walls? For example, the Great Wall of China

I donā€™t see why not, a mesh is a mesh. Though youā€™d probably want to break it up into segments, rather than creating single a 21.000+ km spline :stuck_out_tongue:

1 Like

Hello, are there any videos going through setup and use for some basic use cases like the ones in the demo scene?

I love this!! Evaluating if weā€™ll be able to move off of our current Spline solution onto this in Unity 2022. It has most of what I need (I LOVE the ability for it to intelligently cast down and mold itself to other collision!), with one exception: there are cases in our game where we need to know if our character is Overlapping a Spline.

Since you canā€™t just turn a mesh collider into a trigger without making it Convex, the way we accomplish this with our current tool is to use a variant of the mesher that actually spawns each individually deformed piece of the generated mesh as its own game object, with its own collider. Each of these, on its own, can be made a convex trigger collider, and they all report their collisions to their parent, which lets us know that the player is intersecting with the Spline.

Is there any way to accomplish this with the tool as it exists? If not, would an option to spawn each segment of the Spline as its own game object be possible? Iā€™m pretty sure this is our only barrier to adoption :smile:

Good point! Everything in the demo scene is indeed outlining a particular use case or feature, but I realize now that isnā€™t obvious.

What Iā€™ll do is add a piece of 3D text to each object with a short description to clarify.

Awesome, glad to hear it!

The ability to spawn a mesh in segments (individual Mesh Renderers) is something thatā€™s on the wishlist. Itā€™s particularly useful to divide up very large meshes (eg. a guard rail along a long road).

Though spawning actual objects along a spline can already be achieved using the ā€œSpline Instantiateā€ component. Hereā€™s an example of a cube prefab being repeated along the mesh:

9737125--1392616--upload_2024-3-29_10-4-30.png

You can access this component by importing the Samples from the Spline package :slight_smile:
9737125--1392613--upload_2024-3-29_10-3-27.png

If this asset proved to be beneficial please do consider leaving a review, this in an invaluable way to support future development and helps make complementary updates possible! :slight_smile:

Iā€™ve continued work on integrating Spline Mesher - things have gone reasonably well, but Iā€™ve run into some more QOL challenges or actual blockers:

  1. Iā€™m encountering a rather frustrating issue with a Water Spline setup Iā€™ve created where, once I turn it into a Prefab (so that I can make waterways throughout my levels), if I draw a spline and then run the game, then exit the game, and then ever touch the Spline again, the entire mesh vanishes and I get hit with constant
[Physics.PhysX] cleaning the mesh failed
0x000001b3f70f9193 (Mono JIT Code) sc.modeling.splines.runtime.SplineMesher:CreateCollider () (at D:/Development/Unity/ProjectName/Assets/SplineMesher/Runtime/SplineMesher.cs:234)
0x000001b3f70f4613 (Mono JIT Code) sc.modeling.splines.runtime.SplineMesher:Rebuild () (at D:/Development/Unity/ProjectName/Assets/SplineMesher/Runtime/SplineMesher.cs:188)

The entire thing permanently locks up and I become unable to do anything with it until I destroy it and place a new one. Performing identical steps with an un-prefabā€™d version of the same object results in no issue, as far as I can tell, but Iā€™d very much like to use Prefabs. Iā€™ve been unable to lock down an exact repro for this (it always happens to the actual asset Iā€™ve made, but attempts to start from scratch and to narrow down what precisely is causing the issue is not yielding results. Maybe itā€™s something to do with the precise models Iā€™m using? Iā€™ve attached them.)

  1. Because I use multiple SplineMeshers that all reference the same base Spline, the Scaling feature becomes borderline unusable - since scale data is on a per-SplineMesher basis, and multi-selecting each SplineMesher and trying to use the Scale tool doesnā€™t work the way youā€™d expect, and there doesnā€™t seem to be a way to copy/paste scale data from SplineMesher to SplineMesher, you end up needing to manually do your best to make all of the different meshes line up with regards to Scale, which seems extremely difficult if not impossible. Certainly not a smooth workflow.

  2. And, the previously aforementioned inability to spawn submeshes - while the Spline Instantiate method is working at a baseline (thank you for the suggestion!) it also renders the idea of using the SplineMesherā€™s scale mesh functions moot, since you canā€™t scale the instances to match at various points along the spline.

Unfortunately Iā€™m not yet at a point where Iā€™m confident to integrate this tool - in spite of how nice it is to get started with. Any suggestions on the above?

9742114ā€“1393783ā€“Spline Cubes and Plane.zip (4.23 KB)

Valuable insights! :slight_smile:

The error youā€™re getting directs at the point where the collision-mesh is assigned to the Mesh Collider. Internally, it gets post-processed by the physics engine, but I take whatever it was receiving is invalid. Something happened that causes an invalid mesh to be created (nothing caught by existing safety checks). I can only reproduce the same error by manually setting all the scale data to (0,0,0), which causes a mesh to be created with all vertices bunched up on the same point, creating degenerate triangles. So I assume itā€™s related to that. Your meshes certainly look in order!

On that note: Iā€™ll be sure to implement a safety check in the Scale tool, to check for such invalid scale data, and reset them. Scale data is normally added automatically, to ensure that is exists for every spline. But I can imagine itā€™s possible to unintentionally circumvent this.

A useful debugging option is to reset the scale data through the context menu:
9742987--1393882--upload_2024-4-1_14-42-23.png

About the scale, I can see how it may be difficult to work with if youā€™re looking to make compound geometry. Adding support for multi-selection editing to the tool is rather straightforward fortunately, yet definitely something that hadnā€™t occurred to me.

Thereā€™s a simple auxiliary component that can be made to copy the scale data from one component to another. See this script.

For the box colliders, example components are often useful, but specific functionality does require specific code. The easiest way I think is a post-processing script can go over all the collider objects and scale them using the scale data. Hereā€™s an example component that does this.

Splines are very extendible so I want to encourage people to create addons tailored to their specific needs. With use case reaching far and wide tools would blow in complexity trying to cater to them all. Iā€™ve extended the documentation with a ā€œScriptingā€ section, and linked a couple of example code snippets that hopefully prove useful.

Thank you for your feedback so far!

1 Like

Thank you so much for your reply! Your guidance was extremely helpful.

I was able to add some code that forwards the scale of one SplineMesher to all the rest, and it did the job nicely!

Your tip about Reset Scale helped me pin down the issue with my one prefab. I think in the process of turning it into a Prefab, some bad ScaleData had made its way into the Components. Everything worked fine upon first placement but upon entering and exiting play mode, that bad ScaleData ultimately broke something. I seem to have been able to re-Prefab the object with properly cleared ScaleData, and the issue has gone away.

Next up is getting the collider scaling working and I should be good to go! Happy to have given 5 stars already. :smile:

Pleased to say that Spline Mesher is proving to be a coveted tool on peopleā€™s belt! It shot straight up to the top 5 assets on the store.

Iā€™ve finished a sizeable update, based on feedback and more extensive testing, which will be available shortly.

The ā€œScriptingā€ section of the documentation now has a link to several helper/example scripts.

Two particularly useful components are the ā€œAttach Transform To Splineā€ and ā€œSpline Junctionā€ components. Which can be used to aid in road systems, or attaching a separate mesh to the start/end of a spline. This sort of functionality seems to be requested, but it is something I am hesitant to include or facilitate in this assetā€™s scope, as they revolve around creative use of the Splines API specifically, not mesh generation.

1.1.0

Added:

  • Demo scene, text description to each object explaining what is being achieved.
  • Inspector UI enhancements.
  • Option to regenerate the mesh on Start(), required when prefabbing procedural meshes.

Changed:

  • Component no longer targets a Mesh Filter reference directly, now an output GameObject may be specified (automatically upgrades).
  • Improved mesh generation performance by 120-300%.
  • C#, static rebuilding events are now regular ā€˜Actionā€™ delegates.
  • Scale tool now validates data points and resets them if a scale of 0 was found.
  • Scale tool now supports multi-selection editing.
  • A Spline Mesher component no longer requires 2 default scale data points. If no scale data is found, a default scale is assumed.

Fixed:

  • Issue with geometry not generating for multiple splines if it uses more than 1 material.
  • Vertex normals not being accurately rotated if the deformation scale was negative.
  • Vertices at the very start/end of the spline possibly being deformed.
  • Using a Box-shape collider with +1 subdivisions no longer shifts the collider when using the ā€œSpacingā€ parameter.
  • Mesh rotation not taking effect for a custom collider input mesh.

Example of the new inspector UI:

The 50% off release discount on the asset store runs out today! :slight_smile:

I want to use it with the Easy Build System to allow players to create roads, rivers, bridges, and city walls. Can the two be compatible?

Based on the videos, possibly. I think the first question youā€™d need answered is if it can create splines using its interaction system.

The game Farm Folks recently implemented something similar using Spline Mesher, so by all means it is possible :slight_smile:

Hey, first of all, thanks for providing the community with amazing assets! I find myself using more and more of them.
Iā€™m using this to spawn obstacles that match my terrain shape.

Is there a feature to have start/end meshes?
Imagine a bridge with start and end segments that provide ramps for the player to walk up or down the bridge.