Jump to content

Trains in FSX Possible?!


the_pc_pilot

Recommended Posts

Hey people,

 

I was reading about ways to add trains to FSX, and the general suggestion was to model a car like a train and then have it drive a road that would be created along a train track. The other option was to use something in the 'animal' catagory, which would follow the railroad tracks, but it turns out that the 'box' in which they are animated is only so big. Also, it wouldn't be very fun watching a train, several hundered meters long turn a corner...

 

So i came up with this; the road thing would work fine because you could model each traintrack car as an individual 'car' instead of doing it as one long thing. So would it be possible to allow them to come onto the tracks as seperate entities, close together, but in the right order?

 

If you have any ideas or are even considering trying this (as i will if i can get enough information on how the game works) please comment :)

 

the_PC_pilot

Positive rate, gear up.

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Hi,

 

interesting idea. How accurate and realistic do you want this to be?

 

Here is a possible solution:

 

First thing would be to get an accurate train track profile of those that are actually present in the sim. This should be possible by analyzing the scenery (vector) BGL data and generating a file - a lot like makerunways does. This has to be done in advance, as it is not really possible to gain this static information from the sim at runtime.

 

Next you write an addon that uses SimConnect to move any objects you desire along these tracks. Probably best to limit them to the reality bubble.

 

After that, you "only" have to figure out how and when the trains should be running, either at random or with precompiled schedules like AI does. You could probably build this up to a point where you are using the sim as a virtual model train set.

 

As of development effort, if you are proficient in C++ or C# and the SimConnect API you should be able to slap something together in about two weeks time.

Link to comment
Share on other sites

Wow, thanks. And in answer to your question, well, it is FSX, so no more realistic than the little cars we see are.

So let me see if I get what you mean:

Get vectors for where railways would be, as in, the actual locations in the format that the game uses.

 

Next up, program the trains, which will be 'simobjects' to move along the vectors designated. I'd probably want them running on precompiled schedules, like the AI, so that there aren't any overlaps with trains.

 

Tell me if I got that right,

Thanks a lot, this is more programming than i know, but i'm sure it is possible if I can find time for it.

Positive rate, gear up.

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Hi,

You got that right.

 

I would do it this way:

1. Use CVXExtractor to look at the actual format of the railways vector data

2. Figure out a way to make use of this data, i.e. if it is possible to transform it into lat/lon based waypoint lists.

3. Write a small prototype in C# that reads this file, compiles a list and lets an object run along it that is already there (can be anything really).

4. Take it from there... depending on how this works out, you will know how to pre-process the vector data to actually make it useful and how to move the objects to make movement practical and smooth (there are a lot of limits in the SimConnect API one would have to work around).

 

Take a look at the two AI Waypoints samples in the SimConnect SDK documentation, those will give you the right idea. If you get stuck, drop me a PM. Coding SimConnect stuff is my speciality ;)

Link to comment
Share on other sites

All right, I'm in CVXExtractor, but how do i know which BGL is for which part of the world? I was thinking of using a place like the netherlands or france for experimentation because they have a lot of railways, but i need to know which BGL I actually need to analyze...

 

I tried random BGLs but none gave any results for railroad vectors... hmm...

 

Edit: Found one, located C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Scenery\1003\scenery cvx8024.bgl

 

Right, i guess I'll have to use TMF Viewer to find the right sections, that means i need to get the SDK installed on this computer.

Positive rate, gear up.

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Hi,

 

- I looked for the right files with ADE by providing a nearby airport ICAO and then selecting the CVX that matched the APX numerically as close as possible.

 

- I then decompiled it into XML format, as this is very easy to use and parse programmatically.

 

- Next I typed a small SimConnect client, that reads the XML and uses the vector data as waypoints for trucks.

 

2015-11-11_18-53-36-570.jpg

 

2015-11-11_18-53-52-346.jpg

 

A few observations:

 

- The railroad tracks are not joined together, the vector data just provides bits and pieces of the whole track

- Because of this, trucks sprung up in any odd places and did strange things

- As as proof of concept this works, but it needs a lot of thought until it will be usable.

 

The next step would be

 

- to use some geographical functions to link the lists together at matching waypoints, so that the trucks/trains pass over longer stretches of tracks at a time.

 

