Jump to content

Road Spline Data / API


Dogtanian
Go to solution Solved by Clyde,

Recommended Posts

Hi - I'm trying to get automated traffic running on a GeNa generated road.  To do that, I need to know where the road is, or more precisely, where the middle of the left hand side, and the middle of the right hand side, of the road is.

Can someone advise me on the best way of doing that?  Presumably I'd need to access the individual spline data points, and then do interpolation between them using exactly the same algorithm for the curve generation as GeNa does to ensure that the calculated position of the road for where to put the car matches the drawn position of the road. Or is there some kind of API into the spline data that can just tell me where the edges / centre / normals to the centre of the road are at any arbitrary point along it?

Link to comment
Share on other sites

  • Solution

You can get the GeNa Curves for a spline, using Spline.GetTrees(). That will return a dictionary of List<GeNaCurve>'s.  These list each represent the curves between intersections or dead ends. 

You can get a GeNaSample at some distance along a list of curves also, using Spline.GetSampleAtDistance(distance, geNaCurvesList);

You can Find the other curves that share an intersection node using Spline.GetConnectedCurves(node);

A GeNaSample, as well as the GeNaCurve, has a tangent and a right vector which can be used to determine an offset from the center of the road (spline).  If your road has lane centers that are 1.5m wide then sample.Location + sample.Right * 1.5f would give you that position, or use -sample.Right for the other side of the road.

GeNaSpline uses cubic curves, where a GeNaNode represents the position, and GeNaCurve refers to two GeNaNodes, whose location(s) are the P0 and P3 of the cubic curve. P1 and P2 are stored in the GeNaCurve which can also be accessed as StartTangent and EndTangent, respectively, for relative tangent vectors.

Edit: Note that you could store the cubic spline data in your own format by getting the GeNaCurve.P0, P1, P2, P3 data and apply your own code to them. They are common cubic Bezier curve data.

To further extrapolate on the way the data will be returned by Spline.GetTrees(): each Curve List will contain curves where the end node of the one will be the same as the start node of the next in the list.

Let me know if I can be of more assistance.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...