Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
splines from .txt files
#1
Question 
Hi, I am having a great time making splines manually.
I want to make splines automatically from txt files, though, cos some are really huge.
I am very new to C#, but I want to use curvy like this:

1. drop a txt file into the editor of a CurvySpline
2. ask Curvy to make new control points specified by each line in the txt file

I want this to happen in the editor, not instantiate in gameplay.
I have alot of splines to work with, so this is pretty important to me.
I could drop each txt file onto a new CurvySpline, but if I could drop a folder onto a CurvySplineGroup that would be even better.
In the end, the goal is to have a bunch of different splines defined by txt. I could put each spline in the same txt file instead of separate ones, if that is easier.
So far they are all separate txt files.

This is my broken code idea so far for dropping a txt file into a CurvySpline:

//i think this script goes in a folder called "Editor"
//i think this is how you make things happen in the Editorvsruntime

using UnityEditor;
using System.Collections;

public class read_vector : MonoBehaviour
{
        //drop text asset here in editor:
    public TextAsset track

        //read text asset as string:
    static void Create() //not sure if should be hereguessing

        //print(track.text); (prob dont need this)
        string fileRead = track.text;
    

        //read file as separated by return lines and number each
        string lines = fileRead.Split("\n"[0]);
        float int i = Parse(pt[0]);
        vectors = new Vector3[lines.Length];
        for (int i = 0i < lines.Lengthi++)

        //read each line and label "xyz"
        string ()()() lines = fileRead.Split (","[0])
        float int x = Parse(pt[0]);
        float int y = Parse(pt[1]);
        float int z = Parse(pt[2]);

        //i think i need some way to associate each vector 3 with each line
        //maybe with the same int variable like x(i), y(i), z(i)?

        //create new curvyspline control point with vector x,y,z for each line
        vectors [i] = new Vector3 ("x","y","z")
        CurvySpline.Add.(vectors [i])
        
        

        //stop when there are no more lines


    }
}


My text files look like this:


-4.096196175 13.23249722 49.63834381
-4.012486458 13.07298183 49.5514679
-3.953039408 12.89356709 49.48607635
-3.910502434 12.70170784 49.44891739
-3.84428215 12.51645088 49.41293716
-3.742287636 12.34783459 49.37879944
-3.630933762 12.1874485 49.33547974
-3.524027586 12.02439499 49.2909317
-3.40421176 11.87058163 49.24637222
-3.317773581 11.6994257 49.18950272
-3.231610537 11.52034092 49.16704178
-3.151533842 11.33750439 49.17963409
-3.047248125 11.16755295 49.16411591
-2.970181704 10.98312473 49.17096329
-2.896412134 10.80042648 49.20530319
-2.829617023 10.61301899 49.22572327

etc etc etc

Any advice is welcome. I am a dedicated learner.
I see much potential in this plug in, but I am not sure how to get it to do what I want yet.

Thanks <3,

Lila

 

 

 

 

 
Reply


Messages In This Thread
splines from .txt files - by Lila - 04-30-2014, 01:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 1 2 2 hours ago
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  Using Unity's SplineContainer in Curvy Splines dlees9191 3 15 02-26-2024, 09:49 AM
Last Post: _Aka_
  Distance travelled across multiple splines jh092 1 7 02-23-2024, 09:44 AM
Last Post: _Aka_

Forum Jump: