Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Permission to publish custom CGModule source code?
#1
I want to provide some CGModule-extending code in a public repository for other Curvy users to use. They will be able to use it by adding FLUFFYUNDERWARE_CURVY to their Scripting Define Symbols, found under Edit > Project Settings > Player, in the inspector window.
   
This is adapted from the ModifierTRSPath class.

ModifierOffsetPath.cs
Code:
// =====================================================================
// Copyright 2013-2017 Fluffy Underware
// All rights reserved
//
// http://www.fluffyunderware.com
// =====================================================================

#if FLUFFYUNDERWARE_CURVY

using FluffyUnderware.DevTools;
using UnityEngine;

namespace FluffyUnderware.Curvy.Generator.Modules
{
    [ModuleInfo("Modifier/Offset Path", ModuleName = "Offset Path", Description = "Offset a path by its normals/binormals")]
    [HelpURL(CurvySpline.DOCLINK + "cgtrspath")]
    public class ModifierOffsetPath : CGModule, IOnRequestPath
    {
        [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 ##

        [SerializeField]
        [VectorEx]
        private Vector3 m_Offset;

        #endregion ## Serialized Fields ##

        #region ### Public Properties ###

        public Vector3 Offset
        {
            get { return m_Offset; }
            set
            {
                if (m_Offset != value)
                    m_Offset = value;
                Dirty = true;
            }
        }

        public float PathLength
        {
            get
            {
                return (IsConfigured) ? InPath.SourceSlot().OnRequestPathModule.PathLength : 0;
            }
        }

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

        #endregion ### Public Properties ###

        #region ### IOnRequestProcessing ###

        public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests)
        {
            if (requestedSlot == OutPath)
            {
                var Data = InPath.GetData<CGPath>(requests);

                for (int i = 0; i < Data.Count; i++)
                {
                    var position = Data.Position[i];
                    var tangent = Data.Direction[i];
                    var normal = Data.Normal[i];
                    var binormal = Vector3.Cross(tangent, normal);
                    var offset_matrix = new Matrix4x4();
                    offset_matrix.SetColumn(0, tangent);
                    offset_matrix.SetColumn(1, normal);
                    offset_matrix.SetColumn(2, binormal);
                    Vector3 offset = offset_matrix * Offset;
                    Data.Position[i] += offset;
                }

                Data.Recalculate();
                return new CGData[1] { Data };
            }
            return null;
        }

        #region ### Unity Callbacks ###

        /*! \cond UNITY */

        protected override void OnEnable()
        {
            base.OnEnable();
            Properties.MinWidth = 200;
            Properties.LabelWidth = 50;
        }

#if UNITY_EDITOR

        protected override void OnValidate()
        {
            base.OnValidate();
            Offset = m_Offset;
        }

#endif

        /*! \endcond */

        #endregion ### Unity Callbacks ###
    }

    #endregion ### IOnRequestProcessing ###
}

#endif

ModifierOffsetPathEditor.cs
Code:
// =====================================================================
// Copyright 2013-2017 Fluffy Underware
// All rights reserved
//
// http://www.fluffyunderware.com
// =====================================================================

#if FLUFFYUNDERWARE_CURVY

using FluffyUnderware.Curvy.Generator.Modules;
using UnityEditor;

namespace FluffyUnderware.CurvyEditor.Generator.Modules
{
    [CustomEditor(typeof(ModifierOffsetPath))]
    public class ModifierOffsetPathEditor : CGModuleEditor<ModifierOffsetPath>
    {
    }
}

#endif

Am I allowed to make this source code publicly available in my repository?

PS: If you want to add these to/adapt these for Curvy, please go ahead. You have my full permission!
Reply
#2
(06-07-2017, 07:14 PM)Jakee Wrote: As long as you don't publish Curvy source, this is totally fine. But I'm curious. what does it exactly do? Looks like you can get the same effect with a PathController GameObject where the visible object is offsetted locally using Unity's hierarchy transform. What do I miss?