- then see to it, that depiction get limited to the reality bubble. The trains probably have to appear and disappear like the cars do, but should "live" longer.

 

- After that, one has to think about acquiring the data, a recursive algorithm is needed to parse through the scenery library, select all vector data it can find and extract it in XML format. (basically re-invent the CVXExtractor, but limited to railways).

 

Oliver

Link to comment
Share on other sites

Edit: Holy cow, this works. I joined the tracks together, and although some joints are not right, I spent this evening train spotting and following a string of trucks through the mountains sticking to the train tracks like glue...

 

2015-11-11_20-9-18-571.jpg

 

2015-11-11_20-9-34-845.jpg

 

2015-11-11_20-13-9-183.jpg

 

2015-11-11_20-13-50-368.jpg

 

2015-11-11_20-14-44-826.jpg

Link to comment
Share on other sites

What you guys are doing is interesting stuff and beyond my understanding but keep it up and good luck....Someday your ideas could be a great payware for those of us who love scenery..al v

 

Thanks, though so far it's mostly Oliver's work!

Positive rate, gear up.

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

WOW! that's awesome! I didn't have time to work on anything, but i see you've gotten it worked out allready! The question is, can different trucks be made to appear in a certain order and close together enough to resemble trains? Awesome work!

Positive rate, gear up.

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

There are some engine and boxcar models here in the library, the trick is to dispatch them closely enough.

 

I cannot invest that much time right now, but as soon as I can, I will continue with this. Will have to think about the whole approach some more and expand the prototype - there will be a ton of stuff that needs working out or tweaking.

Link to comment
Share on other sites

Yeah, i had thought of going into the library, but of course, to use others' boxcar models you need their permission. They probably also are fairly detailed models, which, if you want a lot of them, might be a FPS eating machine! Do you know of a whay to convert sketchup models to .MDL files with the SDK? If so, i could just make some models with a lower amount of detail, and with matching quality.

 

Another note, the railway texture in FSX is just a blank line, yours shows two rails (ORBX I suppose,) but if we're only going to run one train on vector, we need to re-do the railway texture to only have one. The other thing would be to do two on one vector running side by side, or, preferably, in opposite directions. The FSX highway is only one vector, i remember from using a scenery tool, (i think SBuilderX313) I never actually compiled anything tho!) but has multiple rows of cars going opposite directions.

Positive rate, gear up.

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Hi,

 

as long as you do not distribute the models with the new tool, you shouldn't have legal issues here. I'd leave this to the user to acquire and choose his own models as he sees fit.

 

For converting Sketchup or others into FS-digestable MDL you can use ModelConverterX.

 

Now for the hard part, the "joining and running" - this is all internal program logic of my prototype. Basically I read the XML, compile waypoint lists from them and join these together by recursively comparing all start- and endpoints if they are either identical or very close together. Then I join the waypoint lists at that junction into a new one. After that it is just creating the sim objects and sending the waypoint list to them. There will be trouble here, as the number of waypoints the sim can digest is limited, so there needs to be some throttling mechanism (like reducing trains actually running to the reality bubble).

 

As for single/multiple tracks etc.: TBH I don't know what is installed in my sandbox simulator where I took the screenshots. I always thought that one was vanilla FSX SE, but there is no telling now if at some point I installed some texture replacement. This one is only for development and testing stuff, sorry. The level of accuracy and things like trains running opposite on the same track will be developed as I go ahead. Program logic wise there is nothing to it, it is more the sim performance I am concerned about.

Link to comment
Share on other sites

Well, I think what you've done so far is amazing allready, and is nothing i think i could do!

 

No worries. Send me a PM through the forum here if you like, and I will "DropBox" you the prototype binary to play around with. I will be revisiting the trains on and off, but right now I am in the middle of the next version of my fire fighting product and this has to take precedence, I'm afraid.

 

Cheers

Oliver

Link to comment
Share on other sites

Hi,

 

couldn't resist it, even if I should.

 

This is what it looks like right now:

 

TrainRunnerX.jpg

 

I was using a train collection out of the library here (train models for "FSX@WAR") and let them loose in northern Sardinia. Unfortunately they still are very disjointed, even when the depiction timeout is turned way down (at least in the mountains where I tested it - it can even happen that the engine is overtaken by the coaches). I am not sure if this can be cured, at least not unless the models themselves are altered (acceleration and speeds, size - larger coaches/engines turn slower than smaller ones). So maybe this is not going to be really usable, more like a gimmick.

 

2015-11-12_18-26-34-226.jpg

 

2015-11-12_20-7-14-153.jpg

 

2015-11-12_20-10-55-270.jpg

 

2015-11-12_20-11-1-194.jpg

 

2015-11-12_20-11-58-111.jpg

 

Oliver

Link to comment
Share on other sites

Interesting work and I commend you for it! However I've noticed the biggest complaint on FSX boards for some time has been slow frame speeds per second.

 

Won't putting all these additional vehicles into place and then putting them in motion bring FSX to a halt? Or do you know some techniques the rest of us haven't figured out yet? I'm hoping the latter is true!!

Being an old chopper guy I usually fly low and slow.
Link to comment
Share on other sites

Is it just that program you showed a screenshot of doing all the work, analysing the tracks, connecting them, and also running the trains?

Meaning anyone running it would get the result.

Or is that program built around your database, and not easy to transfer to others.

 

Btw, I think you are being to hard on yourself.;) It looks great! So much better then having empty tracks!

[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

Interesting work and I commend you for it! However I've noticed the biggest complaint on FSX boards for some time has been slow frame speeds per second.

 

Won't putting all these additional vehicles into place and then putting them in motion bring FSX to a halt? Or do you know some techniques the rest of us haven't figured out yet? I'm hoping the latter is true!!

 

Hi Rupert,

 

This has not gone far enough to do performance tuning. But I did a short test just now, with FSX:SE running in windowed mode - no addons that I am aware of. Placed the Trike at stock LIEO, standard fair weather model. I am running unlimited because I need to know how the sim keeps up internally. Edit: system specs: i7 3770k @4,5

 

- FSX:SE without the TrainRunnerX: fluctuating 100-110 FPS

- generating 500 engine and coach models, letting them run along their tracks: 80-90 FPS

- generating another 500 different models: 70 FPS

- generating another 500 different models: 60 FPS

 

At that point I stopped, I had 1500 single models running and no appreciable difference in fluidity in the sim. Of course I will never see all those models at once, and flying over one (or even 10) of these train models did not make any difference either.

 

But you are right of course that load needs to be limited. I keep thinking I will restrict it to the reality bubble, maybe even less. We will see when we get there.

 

BTW there wasn't much figuring involved on my part. I always try not to force the sim to do things it does not want to do (or doesn't do well). The train model library that I found seems to be very light on FPS too. You would have to get it from the library here as I cannot re-distribute it, just search the FSX section for "train" - it is the one for fsx@war.

 

You can try it for yourself if you want - just drop me a PM.

 

Cheers

Oliver

Link to comment
Share on other sites

Is it just that program you showed a screenshot of doing all the work, analysing the tracks, connecting them, and also running the trains?

Meaning anyone running it would get the result.

Or is that program built around your database, and not easy to transfer to others.

 

Btw, I think you are being to hard on yourself.;) It looks great! So much better then having empty tracks!

 

Hi il88pp,

 

the program uses an output file generated by CVXExtractor. The user needs to locate the correct CVXzzzz.BGL in the scenery library and extract the railways into the XML output format. This is pretty straight forward to do with CVXExtractor (GUI version) - the hard part is to find the CVX file in the sim that you want. (At a later date I will look into a searching and parsing method.)

 

The rest is done by the TrainRunner X, it reads the XML, joins the tracks and gets the rolling stock on the rails. Anyone can do this. I have an XML ready for northern Sardinia that I can provide with the program (I got lucky and found the CVX right away).

 

But it really is far from perfect, there still is a lot to do. And it may never amount to anything "perfect" either, as the sim is limited - as we all know.

 

But I have to admit, it is quite fun to go train spotting in a helicopter... Did that all evening ;)

 

Cheers

Oliver

Link to comment
Share on other sites

Thank you. That sounds like something I may eventually understand, lol.

About the cvx file, does this mean it only applies to one limited region (cvx file) at a time?

Or can you attach several of those extracted .cvx files together int a larger area.

 

(I never looked at cvx files, not sure what would be in them. Vector data for a limited area I suppose.)

[sIGPIC][/sIGPIC]
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...