Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scale Deform Mesh Along Spline? / aligning colliders
#1
Earlier today we purchased Curvy Splines for a project at work and having looked into it for the last few hours I must say i am very impressed. It appears to do most of what I was hoping for but there are three things I so far haven't been able to do with your excellent plugin.

1. I see that it is possible to scale a shape extrusion along the length of the spline, can a similar effect by replicated using the deform mesh option? We are looking to use the system for tree roots, tentacles etc. which is to say that we need to apply our own base meshes but also ideally be able to scale the meshes along the spline path.

2. Secondary question is whether or it is possibly to assign an specific mesh at the end of a mesh deform spline path. In the same context of the previous question, we're looking to make tree root-like shapes and would love to have the last mesh along a "deform mesh" spline be an end piece.

3. Lastly, I love all the options for exporting meshes under the "create mesh" note, however I have a hard time using the colliders. What I'd like to do is to have the generated primitive colliders (Box, capsules) be aligned with the average direction of each mesh piece. Currently when I ask the Create mesh note to generate box colliders. it does so in word-space alignment which means that they are nearly useless.
Reply
#2
Hi

1. Using the Deform Mesh feature, you can't unfortunately scale a mesh along the path. You can scale the whole object using the Scale section in the Volume Spots module, under your group's tab. But this scaling will scale the whole object uniformally, so not what you are looking for if I understood correctly.
Being able to scale the defomed mesh is a good idea, I take note of it for future versions.

2. Does the end piece have to be deformed as well?
If no, please take a look at the attached example, made for another customer, that simulates a snake being deformed, and its head being at the end of the deformed mesh.
If yes, then make two Curvy Generators having a mesh deformation setup in them. Using the Range parameter of the Rasterize Path module, you can set what part of the path each generator should act on.

3. The box and capsule collider can, as far as I know, only be aligned on the world's axis. If I am wrong, please do the following to help me fix the issue:
- Make an example scene with a curvy generator that does a mesh deformtation with box and/or capsule colliders
- Export the created meshes. These will have the colliders setup in the way that doesn't fit your needs
- Duplicate one of the exported meshes, and set it up the way you would like the generators to set them up. Rename this object in such a way I can recognize it (for example "...._Corrected")
- Send me this setup
Once received, I will see what I can do.

I hope this helped
Have a nice day


Attached Files
.meta   SnakeAnimator.cs.meta (Size: 243 bytes / Downloads: 3)
.cs   SnakeAnimator.cs (Size: 791 bytes / Downloads: 6)
.meta   Snake.unity.meta (Size: 155 bytes / Downloads: 3)
.unity   Snake.unity (Size: 62.29 KB / Downloads: 3)
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#3
(09-14-2022, 06:51 PM)_Aka_ Wrote: Hi

1. Using the Deform Mesh feature, you can't unfortunately scale a mesh along the path. You can scale the whole object using the Scale section in the Volume Spots module, under your group's tab. But this scaling will scale the whole object uniformally, so not what you are looking for if I understood correctly.
Being able to scale the defomed mesh is a good idea, I take note of it for future versions.

2. Does the end piece have to be deformed as well?
If no, please take a look at the attached example, made for another customer, that simulates a snake being deformed, and its head being at the end of the deformed mesh.
If yes, then make two Curvy Generators having a mesh deformation setup in them. Using the Range parameter of the Rasterize Path module, you can set what part of the path each generator should act on.

3. The box and capsule collider can, as far as I know, only be aligned on the world's axis. If I am wrong, please do the following to help me fix the issue:
- Make an example scene with a curvy generator that does a mesh deformtation with box and/or capsule colliders
- Export the created meshes. These will have the colliders setup in the way that doesn't fit your needs
- Duplicate one of the exported meshes, and set it up the way you would like the generators to set them up. Rename this object in such a way I can recognize it (for example "...._Corrected")
- Send me this setup
Once received, I will see what I can do.

I hope this helped
Have a nice day

Hi Smile Thanks for the reply.

1. Yea I believe you understood it correctly. important note though is that the gradual scaling would have to apply to all the meshes deformed along the spline. Essentially the same effect you currently have for the extrude shape, only applied to all the deformed meshes along a curve, seeing it in a future update would be much appreciated.

2. It would have to follow the spline. I can see how your solution might work, I'll give it a shot later today and report back. My main concern is how difficult it might be to match find the right point on the spline without the ending peice "tiling" along the spline.  If I might suggest a possible improvement for future users. You already have the ability to place different meshes along the spline through a single generator, adding a "start" and "end" mesh would do wonders for work flow.

