Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Force Mesh creation at runtime?
How do I force the creation of a mesh at runtime?  If I use a generator, the mesh gets created if I run the creation through a co-routine, but how do I force the mesh to be created without a co-routine?
Like answered by mail: Call CurvyGenerator.Refresh(), then use the CreateMesh module's SaveToScene() method to "extract" the meshes.
This code does not work, unless, I put it into a co-routine with a 0.1f second wait.

   // Create the spline
   var GENERATOR = CurvyGenerator.Create();
   var SHAPE = Rails[0].CopyTo(GENERATOR);

   var PATH = GENERATOR.AddModule<InputSplinePath>();
   var EXTRUSION = GENERATOR.AddModule<BuildShapeExtrusion>();
   var VOLUME = GENERATOR.AddModule<BuildVolumeMesh>();
   VOLUME.SetMaterial(0, RailMaterials[1]);
   VOLUME.MaterialSetttings[0].KeepAspect = CGKeepAspectMode.ScaleU;
   var MESH = GENERATOR.AddModule<CreateMesh>();

   // Wire the Generator Parts

   // Create the spline
   PATH.Spline = CurvySpline.Create();


   // ... logic to add points to SPLINE

   var CREATED_MESH = MESH.SaveToScene(myGameObject.transform);

   // CREATED_MESH is null
What does "var SHAPE=Rails[0].CopyTo(GENERATOR)" is supposed to do?

Edit: Nevermind, should know my own API better Big Grin

You shouldn't need to make your shape spline a managed spline (that's what you do with copying it into the CG space). I just noticed your other post, will continue there...
Rails[0] is a shape inside of another generator created within the editor.  The thing is, the code runs fun if I put it into a co-routine and let the system run though a bunch of frames, but doesn't work if I run it straight.

[Image: 51d688a126.png]

In retrospect, I may have done this because I couldn't figure out a way to create the shape at runtime.  I could create a shape consisting of pre-fab elements like circles and boxes, but how do I create a spline and tell Curvy to extrude it along the path ... all at runtime?  There was no sample in the example code that I could find to do that.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 296 06-17-2021, 01:59 PM
Last Post: _Aka_
  Updating MaterialID in MetaCGOptions at Runtime boriskourt 5 323 06-16-2021, 03:54 PM
Last Post: _Aka_
  Questions about Generator: mesh/objects within spline, snap to control point dartboard 5 467 06-09-2021, 12:42 PM
Last Post: _Aka_
Shocked Change spline path at runtime burn0815 7 805 05-27-2021, 08:27 PM
Last Post: _Aka_

Forum Jump: