Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Guide to custom placing stuff on spline
#7
(10-05-2023, 02:07 PM)_Aka_ Wrote: You can deform objects that you place individually via Curvy Generator. The following video tutorial shows that in its first half. The second half is about deforming meshes that are placed automatically on a spline.
https://www.youtube.com/watch?v=eP6QEn9SFoM
Other than that, the mesh deforming code is public, and you can call it in your own code, for example a custom Curvy Generator module. The method is DeformMesh.DeformMeshes(...)

Sorry for the late response. I appreciate all your amazing help. 
The problem I'm having is that DeformMesh requires all sorts of parameters such as 

List<CGVMesh> inputMeshes,
            SubArray<CGSpot> inputSpots,
            SubArray<CGSpot> outputSpots,
            [NotNull] CGVMesh[] outputMeshes,
            [NotNull] CGPath path,
            bool stretchToEnd,
            ThreadPoolWorker<CGSpot> threadPoolWorker

its rather difficult to understand the steps needed to get all this data in my own custom setup. I was hoping you could provide me some steps to get this data.

From my understanding I need to rasterize the spline first, then generate volume spots for it from the game objects I plan to use as well convert the meshes from the gameobjects into CGVMeshes.


Where would you suggest I begin?


It's very overwhelming having to deal with the curvygenerator both from a coding perspective and from a editor/creator perspective.
I need rather specific control of my objects being generated along with them being able to curve and sadly curvygenerator doesn't offer me that.

For starters it seems have a 1 frame delay when refreshing things that seemingly breaks a lot of the editor code I'm trying to do at runtime. It also doesn't let me work with my own specfic custom types, I'm forced to inject my stuff on top after the objects refresh.

I've provided an example of the editor I'm trying to build. I was having way too much trouble getting the intersection code working with curvygenerator and was forced to write my own solution.



I currently generate the walls with this primitive solution

Code:
        private void GenerateWalls()
        {
            if (!IsSetup) return;
            if (spline == null) return;
            if (blockPool == null) return;

            var curvySpline = spline.CurvySpline;
            if (!curvySpline.IsInitialized) return;

            var blockIndex = 0;
            var splineDistance = spline.Distance;
            SplineSpawnSegment = Mathf.Max(splineDistance - 1, 0f);
            if (splineDistance <= 1f)
            {
                ReleaseExtraInstances(blockIndex);
                return;
            }


            BlockCount = Mathf.CeilToInt(SplineSpawnSegment);

            var emptyBlockSpace = (SplineSpawnSegment - BlockCount);

            var padding = emptyBlockSpace / 2f;
            var paddingOffset = padding / 2f;

            const float blockScale = 1f;
            var blockModifiedScale = blockScale + padding;

            var distanceOnSpline = blockScale;
            while (blockIndex < BlockCount)
            {
                var block = GetBlock(blockIndex);
                if (blockIndex == 0 || blockIndex == BlockCount - 1)
                {
                    var scale = block.LocalScale;
                    scale.z = blockModifiedScale;
                    block.LocalScale = scale;
                    distanceOnSpline += paddingOffset;

                    block.SetBoundJoint(blockIndex == 0 ? spline.GetFirstJoint() : spline.GetLastJoint());
                }
                else
                {
                    block.LocalScale = Vector3.one;
                    block.SetBoundJoint(null);
                }

                var tf = curvySpline.DistanceToTF(distanceOnSpline);
                var position = curvySpline.InterpolateFast(tf, Space.World);
                var rotation = curvySpline.GetTangentFast(tf, Space.World);
                block.CachedTransform.SetPositionAndRotation(position,
                    rotation != Vector3.zero ? Quaternion.LookRotation(rotation) : Quaternion.identity);

                distanceOnSpline += block.CachedTransform.localScale.z / 2f + blockScale / 2f;
                blockIndex++;
            }

I just want to know what steps I can take to help make the walls curve.
Reply


Messages In This Thread
RE: Guide to custom placing stuff on spline - by Lupos - 11-18-2023, 06:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get length starting from one spline to connected nth spline Dragon-3623 1 1 05-14-2024, 04:52 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_

Forum Jump: