Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generate walls on non-uniformly scaled mesh
#1
Hey _Aka_,

I have a generated spline with advanced non-uniform X scaling on the Shape Extrusion node. I am looking for a way to be able to generate "walls" that adapts to this non-uniform scale, but haven't found an easy way to do so. The wall needs to be a separate mesh. I've played around with the scaling settings on the shape extrusion node of the wall, but failed to achieve what I need. Here are some screenshots to show what I am talking about.

Thanks!

[Image: n9N5t2W.png]
[Image: mp0JUQP.png]

Also I am not sure why the headers of the nodes in the node editor disappeared. It seems to happen randomly sometimes.
Reply
#2
I will answer the main question soon. About the missing headers, on what Unity version did this happen? I am aware of this issue, but I was under the impression that this issue is not present in the latest Unity versions.
Thanks
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
(08-12-2022, 05:04 PM)_Aka_ Wrote: I will answer the main question soon. About the missing headers, on what Unity version did this happen? I am aware of this issue, but I was under the impression that this issue is not present in the latest Unity versions.
Thanks

I am on 2021.3.5f1. The headers disappear when I try to open generator in different scenes:

1. Open scene A, open generator graph
2. Open scene B, open generator graph
3. Headers disappear
Reply
#4
(08-12-2022, 05:34 PM)GameJazz Wrote: I am on 2021.3.5f1. The headers disappear when I try to open generator in different scenes:


1. Open scene A, open generator graph

2. Open scene B, open generator graph

3. Headers disappear


Thanks for the additional information, will add that to the bugs list.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
About the main question, I see a solution that can be implemented relatively quickly. Will try to implement it in the next few days.
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
Hi

I modified the Path Relative Translation module so that its translation is no more a fixed value, but a variable one. A proper, release ready, implementation will be different, but this is a functional one.

The idea is to use the same curve that you use to define the road's width, to use it to define the translation of the path used to generate the walls.

I also attached a scene with a setup that uses this modified module.

I hope this helped

Code:
// =====================================================================
// Copyright 2013-2022 ToolBuddy
// All rights reserved
//
// http://www.toolbuddy.net
// =====================================================================

using System;
using FluffyUnderware.DevTools;
using UnityEngine;
using UnityEngine.Assertions;

namespace FluffyUnderware.Curvy.Generator.Modules
{
    /// <summary>
    /// Translates a path relatively to it's direction, instead of relatively to the world as does the TRS Path module.
    /// </summary>
    [ModuleInfo("Modifier/Path Relative Translation", ModuleName = "Path Relative Translation", Description = "Translates a path relatively to it's direction, instead of relatively to the world as does the TRS Path module.")]
    [HelpURL(CurvySpline.DOCLINK + "cgpathrelativetranslation")]
#pragma warning disable 618
    public class ModifierPathRelativeTranslation : CGModule, IOnRequestProcessing, IPathProvider
#pragma warning restore 618
    {
        [HideInInspector]
        [InputSlotInfo(typeof(CGPath), Name = "Path A", ModifiesData = true)]
        public CGModuleInputSlot InPath = new CGModuleInputSlot();

        [HideInInspector]
        [OutputSlotInfo(typeof(CGPath))]
        public CGModuleOutputSlot OutPath = new CGModuleOutputSlot();


        #region ### Serialized Fields ###

        /// <summary>
        /// The translation amount
        /// </summary>
        [SerializeField]
        [Tooltip("The translation amount")]
        [AnimationCurveEx("Lateral Translation")]
        private AnimationCurve lateralTranslation = new AnimationCurve(new Keyframe(0,0), new Keyframe(1,0));
        #endregion

        #region ### Public Properties ###

        /// <summary>
        /// The translation amount
        /// </summary>
        public AnimationCurve LateralTranslation
        {
            get { return lateralTranslation; }
            set
            {
                if (lateralTranslation != value)
                {
                    lateralTranslation = value;
                    Dirty = true;
                }
            }
        }

        public bool PathIsClosed
        {
            get
            {
                return (IsConfigured) ? InPath.SourceSlot().PathProvider.PathIsClosed : false;
            }
        }

        #endregion

        #region ### IOnRequestProcessing ###

        public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests)
        {
            CGData[] result;
            if (requestedSlot == OutPath)
            {
                CGPath data = InPath.GetData<CGPath>(out bool isDisposable, requests);
#if CURVY_SANITY_CHECKS
                // I forgot why I added this assertion, but I trust my past self
                Assert.IsTrue(data == null || isDisposable);
#endif
                if (data)
                {
                    Vector3[] positions = data.Positions.Array;

                    for (int i = 0; i < data.Count; i++)
                    {
                        Vector3 translation = Vector3.Cross(data.Normals.Array[i], data.Directions.Array[i]) * lateralTranslation.Evaluate(data.RelativeDistances.Array[i]);
                        positions[i].x = positions[i].x + translation.x;
                        positions[i].y = positions[i].y + translation.y;
                        positions[i].z = positions[i].z + translation.z;
                    }

                    data.Recalculate();
                }

                //TODO after fixing Directions computation in ConformPath, do the same here

                result = new CGData[1] { data };
            }
            else
                result = null;

            return result;
        }

        #endregion


        #region ### Unity Callbacks ###
        /*! \cond UNITY */

        protected override void OnEnable()
        {
            base.OnEnable();
            Properties.MinWidth = 250;
            Properties.LabelWidth = 165;
        }

        public override void Reset()
        {
            base.Reset();
            LateralTranslation = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0));
        }

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

        /*! \endcond */
        #endregion
    }
}


Attached Files
.unity   GameJazz Extrusion Scale.unity (Size: 60.69 KB / Downloads: 2)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#7
(08-14-2022, 10:23 PM)_Aka_ Wrote: Hi

I modified the Path Relative Translation module so that its translation is no more a fixed value, but a variable one. A proper, release ready, implementation will be different, but this is a functional one.

The idea is to use the same curve that you use to define the road's width, to use it to define the translation of the path used to generate the walls.

I also attached a scene with a setup that uses this modified module.

I hope this helped

Code:
// =====================================================================
// Copyright 2013-2022 ToolBuddy
// All rights reserved
//
// http://www.toolbuddy.net
// =====================================================================

using System;
using FluffyUnderware.DevTools;
using UnityEngine;
using UnityEngine.Assertions;

namespace FluffyUnderware.Curvy.Generator.Modules
{
    /// <summary>
    /// Translates a path relatively to it's direction, instead of relatively to the world as does the TRS Path module.
    /// </summary>
    [ModuleInfo("Modifier/Path Relative Translation", ModuleName = "Path Relative Translation", Description = "Translates a path relatively to it's direction, instead of relatively to the world as does the TRS Path module.")]
    [HelpURL(CurvySpline.DOCLINK + "cgpathrelativetranslation")]
#pragma warning disable 618
    public class ModifierPathRelativeTranslation : CGModule, IOnRequestProcessing, IPathProvider
#pragma warning restore 618
    {
        [HideInInspector]
        [InputSlotInfo(typeof(CGPath), Name = "Path A", ModifiesData = true)]
        public CGModuleInputSlot InPath = new CGModuleInputSlot();

        [HideInInspector]
        [OutputSlotInfo(typeof(CGPath))]
        public CGModuleOutputSlot OutPath = new CGModuleOutputSlot();


        #region ### Serialized Fields ###

        /// <summary>
        /// The translation amount
        /// </summary>
        [SerializeField]
        [Tooltip("The translation amount")]
        [AnimationCurveEx("Lateral Translation")]
        private AnimationCurve lateralTranslation = new AnimationCurve(new Keyframe(0,0), new Keyframe(1,0));
        #endregion

        #region ### Public Properties ###

        /// <summary>
        /// The translation amount
        /// </summary>
        public AnimationCurve LateralTranslation
        {
            get { return lateralTranslation; }
            set
            {
                if (lateralTranslation != value)
                {
                    lateralTranslation = value;
                    Dirty = true;
                }
            }
        }

        public bool PathIsClosed
        {
            get
            {
                return (IsConfigured) ? InPath.SourceSlot().PathProvider.PathIsClosed : false;
            }
        }

        #endregion

        #region ### IOnRequestProcessing ###

        public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests)
        {
            CGData[] result;
            if (requestedSlot == OutPath)
            {
                CGPath data = InPath.GetData<CGPath>(out bool isDisposable, requests);
#if CURVY_SANITY_CHECKS
                // I forgot why I added this assertion, but I trust my past self
                Assert.IsTrue(data == null || isDisposable);
#endif
                if (data)
                {
                    Vector3[] positions = data.Positions.Array;

                    for (int i = 0; i < data.Count; i++)
                    {
                        Vector3 translation = Vector3.Cross(data.Normals.Array[i], data.Directions.Array[i]) * lateralTranslation.Evaluate(data.RelativeDistances.Array[i]);
                        positions[i].x = positions[i].x + translation.x;
                        positions[i].y = positions[i].y + translation.y;
                        positions[i].z = positions[i].z + translation.z;
                    }

                    data.Recalculate();
                }

                //TODO after fixing Directions computation in ConformPath, do the same here

                result = new CGData[1] { data };
            }
            else
                result = null;

            return result;
        }

        #endregion


        #region ### Unity Callbacks ###
        /*! \cond UNITY */

        protected override void OnEnable()
        {
            base.OnEnable();
            Properties.MinWidth = 250;
            Properties.LabelWidth = 165;
        }

        public override void Reset()
        {
            base.Reset();
            LateralTranslation = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0));
        }

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

        /*! \endcond */
        #endregion
    }
}

Thank you for pointing me towards the right direction. The solution doesn't solve my problem completely, but I should be able to tweak it to fit my needs!
Reply
#8
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
  Adjust radius of generated mesh via script? Shackman 1 3 03-26-2024, 01:12 PM
Last Post: _Aka_
  Not seeing mesh extended after following YT PaulM 1 3 02-02-2024, 12:01 PM
Last Post: _Aka_
  Cant Generate Meshes At Runtime alms94 5 22 01-26-2024, 11:27 AM
Last Post: _Aka_
  Trigger Zones along Spline Mesh dlees9191 1 5 01-05-2024, 10:18 AM
Last Post: _Aka_

Forum Jump: