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!
Also I am not sure why the headers of the nodes in the node editor disappeared. It seems to happen randomly sometimes.
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
(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
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;
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;
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!