3. I'll look into giving you an example, but I'll try to explain a possible solution (I'm not coder, merely an artist and level designer, so bare with me ^^ ) Colliders obviously align with the objects they are applied to, which results in the box colliders being a very rough fit since all your generated meshes are placed in 0,0,0 rotation. My suggestion is to have an option to have the pivot orientation of the generated meshes, match the orientation of the point on the spline they were placed at, that way a primitive collider would be a able to match the shape much more accurately.
Reply
#4
Hi
2. Feature suggestion noted, thanks.
3. I see what you mean now.
Sorry that all your requests need coding, which I can't do now since I am on vacation. I will start working on them once back to the office, last week of the month.
Thanks for your patience, and have a nice day
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#5
(09-17-2022, 12:54 PM)_Aka_ Wrote: Hi
2. Feature suggestion noted, thanks.
3. I see what you mean now.
Sorry that all your requests need coding, which I can't do now since I am on vacation. I will start working on them once back to the office, last week of the month.
Thanks for your patience, and have a nice day

Haha no worries, I'll be honest this is probably the most well made tool for unity I've come across so far, really fills a gap in what the vanilla engine can do. We'll just work around these limitations for now.
Reply
#6
If I understand correctly, you want only 1 mesh to be always at the end? I had that problem too so I made a spot generator given the percent in 0.0 to 1.0 format:

[Image: o0Qfkv4.gif]

Here's the code:
Code:
using System;
using UnityEngine;
using System.Collections.Generic;
using FluffyUnderware.Curvy.Pools;
using FluffyUnderware.DevTools;
using ToolBuddy.Pooling.Collections;

namespace FluffyUnderware.Curvy.Generator.Modules
{
    [ModuleInfo("Build/Percent Path Spot", ModuleName="Percent Path Spot", Description="Return spots from the path using its TF (0.5 will return a spot in the middle of the path).")]
    public class BuildPercentPathSpot : CGModule
    {
        [HideInInspector]
        [InputSlotInfo(typeof(CGPath), Name = "Path/Volume", DisplayName = "Volume/Rasterized Path")]
        public CGModuleInputSlot InPath = new CGModuleInputSlot();

        [HideInInspector]
        [OutputSlotInfo(typeof(CGSpots))]
        public CGModuleOutputSlot OutSpots = new CGModuleOutputSlot();

        [Serializable]
        public struct Entry
        {
            [RangeEx(0, 1, Label="Percent")]
            public float Percent;

            [VectorEx]
            public Vector3 PositionOffset;

            [VectorEx]
            public Vector3 RotationOffset;
        }

        #region ### Serialized Fields ###
        [SerializeField]
        private List<Entry> m_Entries = new List<Entry>();
        #endregion

        #region ### Unity Callbacks ###
        /*! \cond UNITY */
        protected override void OnEnable()
        {
            base.OnEnable();

            // Note: Float Range Sliders won't show up unless we do this:
            Properties.MinWidth = 270;
            Properties.LabelWidth = 100;
        }

#if UNITY_EDITOR
        protected override void OnValidate()
        {
            base.OnValidate();
            Dirty = true;
        }
#endif

        public override void Reset()
        {
            base.Reset();
            m_Entries.Clear();
            m_Entries.Add(new Entry());
        }

        /*! \endcond */
        #endregion

        #region ### Module Overrides ###

        public override void Refresh()
        {
            base.Refresh();
            /* Add Module processing code in here */

            CGPath path = InPath.GetData<CGPath>(out bool isDisposable);
            SubArrayList<CGSpot> spots = new SubArrayList<CGSpot>(m_Entries.Count, ArrayPools.CGSpot);

            for (int n = 0, len = m_Entries.Count; n < len; ++n)
            {
                path.Interpolate(m_Entries[n].Percent, out Vector3 pos, out Vector3 dir, out Vector3 up);

                Quaternion rotation = Quaternion.LookRotation(dir, up) * Quaternion.Euler(m_Entries[n].RotationOffset);
                spots.Add(new CGSpot(0, pos + (rotation * m_Entries[n].PositionOffset), rotation, Vector3.one));
            }

            OutSpots.SetData(new CGSpots(spots.ToSubArray()));

            if (isDisposable)
                path.Dispose();
        }

        // Called when a module's state changes (Link added/removed, Active toggles etc..)
        public override void OnStateChange()
        {
            base.OnStateChange();
            if (!IsConfigured)
                Clear();
        }

        public void Clear()
        {
            OutSpots.SetData(new CGSpots());
        }

        #endregion
    }
}

And the editor script for it:
Code:
using UnityEditor;
using FluffyUnderware.Curvy.Generator.Modules;

namespace FluffyUnderware.CurvyEditor.Generator.Modules
{
    [CustomEditor(typeof(BuildPercentPathSpot))]
    public class BuildPercentPathSpotEditor : CGModuleEditor<BuildPercentPathSpot>
    {
    }
}
Reply
#7
Thanks a lot for sharing this module Ferdinand, much appreciated.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#8
Hi Ferdinand,

I edited your code in this post, to avoid null reference exceptions when no entries are set in the module. My edit was to replace this:
private List<Entry> m_Entries;
with this:
private List<Entry> m_Entries = new List<Entry>();

Let me know if you think I should set the code back to what it was. Thanks again for your code
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#9
(09-15-2022, 10:02 AM)MamasToast Wrote: 1. Yea I believe you understood it correctly. important note though is that the gradual scaling would have to apply to all the meshes deformed along the spline. Essentially the same effect you currently have for the extrude shape, only applied to all the deformed meshes along a curve, seeing it in a future update would be much appreciated.

Hi
This feature is now available in the 8.3.0 update. Thanks for your patience, and have a nice day
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#10
(09-19-2022, 11:53 AM)Ferdinand Wrote: If I understand correctly, you want only 1 mesh to be always at the end? I had that problem too so I made a spot generator given the percent in 0.0 to 1.0 format:

[Image: o0Qfkv4.gif]

Here's the code:
Code:
using System;
using UnityEngine;
using System.Collections.Generic;
using FluffyUnderware.Curvy.Pools;
using FluffyUnderware.DevTools;
using ToolBuddy.Pooling.Collections;

namespace FluffyUnderware.Curvy.Generator.Modules
{
    [ModuleInfo("Build/Percent Path Spot", ModuleName="Percent Path Spot", Description="Return spots from the path using its TF (0.5 will return a spot in the middle of the path).")]
    public class BuildPercentPathSpot : CGModule
    {
        [HideInInspector]
        [InputSlotInfo(typeof(CGPath), Name = "Path/Volume", DisplayName = "Volume/Rasterized Path")]
        public CGModuleInputSlot InPath = new CGModuleInputSlot();

        [HideInInspector]
        [OutputSlotInfo(typeof(CGSpots))]
        public CGModuleOutputSlot OutSpots = new CGModuleOutputSlot();

        [Serializable]
        public struct Entry
        {
            [RangeEx(0, 1, Label="Percent")]
            public float Percent;

            [VectorEx]
            public Vector3 PositionOffset;

            [VectorEx]
            public Vector3 RotationOffset;
        }

        #region ### Serialized Fields ###
        [SerializeField]
        private List<Entry> m_Entries = new List<Entry>();
        #endregion

        #region ### Unity Callbacks ###
        /*! \cond UNITY */
        protected override void OnEnable()
        {
            base.OnEnable();

            // Note: Float Range Sliders won't show up unless we do this:
            Properties.MinWidth = 270;
            Properties.LabelWidth = 100;
        }

#if UNITY_EDITOR
        protected override void OnValidate()
        {
            base.OnValidate();
            Dirty = true;
        }
#endif

        public override void Reset()
        {
            base.Reset();
            m_Entries.Clear();
            m_Entries.Add(new Entry());
        }

        /*! \endcond */
        #endregion

        #region ### Module Overrides ###

        public override void Refresh()
        {
            base.Refresh();
            /* Add Module processing code in here */

            CGPath path = InPath.GetData<CGPath>(out bool isDisposable);
            SubArrayList<CGSpot> spots = new SubArrayList<CGSpot>(m_Entries.Count, ArrayPools.CGSpot);

            for (int n = 0, len = m_Entries.Count; n < len; ++n)
            {
                path.Interpolate(m_Entries[n].Percent, out Vector3 pos, out Vector3 dir, out Vector3 up);

                Quaternion rotation = Quaternion.LookRotation(dir, up) * Quaternion.Euler(m_Entries[n].RotationOffset);
                spots.Add(new CGSpot(0, pos + (rotation * m_Entries[n].PositionOffset), rotation, Vector3.one));
            }

            OutSpots.SetData(new CGSpots(spots.ToSubArray()));

            if (isDisposable)
                path.Dispose();
        }

        // Called when a module's state changes (Link added/removed, Active toggles etc..)
        public override void OnStateChange()
        {
            base.OnStateChange();
            if (!IsConfigured)
                Clear();
        }

        public void Clear()
        {
            OutSpots.SetData(new CGSpots());
        }

        #endregion
    }
}

And the editor script for it:
Code:
using UnityEditor;
using FluffyUnderware.Curvy.Generator.Modules;

namespace FluffyUnderware.CurvyEditor.Generator.Modules
{
    [CustomEditor(typeof(BuildPercentPathSpot))]
    public class BuildPercentPathSpotEditor : CGModuleEditor<BuildPercentPathSpot>
    {
    }
}
This only seems to work if the splines path's CP0 local position is at (0,0,0)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Method of scattering objects along spline joebain 1 3 11-26-2024, 03:20 PM
Last Post: _Aka_
  Is it possible to make the face at the end of mesh? Chanon 3 6 11-14-2024, 04:38 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 5 13 10-29-2024, 10:19 AM
Last Post: _Aka_
  Mesh deform - baby guide jmh1804 7 11 08-22-2024, 07:18 AM
Last Post: _Aka_

Forum Jump: