Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: Rigid spline converter

  1. #1
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Rigid spline converter

    .rigid_spline files are used by NTW and ETW to determine borders, rivers and roads. On request, I wrote a simple tool that converts these files to and from text files that you can edit a bit more easily. More specifically, a spline in ETW/NTW language is a line from a starting point, to an end point, going through a variable number of intermediate points, with straight connections between each point and the next being drawn.

    I'm sorry that I can't provide anything more sophisticated right now but I've got enough things to eat my time and this is far from being a high priority thing for me.

    To convert splines, install python 3.0, make a new folder, copy all splines you want to convert into it, extract the archive to the same folder, then run "convert_all_splines_to_text.bat". This will output a text file for each spline which you can edit however you wish.

    You can add new points by adding lines. The numLines entry is just an FYI (not used when reconverting). To reconvert, simply rum "convert_all_text_to_splines.bat". This will overwrite any existing files so be careful. Then put them in the game borders folder and see what happens.


    Changelog

    1.1

    Added a precision command line option for the spline to text conversion. Usage: "python convert_splines.py -sa -N" where N is the precision. Defaults to N=3



    Usage Example

    0. Make sure you have Python 3.x installed. You can get it at http://www.python.org. If unsure, simply download and install the newest version. You also have to add python to your PATH environment variable for this to work correctly. To do this, open the Control Panel, then System, navigate to the Advanced tab and click on Environment Variables. Look for the one called PATH and add your python installation directory to it, separated with a semi-colon ";" from the previous entry (for me it's "C:\Python31")

    1. Create a working directory somewhere, paste the border files into it, then extract the attached rar archive into it.

    2. Navigate to your NTW/data/campaign_maps/nap_europe/display/borders directory. Select and copy the rigid_spline files you want to edit (for example eur_scotland_1.rigid_spline). Make sure you create a backup of the files you're planning to change in case you screw something up.

    3. Run "convert_all_splines_to_text.bat" to convert all .rigid_spline files to text files.

    4. Open the file you want to edit first with a text editor, notepad for example, and do any changes you like. The first few lines contain some header entries of which I'm not sure what they do, so don't edit them.

    The rest of the entries consists of 3d points: three coordinates for each point of the spline. The first coordinate is the horizontal east-west coordinate (east is positive, west is negative) - I'm not sure in what units. The third coordinate is the north-south coordinate (north is positive). The second coordinate is probably the height above ground: it seems to be the same for all borders - but I don't think it's used at all.

    You don't have to update numEntries if you add or remove lines, the converter will recalculate it automatically and it's just there for your information.

    5. Once you're done with your changes, save the file. Then run "convert_all_text_to_splines.bat". This will overwrite your old spline file with your changes (you can verify this by the checking the timestamp changes when running the converter).

    6. That's it, copy the file back to your borders directory and have a look at the results in your game. I added a point before the first in Scotland's border with some more exotic coordinates and this is the result:



    Have fun!
    Last edited by alpaca; May 23, 2010 at 04:36 AM.

    No thing is everything. Every thing is nothing.

  2. #2
    Inevitability won
    Patrician Citizen

    Join Date
    Mar 2010
    Posts
    9,594

    Default Re: Rigid spline converter

    Dam very nice indeed!

    Although I fear for a lot of people (like me) a tutorial will have to be created by the community before attempting this.

    None the less very good stuff.

  3. #3
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Rigid spline converter

    Quote Originally Posted by ♔Mitch, Your humble servant♔ View Post
    Dam very nice indeed!

    Although I fear for a lot of people (like me) a tutorial will have to be created by the community before attempting this.

    None the less very good stuff.
    Yeah I'll write one later, it's not difficult.

    No thing is everything. Every thing is nothing.

  4. #4
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Rigid spline converter

    Ok, tutorial/example added.

    No thing is everything. Every thing is nothing.

  5. #5
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: Rigid spline converter

    I just cannot get this to work.

    I installed python 3.1.2 to c:\Python31
    I made a folder on my desktop called splines and put the scotish spline, the batch files and the script in it.
    I double clicked the correct patch, command prompt flashes up but no text file appears.

    Any ideas?
    Last edited by The Hedge Knight; May 22, 2010 at 01:48 PM.

  6. #6
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Rigid spline converter

    Quote Originally Posted by Josst View Post
    I just cannot get this to work.

    I installed python 3.1.2 to c:\Python31
    I made a folder on my desktop called splines and put the scotish spline, the batch files and the script in it.
    I double clicked the correct patch, command prompt flashes up but no text file appears.

    Any ideas?
    Try to open a command prompt using start->run->cmd, then navigate to your working directory and run the batch file using the command prompt. This will make the screen stay so you can tell me what it says.

    No thing is everything. Every thing is nothing.

  7. #7
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: Rigid spline converter

    No, i just found the problem, turns out i needed to set python as an enviromental variable.

    Now it works great. I was getting
    'python' is not recognised as an internal command,operable program or batch file.
    Thanks again though.

  8. #8
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Rigid spline converter

    Quote Originally Posted by Josst View Post
    No, i just found the problem, turns out i needed to set python as an enviromental variable.

    Now it works great. I was getting

    Thanks again though.
    Ah yes, I forgot that. Will put it in the first post.

    No thing is everything. Every thing is nothing.

  9. #9
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: Rigid spline converter

    How simple would it be to make it round make the script three decimal places, it seems the borders are always >0.001 apart. If its not possible i fully appriciate that.

  10. #10
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Rigid spline converter

    Quote Originally Posted by Josst View Post
    How simple would it be to make it round make the script three decimal places, it seems the borders are always >0.001 apart. If its not possible i fully appriciate that.
    Pretty simple. The script simply prints the next float to the precision it's defined as. When you change something, you don't have to use the same precision, you can use any number of decimals. 8 works fine, 8.2 works fine, 8.24672573628934 works but there will be some decimals discarded. I replaced it with a version that exports to 3 decimals by default, which can be overridden by using a command line option -N after the flag: "python convert_splines.py -sa -5" will write 5 decimals

    No thing is everything. Every thing is nothing.

  11. #11
    Hazbones's Avatar Senator
    Join Date
    May 2007
    Location
    Iwakuni, Japan
    Posts
    1,104

    Default Re: Rigid spline converter

    So if you change the spline what effect does it have in game? Does the game recognize that a border change was made?

  12. #12

    Default Re: Rigid spline converter

    Excellent as always!

    I've got a request in another post but i repeat it here:

    Alpaca, though I know you have not much free time, it would be crucial to make your startpos searching tool also for poi and pathfinding esf files.

    Also any guess in answering these questions are welcome.
    EDIT: rigidmodels\campaignborders\ is not usefull at all in Napoleon.

    EDIT: Since all numbers in all file are small numbers e..g. 8.xxx, 6.xxxx, 12.xxx, could they mean distance from a certain point,? And what this could be, settlement?
    Last edited by husserlTW; May 23, 2010 at 10:12 AM.




  13. #13
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: Rigid spline converter

    I dont know, have you noticed that all the splines are also contained in rigid_models leading me to wonder what those are for.

    Also the balearic isles seem to be missing and im wondering if thats because they have no borders.
    Last edited by The Hedge Knight; May 23, 2010 at 09:02 AM.

  14. #14

    Default Re: Rigid spline converter

    Quote Originally Posted by Hazbones View Post
    So if you change the spline what effect does it have in game? Does the game recognize that a border change was made?
    Afaik, the effect is only visual. The "real" borders are in the esf files. The next step is matching the values in the splines to values in regions.esf, the startpos, etc.

  15. #15
    Hazbones's Avatar Senator
    Join Date
    May 2007
    Location
    Iwakuni, Japan
    Posts
    1,104

    Default Re: Rigid spline converter

    Quote Originally Posted by Josst View Post
    I dont know, have you noticed that all the splines are also contained in rigid_models leading me to wonder what those are for.

    Also the balearic isles seem to be missing and im wondering if thats because they have no borders.
    There are db tables that refer to the rigid_model files. The rigid_models are the actual model and the db entries just tell the game which model to use.

  16. #16
    Hazbones's Avatar Senator
    Join Date
    May 2007
    Location
    Iwakuni, Japan
    Posts
    1,104

    Default Re: Rigid spline converter

    Quote Originally Posted by erasmus777 View Post
    Afaik, the effect is only visual. The "real" borders are in the esf files. The next step is matching the values in the splines to values in regions.esf, the startpos, etc.
    And also I assume matching all that to the POI esf so that the AI knows where everything is. Man, CA wasn't joking when they said it took a team of phd's to put this monster together (and yet no PHD's are reverse-engineering the whole thing to my knowledge unless Erasmus or Alpaca has one they are not telling us about).

  17. #17
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Rigid spline converter

    Quote Originally Posted by husserlTW View Post
    Excellent as always!

    I've got a request in another post but i repeat it here:

    EDIT: Hey guys have you noticed that there are the same spline files as in ETW (at least the names)? For example there is no Balkan for the region that exists in Napoleon but there are Bosnia and Serbia which exist in ETW but not in Napoleon. Is there probably another file that determines which and how splines will be used in campaign's map creation?

    EDIT2: Since all numbers in all file are small numbers e..g. 8.xxx, 6.xxxx, 12.xxx, could they mean distance from a certain point,? And what this could be, settlement?
    The NTW borders aren't in the pack but in the campaign maps folder for the map (this was presumably easier because NTW has a number of completely disjoint maps rather than all maps sharing the same worldmap), I think the ETW files in rigidmodels are unused remains.

    Quote Originally Posted by Hazbones View Post
    And also I assume matching all that to the POI esf so that the AI knows where everything is. Man, CA wasn't joking when they said it took a team of phd's to put this monster together (and yet no PHD's are reverse-engineering the whole thing to my knowledge unless Erasmus or Alpaca has one they are not telling us about).
    A PhD doesn't make you more intelligent. I don't have one (yet?)

    Quote Originally Posted by Josst View Post
    I dont know, have you noticed that all the splines are also contained in rigid_models leading me to wonder what those are for.

    Also the balearic isles seem to be missing and im wondering if thats because they have no borders.
    If you have no borders you need no spline. As for the rigidmodels, see above.

    Quote Originally Posted by erasmus777 View Post
    Afaik, the effect is only visual. The "real" borders are in the esf files. The next step is matching the values in the splines to values in regions.esf, the startpos, etc.
    I'd also guess that the borders are visual only. There's no simple or sensible way for the game to determine a unit crosses one of these borders, for example. My money's on regions.esf

    No thing is everything. Every thing is nothing.

  18. #18
    The Hedge Knight's Avatar Fierce When Cornered
    Artifex

    Join Date
    Oct 2009
    Location
    England
    Posts
    5,875

    Default Re: Rigid spline converter

    Well i have done some experimentation and came up with this by plotting three splines on a graph.

    Seems the map in spline terms is slighly irregular.

    -10>x>8.55
    -4.6>y>4.6
    Last edited by The Hedge Knight; November 09, 2012 at 11:41 AM.

  19. #19

    Default Re: Rigid spline converter

    Great work.

    Does this tool work for Arabian Peninsula and East side of Caspian sea since they are already included in the map in ETW so we can add some regions maybe there if this tool is for arranging borders?

  20. #20
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Rigid spline converter

    Quote Originally Posted by AmiR TimuR View Post
    Great work.

    Does this tool work for Arabian Peninsula and East side of Caspian sea since they are already included in the map in ETW so we can add some regions maybe there if this tool is for arranging borders?
    I don't think changing the borders has any gameplay effect, it's purely visual.

    No thing is everything. Every thing is nothing.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •