Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SplinePathMeshBuilder to Curvy Generator
#1
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;
            }

Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy discards Input Spline Range VoltDriver 3 3 11-28-2023, 07:14 PM
Last Post: _Aka_
  Problematic Curvy API XtroTheArctic 8 23 10-16-2023, 08:41 AM
Last Post: _Aka_
  Curvy Splines Built In Editor Undo causes issues. Lupos 1 8 10-02-2023, 08:52 AM
Last Post: _Aka_
  Does Curvy has gameobjects pooling system function? Chanon 7 13 09-07-2023, 12:43 PM
Last Post: _Aka_

Forum Jump: