the Curve3 object has a useful method, the continue() method, that allows you place the start of one Curve3 onto the end of another Curve3 without any calculations to match the start and end points of the curves.
Is there any examples of building a full path with Bézier curves. I get that you can specify points, but that still one curve from a set of three points.
I am trying to create a driving line for a race track using Bézier curve control points in unity and export those control points to Babylon and rebuild the full Bézier path in client side Babylon script
The only way I can see that is grouping all the path control points into threes… then build a Bézier curve for the first three control points … using the last control point from each group as the first control point for the next group of three points. That’s the stitching … I believe
It’s my understanding that’s how you build a full Bézier path. But was wondering how I am going to handle such a thing in Babylon
And if anyone has ever built a full Bézier path … not just a single Bézier curve
But if anybody has ever generated a full path from control points … not just a hard coded 2 or three example … I was hoping I can see how they handle a few things like:
How many control points do they require, and should it be a divisible of 3 … if you don’t have enough control points for that last curve, are you adding dummy points or just truncate that set if not a set of three points. How are your handling close loops… etc… basically a full example … if anyone has one .
I am also thing bout trying to create a static helper function that you pass all the control points and that function would create the Curve3 spline with all the detail points.
Kind like the create static function Babylon has for Catmull Rom paths… but this will be for full bezier paths.
Looking for details on how I would build such a class and to properly handle differ lengths of control points.
But alas … I cannot find any example code doing this kind of thing… so I would have to make up all this logic myself for working with full path Bézier curves
I get that you have a point one and a point two and a control point in the middle that controls the curve.
I am trying to make a tool in unity where you simply layout transform to define your path. I then come along and serializing that transform position and rotation and use those as control points in Babylon. The use can put what ever or how many transforms they want. For me to control the amount of transforms to make sure it’s total amount is correct for a proper Bézier path, I would also have to create or purchase a tool in unity to make sure the user enter the correct amount of points when exporting the scene
That’s why I said what if you don’t have enough points. Think if I should pop up a message and say you don’t have proper number of points or some how create the missing point or two with default values or something.
But all this might be too much and I might only support Unity Catmull Rom splines and not Bézier curve splines for exporting from unity to Babylon … Bézier curve exporting would have been pretty cool though… use unity to layout race lines around a large race track and choose your type curve, Catmull or bezier… that would have been a sweet design time tool for my racing game projects and making many race tracks for my Vehicle AI to drive along
Is it possible to to demonstrate how to produce a particular curve in Unity using layout transform and provide the data you would export for that curve to import into BJS?
Perhaps ( and it is a big perhaps) it might be enough to work on.
I did do some Bezier path creation with BJS in http://cubees.github.io/ both Lathe and Extrude will take you to using a Bezier path. Click on existing path to bring up the menu to add/ delete points, drag and drop the control points.
MackeyK24, I am 99% sure this is not what you want but . . . MeshWriter builds glyphs out of cubic and quadratic Bezier curves. The curves are specified originally in the font file, so it doesn’t have to create anything.
I would expect that using Catmull-Rom in Unity means the only possibility is to export for Catmull-Rom in BJS. If it is possible to create a full path in Unity using Bezier curves then you are likely to be able to export this data to use Bezier curves in BJS
Conversion between Catmull-Rom and Bezier and vice-versa appears possible A Primer on Bézier Curves but I need time to read and understand it.
EDIT PS if you end up drawing the same curve in BJS what are the advantages of using Bezier over Catmull-Rom that you see?
The difference between Catmull-Rom and Bezier is mainly tighter cornering with race lines… Catmull evaluates ALL the control points to determine the curve amount in between points… which tends to make the curve a little wider in the corners when laying out an entire track with lots off turns.
Bézier lets you put a control point before the turn and one after then use the middle point to fine tune the curve amount for just that corner
That’s the only reason I started messing with Bézier…: tighter corners in a race line
Also… I must note… this is for a Visuals of the race line as a helper for the driver. Because weather I’m using Catmull rom with a 1 as resolution with is very blocky or something higher like 20 which makes real smooth curves…
Does not matter for the AI… because my AI driver is really following the chase rabbit with smooth turning angle… distanceToPoint.x / distanceToPoint.length gives you smooth turning Angle no matter if chase rabbit is following a low res spline curve or a hi res spline curve
But I wanted to generate a glowing mesh and drop on the race track to show the best race line to take corners… but again my AI driver can get away with low res Catmull rom splines… the race line visual looks crappy when low res… a bezier would solve the smooth/tight cornering race lines