Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

SplineMesh, the plugin to create curved content

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

  1. Object-Null

    Object-Null

    Joined:
    Feb 13, 2014
    Posts:
    74
    is this possible: every node to be attached to a game object. so that it is possible to animate the game objects and in that case also the spline itself
     
  2. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    289
    Hello, I use SplineMesh's Cubic Bezier curve in code, and use Unity's Handle.DrawBezier to debug the curve, but they're different.
    Blue dots are SplineMesh's bezier samples ( the actual path )
    the white curve which does not have dots is the desired path drawed by the Handle.DrawBezier,
    using SplineMesh's bezier curve's internal value.
    Code (CSharp):
    1.             Handles.DrawBezier(curve.n1.Position, curve.n2.Position, curve.n1.Direction, curve.n2.Direction, Color.white, null, 2);
    2.  
    How to make the actual path be like the desired path ?

     
  3. KilledByToaster

    KilledByToaster

    Joined:
    Aug 24, 2017
    Posts:
    7
    Hi, I'm trying to do the following from the example, but having issue calculating the up vector so that it auto detects a loop. do you have some example code I could look at that does this?
     
  4. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    I can't think of any way to detect a loop. The wrong up vector can be computed each time the spline goes up or down, because when it does there is no way to decide a better up than another (gimbal lock). That said, you can simply decide that your up at this moment is in the direction of the previous node (which is most likely for a track for example) and go with that.
     
  5. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    Sorry I didn't see you message. I suppose you have fixed it by the time, but here is my though just in case. The issue here comes from the parameter you give to DrawBezier.

    This method require two world positions and two tangent vectors, which are directions in local space. In SplineMesh though, the SplineNode.Direction is in world space, no in local space. So you need to pass
    node.Direction - node.Position
    as a local tangents.
     
  6. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    289
    Thank you! Can write curve in gameplay code is fun!
     
    methusalah999 likes this.
  7. tdjemai

    tdjemai

    Joined:
    Dec 15, 2016
    Posts:
    1
  8. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    My best guess is that this version of Unity raised the version of C# specifications, but I find it very strange that the event handling syntax is not backward compatible. Do you use Visual Studio? if so I suppose it will propose a rewrite. If not that will need to wait that I test this version.
     
  9. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,554
    Thankful for this free asset. I added undo to Spline and SplineExtrusion.

     
  10. KilledByToaster

    KilledByToaster

    Joined:
    Aug 24, 2017
    Posts:
    7
    Hi thanks for the reply, just seeing this now. What's the best way to detect if the spline goes up or down? Would I iterate through each curve? (an example would be super helpful if you don't mind)
     
  11. KilledByToaster

    KilledByToaster

    Joined:
    Aug 24, 2017
    Posts:
    7
    Code (CSharp):
    1. var node = spline.nodes[index];
    2.         var curve = spline.curves[index - 1];
    3.         float spacing = .1f;
    4.         bool isFlipped = false;
    5.         float prevZ = -2;
    6.         float prevX = -2;
    7.         bool isAimingUpOrDown = false;
    8.         for (float d = spacing; d < curve.Length; d += spacing)
    9.         {
    10.             var sample = curve.GetSampleAtDistance(d);
    11.  
    12.             float x = sample.tangent.x;
    13.             float y = sample.tangent.y;
    14.             float z = sample.tangent.z;
    15.             //Check if track is aiming up or down
    16.             if (Mathf.Abs(y) > .9f)
    17.             {
    18.                 isAimingUpOrDown = true;
    19.             }
    20.             // Set initial track direction
    21.             if (prevZ == -2)
    22.             {
    23.                 prevZ = Mathf.Sign(z);
    24.                 prevX = Mathf.Sign(x);
    25.             }
    26.             // Check if direction is aiming in oposite direction from start
    27.             if (isAimingUpOrDown)
    28.             {
    29.                 if (prevZ != Mathf.Sign(z))
    30.                 {
    31.                     isFlipped = true;
    32.                 }
    33.                 if (prevX != Mathf.Sign(x))
    34.                 {
    35.                     isFlipped = true;
    36.                 }
    37.             }
    38.         }
    39.         if (isFlipped)
    40.         {
    41.  
    42.             var prevNode = nodes[index - 1];
    43.             Vector3 up = (transform.position - prevNode.transform.position).normalized;
    44.             node.Up = up;
    45.         }
    46.         else
    47.         {
    48.             node.Up = Vector3.up;
    49.         }
    This is as far as I've been able to come along, but the result messes up when after the part that flipped
     
  12. KilledByToaster

    KilledByToaster

    Joined:
    Aug 24, 2017
    Posts:
    7
    upload_2022-8-26_15-43-31.png
    Also getting the following errors and the mesh sometimes becomes isn't able to generate depending on the location of the nodes. Any ideas?
     
  13. fullerfusion

    fullerfusion

    Joined:
    Dec 2, 2018
    Posts:
    23
    I really enjoyed this update you gave to the asset. Thank you for your contribution.
     
  14. Deleted User

    Deleted User

    Guest


    Really cool! Thanks a lot!!!
     
  15. fullerfusion

    fullerfusion

    Joined:
    Dec 2, 2018
    Posts:
    23
    I have a mesh model that I'm trying to tile, but it needs two materials. In the SplineMeshTiling.cs script, I can only assign 1 material to my mesh, but I want to add additional materials? How would modify the SplineMeshTiling script to support the ability to add multiple materials to a mesh?
     

    Attached Files:

  16. enurmatbekov

    enurmatbekov

    Joined:
    Aug 2, 2022
    Posts:
    3
    Can I feed it(through code) an array of points/vertices and have a 3d cylindric spline?
     
  17. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    This is an easy one. Just use a list of materials and feed the mesh renderer with the list instead of the single material here https://github.com/methusalah/Splin...ripts/MeshProcessing/SplineMeshTiling.cs#L122
     
  18. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    yes you can add/insert/remove/edit spline nodes via code at runtime
     
  19. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    You need to have two behaviors. One when the curve tangent is not vertical and another when it is vertical. Of course, the curve tangent is never perfectly vertical so you need to test it against the world up with a certain tolerance. Also, if the start and end nodes of your curve are not vertical, but verticality happens between them, you will need to check the samples generated by SplineMesh to check if verticality happen somewhere inside the curve and act accordingly.

    My advise is to have a code that avoid this situation and if verticality must happen, have a spline node at that place.

    Once you can correctly detect vertical parts of your spline, it is easier. You can now use the previous up vectors to find the correct up vector in the vertical part, just by being in the same general direction as the previous ones until you are not vertical again.
     
  20. skoteskote

    skoteskote

    Joined:
    Feb 15, 2017
    Posts:
    88
    Hi, thanks for a great asset - super useful! I am trying to solve a thing and posting here in case there is some simple solution that I've missed:

    I have a spline with a bunch of nodes, piped with a single mesh.
    The mesh is only created along a part of the spline, using
    SetInterval(spline, 0, y)
    .
    I need to find the closest point on the spine to another object (using GetProjectionSample) - but Only on the portion of the spline that has a mesh created on it, ie the part of the spline between 0 and y.

    I see two solutions to this:
    1. Create a new spline that is only the part between 0 and y on the old spline, and then use GetProjectionSample on it. This would be ideal, but the curvature of the spline cannot change in the process. I see there has been extensive discussion on this above, but don't know if it was ever solved?
    2. Create a new point at y along the spline, and then check if my closest point is past it. This feels less intuitive and will yield the wrong result in many cases.
     
  21. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    Just write your own GetProjectionSample method with the interval start and end as arguments, it should be no big deal.
     
  22. Predulus

    Predulus

    Joined:
    Feb 5, 2018
    Posts:
    90
    Thanks for the asset methusalah999. One problem though - toggling isLoop doesn't seem to be working for me ... it worked the first time, to create a loop, but now it's stuck being a loop no matter how many times I toggle it.

    I also tried hacking it myself, using OnValidate and GUI.changed etc, but still no joy.
     
    Last edited: Nov 24, 2022
  23. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    It may be broken, thank you for the report. Why would you need to toggle it on, then back off? It that an actual use case? or is it just broken, you report it but you don't need it to work?
     
  24. Predulus

    Predulus

    Joined:
    Feb 5, 2018
    Posts:
    90
    Hi Methusalah

    I think I toggled it on accidentally. Then I wanted to toggle it back off, but it would not update the looping status.

    Also, sometimes while in dev cycle, we change our minds about such things as whether this spline should loop, so it's an actual use-case.
     
  25. yonatanab1

    yonatanab1

    Joined:
    Sep 9, 2018
    Posts:
    56
    I don't understand, how can I find the position of the object that moves along a spline?
    using examplefontortalong if it matters.
     
  26. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    Generally, it's you who say what the position of the objet should be. In "contort along" example, the position is the rate (going from 0 to 1) multiplied by the spline.length.
     
  27. yonatanab1

    yonatanab1

    Joined:
    Sep 9, 2018
    Posts:
    56
    Thank you!
    I solved my issue by getting the position through the Spline component:
    _Spline.GetSampleAtDistance(length).location;

    this asset is awesome!
     
  28. KilledByToaster

    KilledByToaster

    Joined:
    Aug 24, 2017
    Posts:
    7
    Hi I'm having an issue where the mesh acts weird and deforms at certain angles, any ideas what might be happening?
     
  29. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    289
    Hello dev, I notice the set spline rotation at sample is not working as intent, so I draw debug up, tangent, forward to see what's going on.

    Code (CSharp):
    1.             //draw up & tangent & dir
    2.             for (float i = 0; i < 1; i+=0.033f) {
    3.                 var sample = spline.GetSample(i);
    4.                 Handles.color = Color.green;
    5.                 var pos = transform.TransformPoint(sample.location);
    6.                 Handles.DrawLine(pos,pos+sample.up.normalized * debugDirLength);
    7.                 Handles.color = Color.red;
    8.                 Handles.DrawLine(pos,pos+sample.tangent.normalized * debugDirLength);
    9.                 Handles.color = Color.blue;
    10.                 Handles.DrawLine(pos, pos + sample.Rotation*Vector3.forward.normalized * debugDirLength);
    11.             }
    upload_2023-1-31_15-38-23.png

    3 lines seem to all line up at one direction.

    This is the code I use to set characters position based on fixed distance.
    The distance is good, just look rotation is wierd.
    Code (CSharp):
    1.             float distance = 0;
    2.             for (int i = 0; i < segments.Count; i++) {
    3.                 var s = segments[i];
    4.                 if (s.transform == null) continue;
    5.  
    6.                 CurveSample sample = spline.GetSampleAtDistance(distance);
    7.                 s.transform.SetPositionAndRotation(
    8.                     transform.TransformPoint(sample.location),
    9.                     sample.Rotation);
    10.  
    11.                 distance += segments[i].length;
    12.                 if (distance > spline.Length) break;
    13.             }
    Hope to hear from you. Thank you!
     
    Last edited: Jan 31, 2023
  30. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    289
    This is the result after I make a handle to edit spline node Up
    upload_2023-1-31_15-58-40.png

    Debug is better, now we can see the up apart from direction, but rotation still wrong (because forward direction is wrong)
    As this debug shows, the animals are facing exact direction as the blue line, not the spline look direction.
     
  31. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    289
    Finally I can do this with some hack.
    Need another sample (next) and use direction from next to current as forward.

    upload_2023-1-31_16-46-23.png

    Code (CSharp):
    1.                 //check if we can move next, we can look at next point
    2.                 var nextDist = distance + m_averageDistance*0.5f;
    3.                 if (nextDist < spline.Length) {
    4.                     var nSample = spline.GetSampleAtDistance(nextDist);
    5.                     var dir = (transform.TransformPoint(nSample.location) - pos).normalized;
    6.                     look = s.transform.rotation = Quaternion.LookRotation(dir, sample.up);
    7.                 }
    8.  
    Still, wanna report the bug about we can't just use the sample.Rotation. Since this hacky approach cost us another sample to calculate.
    Unity 2022.2.4f1
     
    Last edited: Jan 31, 2023
  32. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    You can already show and change the up vector by checking the "show up vector" in the spline component.

    As for the Direction property of the nodes, it is indeed badly named and is in fact the "control point" in Bezier vocabulary. This point is in world space and the vector is therefore not an actual direction. The direction of the node is in fact Direction - Position, i.e. the vector from the node's position to the node's control point.

    It was a very bad design on my end and confused a lot of people. But it is now hard to change for backward compatibility reasons.
     
  33. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    289
    hi, I (currently) has no problem with node's direction, just sample.Rotation.
    turn out, what I do is posing animals which not are childs of the spline. And Rotation should be local rotation.
    My bad, I should remember all your field should be local.
    Fixed by converting it using the spline's rotation.
    Code (CSharp):
    1. targetTransform.rotation = transform.rotation* sample.Rotation;
    About your code name is confusing, I agree. Your position and rotation should be named with local prefix lol.
     
  34. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    289
    Animals are happily placed.
    The application for this is posing instead of spawning. The why I need them to be not directly under the spline is because I want to use it to pose things like skeleton, like the centipede afar.

    upload_2023-1-31_20-3-4.png
     
  35. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    has anyone been able to get seamless repeating to work with the track example script? I tried for a few hours but have no idea what Im doing. when I set it to repeat without curve space they both go the entire length of the spline, despite them behaving as expected with repeat and in curve space. I can tell that its because the standard SplineMeshTiling script uses the CreateMeshes method, while the track example just has a forloop, but I have no idea how to get around that without breaking something. someone must have figured this out already I just couldnt find it in the forum or the git page
     
  36. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    There is a confusion here between how the track is made.

    In SplineMesh there are two ways of bending a shape :
    - the MeshBender, used by the SplineMeshTiling, take an existing mesh, place it and bend it along an interval on the spline,
    - the SplineExtruder takes a 2D shape (not a mesh) and extrude it along an interval on the spline.

    The track example uses the extrusion so repeat does not make sense in this case. You specify the interval it must be extruded and the 2d shape will be extruded with as many layers as required.

    Repeat only make sens when using the MeshBender. You can set the mesh to be stretched along the full length of the spline, or repeated on each curve, or repeated with a certain length, etc. The SplineMeshTiling component allows you to configure this placement in the most common ways, but you may need to write your own script, like the tentacle or contortAlongSpline examples to set your own stretching, repeating interval.
     
  37. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    oh I didnt know the track code was extruding, thats odd because it had a field to put in a mesh. ultimately Im just trying to do what splinemeshtiling does except with the ability to apply a mesh to each node on the spline, this is how the 2dspriteshape package works and it's all I need for 3d, I just cant figure out how to get the spritemeshtiling script to take a mesh with each node like the exampletrack script can
     
  38. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    actually also wondering if it'd be possible to get prefabs into the mesh field of splinemeshtiling like in examplesower, along with being able to input a prefab each node like in exampletrack. I might pay a friend who's a much better programmer than me to look into it. I dont think I know enough to be able to get anywhere with this without wasting a ton of time.
     
  39. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    Bending a prefab is in fact bending all the mesh renderers that are contained inside that prefab. It's totally doable of course. You just need to iterate through the renderers and get their meshes. But you would also need to transform them depending on their position/rotation/scale in the prefab which may lead to a lot of complexity. My advice would be to make a prefab with multiple SplineMeshTilling or such simple scripts, bending along the same Spline.
     
  40. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    now Im just trying to get decals to work with it. so I need it to accept another mesh and material per node and no it cant be a separate object with its own tiling script because the decals have to sync correctly to the actual meshes they're placed on.

    I wrote a lot of complaining but deleted it. I just wish I knew that this asset wasnt able to do what I needed before trying to use it. my friend did get the node segments working, I fixed an issue with it where it wouldnt fill the gaps between nodes, the fix is janky but it works. and now I cant use the decals I designed my assets to use with decalmachine in blender. it just feels like constant hurdles with this. Again I would pay someone to fix it I'm just sick of wasting time in it when Im trying to create assets
     
  41. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    If you need to place decals along the mesh the same way you place your meshes, you can do that be taking a look at the ExampleSower. This script just place prefabs along the spline in the way you want. The road example in the showcase scene is a good example of an Extruder (for the road) and a Sower (for the lamps) using the same spline.

    I understand that you need the decals to be sowed in the same way the meshes to sync them. You will of course need your sower to use the same intervals as the extruder or tiler. Whether it is curve based, distance based or using any other type of interval, you just do the same computation on both scripts. You can also have a third script that control the intervals of the two other synchronously.

    As for the gaps between meshes, it usually comes from the mesh ends being incompatible, but it can be something else. Please show me a screenshot so I can point you in the right direction.
     
  42. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    upload_2023-2-23_16-47-42.png
    The gap problem is pretty much done, this is the new problem. I have no idea how I'd get sower to bend the meshes, and using my current script they arent synced. I could just get the bounding box to match the actual meshes bounding box, then they'd sync correctly if I were to assign the same position and rotation values from a script.
     
  43. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    Oh I though you are talking about actual decals, but I think it is a mesh with an alpha texture, going over the other mesh, is that it? If so, you don't need to sow objects of course.

    I don't know the use case and I lack informations. But if you start from the beginning, show the original meshes and explain the desired result I'm sure we can figure it out.
     
  44. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    upload_2023-2-23_17-7-39.png
    in high definition render pipeline, theres decal tech, decals are cool because they are designed to be applied over other textures and give them attributes like normal maps to fake depth while still overlaying over whatevers behind them. In blender as you can see in this image, theres a package called decal machine that can be used to create them. The workflow sees them exported to their own mesh with its own dedicated decal material, which has a dedicated shadergraph to get this effect to work.

    so Im trying to get the decal mesh to display at the same location as each repeated mesh in the spline, with its own decal material
     
  45. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    this idea didnt work. Weirdly changing the bounding box doesnt seem to affect their placement
     
  46. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    Ok I see.

    In this situation you will need to ensure that the two meshes are bend the same way along the same spline. In your previous screenshot I can see that you have made a custom script to bend a list of meshes. I think it would be simpler to have one Spline and two different SplineMeshTiling components. Does something prevent you from doing that?

    The two meshes should both have the same layering so they can be bent smoothly together. Then the two tiling component should have the same parameters. Depending on import/exports parameters, you may also face problems with the meshes scales or orientation that should be fixed on the Blender side (but I suppose you already checked that).

    In the previous screenshot, I can see that you use the tiler in the mode curve/repeat. In this mode, the tiler will place, on each curve of the spline, as much meshes as the curve fits. The length of the curve will be dictated by the scale of the mesh. There will have a gape at the end of each curve unless the length of the curve is exactly a multiple of the mesh length. I believe it is not what you want. This mode may be the cause for the gap we talked about earlier, and it may also cause the meshes to be offseted if the two meshes have different size/scale along the axis.

    I don't know the whole scheme but if you want your meshes to be placed repeatedly with a constant length (and not stretched to fill the interval exactly), then you might need to use spline/repeat mode. In this mode, the mesh will be placed repeatedly from the start of the spline to the end, with no gap between them, and without taking the curves and nodes into account whatsoever. In the mode, you will end up with a gap at the end of the spline unless the spline length is an exact multiple of the mesh length.

    Please tell me what you think about it. You can also paste your custom component code so I can help debugging it.
     
  47. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42


    the segment list is so I can do this, I can change up the mesh along the spline to create a lot of variety.
    I have the desired X field to show the desired x scale, the gap that appears is then closed, which is why the actual x scale is a little bigger than desired x. I find the gap in the meshbender script and then call a method back in the normal script to extend the scale and rebuild it, which is where the jank comes in, weirdly the only way I could get it to work is to have gotten it in a state where it needs to be toggled on and off a few times to reload it so it can do this. I have no idea but it works consistently.
    the code is a mess, especially where I threw in a bunch of error checking conditions, but here it is as well as the slightly changed mesh bender with a couple new lines finding the gap value and calling a method back in the main script
     

    Attached Files:

  48. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    As I understand your gapBetweenCurve code, it is computed once the mesh is repeated, then corrected, then the mesh must be repeated again with a scale correction, giving a new smaller gap, and the more often you do it, the less gap you have in the end. Hence the fact that you need to enable/disable the component multiple times.

    What you are trying to do here is having the mesh repeated AND stretched to fill this gap, which should not come from the scale but from the MeshBender itself. The algorithm is:
    - find the maximum number of meshes that fit inside the curve,
    - scale the meshes up so they occupy all the remaining space (the gap).

    I suggest that you do it in only once step, by creating a new FillRepeatStretch method in the MeshBender and adding this RepeatStretch mode in the SplineMeshTiling.

    You first find the maximum number of meshes that fit in the curve (which is already the case in FillRepeat)
    int repetitionCount = Mathf.FloorToInt(intervalLength / source.Length);

    Then you find the remaining gap (same as you, but positive)
    float gap = intervalLength / source.Length - repetitionCount;

    This will go from 0 to 1 and represent the percentage of the mesh that could fit in the remaining gap.
    Then you find the upscale each repetition should have so they fill all the space, by distributing the gap among the meshes.
    float scale = 1 + gap / (float)repetitionCount;


    Then later, when you look for the CurveSample, just upscale the distance in the curve
    float distance = (vert.position.x - source.MinX + offset) + scale;

    You also have to upscale the offset variable that is cumulated through repetitions
    offset += source.Length * scale;


    It will be a simpler code and will bend your mesh in the curve space right away without doing back and forth between the bender and the tiler, solving the gap issue exactly and preventing the meshes to be offseted differently.

    Now remember that the mesh length is "found" by the bender, by finding the vertices with the minimum and maximum coordinate along the X axis. If you want your decal mesh to be placed exactly above your plain mesh, you need to ensure that the meshes start and end at the same X coordinates so they have the exact same length.

    Hope it helps!

    In the end,
     
    ChrisRapczynski likes this.
  49. ChrisRapczynski

    ChrisRapczynski

    Joined:
    Jan 13, 2020
    Posts:
    42
    I'm struggling to get it to work, I thinks its because I maybe be putting this line in the wrong spot:

    float scale = 1 + gap / (float)repetitionCount;


    and because I didnt know what you mean by (float)

    and when you say this:
    "Now remember that the mesh length is "found" by the bender, by finding the vertices with the minimum and maximum coordinate along the X axis. If you want your decal mesh to be placed exactly above your plain mesh, you need to ensure that the meshes start and end at the same X coordinates so they have the exact same length."
    do you mean this assuming that the decal mesh is already the same length as the object its going to projected upon? this can be a consideration and wouldnt be a problem but by default its dimensions are only as far as its soonest and farest decal are located which makes it shorter than the main mesh
     
  50. methusalah999

    methusalah999

    Joined:
    May 22, 2017
    Posts:
    648
    (float) converts an int to float in this occurence,

    And indeed, if the mesh dimension is trimmed to the soonest and farest decals and is not, infact, having the same bounds on X than the mesh it is supposed to cover, then an offset will occur after a few repetition.