Thanks for the code.
Reply
#3
As long as you don't publish Curvy source, this is totally fine. But I'm curious. what does it exactly do? Looks like you can get the same effect with a PathController GameObject where the visible object is offsetted locally using Unity's hierarchy transform. What do I miss?
Reply
#4
(06-07-2017, 07:14 PM)Jake Wrote: As long as you don't publish Curvy source, this is totally fine. But I'm curious. what does it exactly do? Looks like you can get the same effect with a PathController GameObject where the visible object is offsetted locally using Unity's hierarchy transform. What do I miss?

Consider this city street road created by a extrusion volume/mesh generator.
I have a comparison between a sidewalk cross section spline that has had all of its points moved:

   
(it gets pinched Sad)

and one that is centered but uses an offset modifier on the path before extrusion:

   
(no pinching!)

Here is my generator configuration, for reference:

   
Reply
#5
(06-08-2017, 10:55 AM)Apelsin Wrote:
(06-07-2017, 07:14 PM)Jake Wrote: As long as you have tried phentermine over the counter and compare them and Curvy source, this is totally fine. But I'm what does it exactly do? Looks like you can get the same effect with a PathController GameObject where the visible object is offsetted locally using Unity's hierarchy transform. What do I miss?

Consider this city street road created by a extrusion volume/mesh generator.
I have a comparison between a sidewalk cross section spline that has had all of its points moved:


(it gets pinched Sad)

and one that is centered but uses an offset modifier on the path before extrusion:


(no pinching!)

Here is my generator configuration, for reference:

I was also about to ask that what does the code exactly do. You explained it clearly. Thanks. And many thanks for the permission to use the code. Developers like you make this forum great.
Reply
#6
(07-06-2018, 06:52 AM)SteveMartinez Wrote:
(06-08-2017, 10:55 AM)Apelsin Wrote:
(06-07-2017, 07:14 PM)Jake Wrote: As long as you don't publish Curvy source, this is totally fine. But what does it exactly do? Looks like you can get the Dbal max same effect with a PathController GameObject where the visible object is offsetted locally using Unity's hierarchy transform. What do I miss?

Consider this city street road created by a extrusion volume/mesh generator.
I have a comparison between a sidewalk cross section spline that has had all of its points moved:


(it gets pinched Sad)

and one that is centered but uses an offset modifier on the path before extrusion:


(no pinching!)

Here is my generator configuration, for reference:

I was also about to ask that what does the code exactly do. You explained it clearly. Thanks. And many thanks for the permission to use the code. Developers like you make this forum great.

Yes, this is a great forum where most of the members are ready to go even out of the way to help others. I've been lurking in the forum for a long time.
Reply
#7
I agree with you.
(01-13-2019, 03:23 PM)NicholasBosworth Wrote:
(07-06-2018, 06:52 AM)SteveMartinez Wrote:
(06-08-2017, 10:55 AM)Apelsin Wrote:
(06-07-2017, 07:14 PM)Jake Wrote: As long as you don't publish Curvy source, this is totally fine. But what does it exactly do? Looks like you can get the Dbal max same effect with a PathController GameObject where the visible object is offsetted locally using Unity's hierarchy transform. What do I miss?

Consider this city street road created by a extrusion volume/mesh generator.
I have a comparison between a sidewalk cross section spline that has had all of its points moved:


(it gets pinched Sad)

and one that is centered but uses an offset modifier on the path before extrusion:


(no pinching!)

Here is my generator configuration, for reference:

I was also about to ask that what does the code exactly do. You explained it clearly. Thanks. And many thanks for the permission to use the code. Developers like you make this forum great.

Yes, this is a great forum where most of the members are ready to go even out of the way to help others. I've been lurking in the forum for a long time.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to attach custom components to output Sacryn 3 6 02-23-2024, 09:42 AM
Last Post: _Aka_
  Guide to custom placing stuff on spline Lupos 15 43 11-27-2023, 12:51 PM
Last Post: _Aka_
  Custom CurvySplineSegment prefabs Lupos 1 10 10-02-2023, 09:36 AM
Last Post: _Aka_
  Custom Control Nodes Lupos 3 14 05-27-2023, 09:05 PM
Last Post: _Aka_

Forum Jump: