Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SplinePathMeshBuilder to Curvy Generator
I am currently updating and improving code that was originally built bij another company using an older version of Curvy.
I basically fixed everything except for the code below:

Since I can't find really good examples online how to convert a SplinePathMeshBuilder to a Curvy Generator version I'd love to get some advice on how to convert this. Especially since I am new to Curvy.

Here's the code (and thanks in advance):  

     public SplinePathMeshBuilder CreateMesh ()
                var MeshBuilder = SplinePathMeshBuilder.Create ();
                spline.Refresh ();

                MeshBuilder.Spline = spline;
                MeshBuilder.CapShape = SplinePathMeshBuilder.MeshCapShape.Custom;
                MeshBuilder.StartMesh = railCapMesh;
                MeshBuilder.gameObject.layer = parentTransform.gameObject.layer;
                MeshBuilder.GetComponent<Renderer> ().material = railMaterial;
                MeshBuilder.UV = SplinePathMeshBuilder.MeshUV.Absolute;
                MeshBuilder.UVParameter = 0.12f; //width of the mapping in cm. 
                MeshBuilder.ExtrusionParameter = 3;
                MeshBuilder.EndCap = MeshBuilder.StartCap    = false;
                MeshBuilder.Refresh ();

                var coll = MeshBuilder.gameObject.AddComponent<MeshCollider> ();

                coll.isTrigger = true;

                railPieceSelection rps = MeshBuilder.gameObject.AddComponent<railPieceSelection> ();

                rps.railPiece = this;

                rps.selected += RailPieceSelectedEventHandler;
                MeshBuilder.transform.parent = parentTransform;
                return MeshBuilder;

That looks like an usual extrusion to me. Please look into the CG setup of one of the example scenes (e.g. 21_CGExtrusion). Tipp: you can add whole templates like the above extrusion to a CG graph (see the tutorial vid about it).

If you want to create a whole CG by code, see 51_InfiniteTrack - that example creates both a spline path and a CG by code. That's a bit extreme though: the best approach is to create a decent CG that does what you want, then change options by script if neccessary.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Custom Spots Filter Generator Module mercior 3 8 03-10-2023, 10:20 AM
Last Post: _Aka_
Brick Extending Curvy to make a Hallway editor. JacobSL 5 395 02-13-2023, 09:29 AM
Last Post: _Aka_
  Curvy does not like Unity 2021.3 (Attribute Conflicts) KasimirBlust 2 7 01-27-2023, 09:23 AM
Last Post: _Aka_
Lightbulb In Game Roads - Curvy Generator Prefab? etoreo 3 9 01-05-2023, 09:16 AM
Last Post: _Aka_

Forum Jump: