Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import splines from GeoJson
#1
Hi there,

I am trying to import splines from a Geojson file to create real world roads. 
I am not sure if Curvy can support geojson because I have seen it can import json files.
Also, I got this kind of error when I imported.

"Your text reached the limit of 15000 characters. Current characters count is ..."

Anyway to avoid this problem?
Reply
#2
Hi,

About the 15000 limitation, it is as the warning message says due to avoid Unity's "String too long for TextMeshGenerator" error. This error is related only to the displayed string in the import/export window. This should not impact the imported content if you import from a file.

The format used by Curvy in import/export is a custom format based on JSON made for ease of use in mind. It is not a standardized format. Its goal was to allow to easily save/mass edit/load/share splines.

Things were done in a way to allow to users to easily integrate their needed format, as long as it is a JSON based format.
Curvy defines the JSON wrappers expected in the SerializedCurvySplineSegment and SerializedCurvySpline classes in Curvy\ImportExport\Wrappers.cs. You can modify these classes to be able to deserialize your own JSON based format, as long as your spline (SerializedCurvySpline ) is defined as an array of control points (SerializedCurvySplineSegment)

Here is an example of a spline with two control points:
Code:
{
   "Array": [
       {
           "Name": "Curvy Spline",
           "Position": {
               "x": -30.329999923706056,
               "y": 37.90800094604492,
               "z": -14.991999626159668
           },
           "Rotation": {
               "x": 0.0,
               "y": 0.0,
               "z": 0.0
           },
           "Interpolation": 1,
           "RestrictTo2D": false,
           "Closed": false,
           "AutoEndTangents": true,
           "Orientation": 1,
           "AutoHandleDistance": 0.38999998569488528,
           "CacheDensity": 50,
           "MaxPointsPerUnit": 8.0,
           "UsePooling": true,
           "UseThreading": false,
           "CheckTransform": true,
           "UpdateIn": 0,
           "ControlPoints": [
               {
                   "Position": {
                       "x": -30.329999923706056,
                       "y": 37.90800094604492,
                       "z": -14.991999626159668
                   },
                   "Rotation": {
                       "x": 0.0,
                       "y": 0.0,
                       "z": 0.0
                   },
                   "AutoBakeOrientation": false,
                   "OrientationAnchor": false,
                   "Swirl": 0,
                   "SwirlTurns": 0.0,
                   "AutoHandles": true,
                   "AutoHandleDistance": 0.38999998569488528,
                   "HandleOut": {
                       "x": 1.0,
                       "y": 0.0,
                       "z": 0.0
                   },
                   "HandleIn": {
                       "x": -1.0,
                       "y": 0.0,
                       "z": 0.0
                   }
               },
               {
                   "Position": {
                       "x": -26.718000411987306,
                       "y": 37.90800094604492,
                       "z": -16.320999145507814
                   },
                   "Rotation": {
                       "x": 0.0,
                       "y": 0.0,
                       "z": 0.0
                   },
                   "AutoBakeOrientation": false,
                   "OrientationAnchor": false,
                   "Swirl": 0,
                   "SwirlTurns": 0.0,
                   "AutoHandles": true,
                   "AutoHandleDistance": 0.38999998569488528,
                   "HandleOut": {
                       "x": 1.0,
                       "y": 0.0,
                       "z": 0.0
                   },
                   "HandleIn": {
                       "x": -1.0,
                       "y": 0.0,
                       "z": 0.0
                   }
               }
           ]
       }
   ]
}

Not all fields are mandatory

Did this post answer your questions?
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Hi Aka,

Thank you for your reply. I think this helps a lot. However I just have few more questions, and hope you don't mind to answer.

1. I applied different materials to Path Line Render, but how do I show different materials for different segment. I tried apply MetaCGOptions(It has material IDs) to control points, but it doesn't work.
*Edit - I figure out that you were using Unity Line render, so I don't think it support different materials for different segments at this point. What I am trying to achieve is I am making a traffic control game, and I want to show traffic speed for different parts. (Like google map/ Waze). The roads doesn't need to be a real 3D mesh, it can be just a polygon face for each segment.


2. Also, because real world data to Unity, and the position seems become very small between each control points. The line render only render one straight line now because of "Cache Density" and "Max Points per Unit". Anyway you think can help to render lines in small scale?

Thank you again for your help here!
Reply
#4
Hi

1- Indeed MetaCGOptions is not used by a line rendrer, but used by the Curvy Generator (CG for short), and specifically the shape extrusion module. More about this here
https://curvyeditor.com/documentation/ge...#materials
The material id can vary through the extruded shape, but does not vary along the extrusion's path. So this is not what you need*. What you need is to have multiple shape extrusions, each one with a different material on a different section of the path. For more details, see the Range property
https://curvyeditor.com/documentation/ge...sion#range

*You can se how material id is used in various example scenes. It is for example used to make the rail track have different materials, the metal one and the dirt one
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
2- Max out Cache Density (a value of 100) and then set the value of Max Points per Unit (MPU for short) to your liking and it should work, if not then it is a bug. For example if you want a cache point every millimiter, set MPU to 1000.
If you still have an issue, please give more information about the used values and distances in your project
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  How make a new connection between splines ? adeel_hamza 2 113 11-13-2019, 11:09 PM
Last Post: _Aka_
  Train Manger - multiple Trains and Splines teamteam 1 96 11-12-2019, 02:07 PM
Last Post: _Aka_
  Create splines at runtime: correct initialization Josenildo 3 219 10-31-2019, 06:50 AM
Last Post: _Aka_
  3ds max import? turbo 9 6,155 09-16-2019, 01:36 PM
Last Post: _Aka_

Forum Jump: