360° tracklaying prototype
360° tracklaying prototype
Today I created a prototype about a possible 360° tracklaying mechanism.
Just download the attached .zip file, and unzip.
It's a java program, so it should work on all pc's with a java virtual machine installed. For windows : just double-click "run.bat". For others: type "java TE3DTracks" in a console window.
I also attached a screenshot.
The red lines represent track-sections, of any arbitrary length and direction. The red text next to them is their length.
I plan to add the functionallity to pick a start-point + start-direction and an end-point + end-direction and have the program automaticly create all the necessary sections. This is not implemented yet. For now, the easiest is to click "add section row", then choose a starting point, then go on clicking to add sections. If you want to startr a new row, just hit the button again.
Just download the attached .zip file, and unzip.
It's a java program, so it should work on all pc's with a java virtual machine installed. For windows : just double-click "run.bat". For others: type "java TE3DTracks" in a console window.
I also attached a screenshot.
The red lines represent track-sections, of any arbitrary length and direction. The red text next to them is their length.
I plan to add the functionallity to pick a start-point + start-direction and an end-point + end-direction and have the program automaticly create all the necessary sections. This is not implemented yet. For now, the easiest is to click "add section row", then choose a starting point, then go on clicking to add sections. If you want to startr a new row, just hit the button again.
- Attachments
-
- TE3DTrack001.png (9.75 KiB) Viewed 5248 times
-
- java 3d tracks.zip
- (17.75 KiB) Downloaded 904 times
Nice to see, althroght my Downloads directory got a bit messed up as all files were directy extracted to my Downloads folder, and not to a sub folder with a suitable name. Probably I was to lasy as only 1 of 50 tar/zip files that I open (excluding my own arcives) dont have a directory where all files are in. Anyway its nice to see that you are doing some nice work.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Ok, I'm working on this prototype again, but I have a problem:
On the previous meeting I told you I was planning to add more features:
This last point is giving me some trouble. One solution I see, is to allow all angles/radiusses when building the track, but give the user a clear visual clue to know which tracksection can be reached from the new one he is trying to place. So, for example, the vertical track below is existing track, somebody tries to place a junction like in the ASCII below. It is clear trains from/to the junction can only move to/from the upper part and not the lower part of the vertical track:
So, how can we give the user a visual clue about this? I thought of maybe colouring the existing section going down in red and the existing section going up in green.
Any other ideas or simpeler solutions ?
On the previous meeting I told you I was planning to add more features:
- To make it easier to use:
- you see which point you will click on when you move the mouse around.
- you see the tracksection you are about to lay when you move the mouse around.
- To implement some restrictions about which tracksections you are allowed to place:
- minimum and maximum tracksection length. This is easy, and consider it done.
- minimum and maximum angle / radius. This is difficult, for 2 reasons:
- Calculating the radius for the circle through 3 points is not a simple formula : This is purely calculation related, and we might use an aproximation instead of the perfect value for more speed.
Code: Select all
radius = sqrt { [ (y1-y2)² + (x1-x2)² ] * [ (y2-y3)² + (x2-x3)² ] * [ (y3-y1)² + (x3-x1)² ] } ------------------------------------------------------------------------------------- 2 * ( x1*y2 - y1*x2 + x2*y3 - y2*x3 + x3*y1 - y3*x1 )
- The second part is worse. This radius/angle restriction is, in essence, not a restriction on the tracksection itself, but rather on the connection points between them. It should be possible to create a 90° crossing, while the trains shouldn't be able to change direction there, this track configuration should be possible to place. Also, as an other example, if you create a junction from an existing line, the new track section has 2 attached sections. If you created the junction in a normal way, the new tracksection should have a "valid" connection with only one of them.
- Calculating the radius for the circle through 3 points is not a simple formula :
This last point is giving me some trouble. One solution I see, is to allow all angles/radiusses when building the track, but give the user a clear visual clue to know which tracksection can be reached from the new one he is trying to place. So, for example, the vertical track below is existing track, somebody tries to place a junction like in the ASCII below. It is clear trains from/to the junction can only move to/from the upper part and not the lower part of the vertical track:
Code: Select all
|
|
|\
|
Any other ideas or simpeler solutions ?
This sounds good. If you restrict the speed throught tight curves you can color the green part more and more yellow when it becomes tighter. But the contrast between yellow and red have to be clear.PJayTycy wrote:This last point is giving me some trouble. One solution I see, is to allow all angles/radiusses when building the track, but give the user a clear visual clue to know which tracksection can be reached from the new one he is trying to place. So, for example, the vertical track below is existing track, somebody tries to place a junction like in the ASCII below. It is clear trains from/to the junction can only move to/from the upper part and not the lower part of the vertical track:So, how can we give the user a visual clue about this? I thought of maybe colouring the existing section going down in red and the existing section going up in green.Code: Select all
| | |\ |
Nice to see your progress.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
OK, I have uploaded a new version. The min/max length restrictions are in place, the angle/radius restrictions are not.
You also see the new tracksection when moving the mouse around (ie: before clicking).
The downside from this last point is the overhead has increased a lot because everytime you move the mouse around:
You also see the new tracksection when moving the mouse around (ie: before clicking).
The downside from this last point is the overhead has increased a lot because everytime you move the mouse around:
- Track restrictions have to be checked
- The area has to be redrawn
- Attachments
-
- TE3DTrack002.zip
- (19.06 KiB) Downloaded 640 times
Your last improvements seams to work on my computer. I dont have any cpu meter exept my fan, so I cant comment on the cpu usage, exept that it comes hot air from it when i moving around with the mouse.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
I was thinking.. Maybe we/you can add a grid system and optinally restrict to n predefined angles. This will mean that people that want to restrict building to 4 directions can do that, while others have the freedome to build in any degree.
Im sipinning away.. You could either choose per player basis or per game basis which method to use. If you have it per player basis you can have a toggle on the build tool.
Im sipinning away.. You could either choose per player basis or per game basis which method to use. If you have it per player basis you can have a toggle on the build tool.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Well, I'm now in the progress of changing the validation checking to a seperate thread that so the lag when moving the mouse around should be a lot less.
In that "checking thread", you can check for everything you want, so implementing a restriction to 4 (or 8 or 16 or ...) directions is easily possible.
In that "checking thread", you can check for everything you want, so implementing a restriction to 4 (or 8 or 16 or ...) directions is easily possible.
New version is ready.
You can now move the mouse around fluently. The track is drawn in black at first (no checking done yet). When the validation runs, the track will either color green (track = OK) or red (track = not OK).
I added 2 screenshots :
=> in shot a, I try to place a section that is too long.
=> in shot b, I try to place a section that is "right".
Changes
I'll probably start with the angle-checking tomorrow morning. That's a little bit trickier, because I have to modify the appearance of existing tracksections (instead of only the one currently being placed) and I'll need to modify some internal datastructures again. I'm happy this is only a prototype
You can now move the mouse around fluently. The track is drawn in black at first (no checking done yet). When the validation runs, the track will either color green (track = OK) or red (track = not OK).
I added 2 screenshots :
=> in shot a, I try to place a section that is too long.
=> in shot b, I try to place a section that is "right".
Changes
- snap-to is either on or off now (toggle with the right mouse button). No confusion anymore wheter you should click the left or the right mouse button to place some section.
- made the validation multi-threaded (good thing, makes a whole lot of difference)
- added a validation progress checker. Although a little useless now, this will show exactly why a certain piece of track is invallid.
- added a "stop editing" button. If you choose "add section row", you keep adding new sections one after the other. If you want to stop that (ie: you reached the destination), you can hit the "stop editing" button. Most games add this functionallity to the ESC-button, but this is only a prototype after all.
- added internal support for points with 3 coordinates (slope checking), but I'll keep the GUI 2D for now and all points have the same height, so all slopes will be reported as 0%. Just a prototype, you see.
I'll probably start with the angle-checking tomorrow morning. That's a little bit trickier, because I have to modify the appearance of existing tracksections (instead of only the one currently being placed) and I'll need to modify some internal datastructures again. I'm happy this is only a prototype

- Attachments
-
- TE3DTracks011_uncompiled.zip
- uncompiled version
- (10.95 KiB) Downloaded 737 times
-
- section OK
- TE3DTracks011b.png (11.42 KiB) Viewed 4127 times
-
- section too long
- TE3DTracks011a.png (11.34 KiB) Viewed 4122 times
1 more attachment...
- Attachments
-
- TE3DTrack011_compiled.zip
- compiled version
- (31.24 KiB) Downloaded 600 times
-
- Transport Empire Developer
- Posts: 699
- Joined: 03 Feb 2003 09:30
- Location: Back at the office
I can't imagine that checking the length of a segment is such a difficult problem that it needs multithreadedness to keep the application running smoothly.
After all, you only have to check something like
which should easily be done in real-time.
I'll dive into the code later.
Not now, don't have time. I have a text summary of a very boring philosophy book due tomorrow.
After all, you only have to check something like
Code: Select all
minlen^2 =< dx^2 + dy^2 =< maxlen^2
I'll dive into the code later.
Not now, don't have time. I have a text summary of a very boring philosophy book due tomorrow.
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)
[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
Code: Select all
+------------Oo.------+
| Transport Empire -> |
+---------------------+
Under construction...
Nope it doesn't, but checking all the other things too would be too much work. Check the ...002.zip version if you want to see the code of a single threaded version.Hellfire wrote:I can't imagine that checking the length of a segment is such a difficult problem that it needs multithreadedness to keep the application running smoothly.
Updated version.
Now includes angle-checking.
You are unable to place a track that doesn't have atleast one "good" connection (unless it has no connections at all).
"good" connections are coloured based on the angle they make. "bad" connections are coloured red. See the attached picture for an example (I was starting a branch there).
Install instructions again:
Now includes angle-checking.
You are unable to place a track that doesn't have atleast one "good" connection (unless it has no connections at all).
"good" connections are coloured based on the angle they make. "bad" connections are coloured red. See the attached picture for an example (I was starting a branch there).
Install instructions again:
- If you have the java SDK : download the _uncompiled version, unzip and click on "compile_and_run.bat" (or if you don't use windows : type javac *.java [enter] java TE3DTracks in a command window).
- If you don't have the java SDK (or you don't know) : download the _compiled version and click on "run.bat" (or if you don't use windows : type java TE3DTracks in a command window).
- Attachments
-
- TE3DTracks012_compiled.zip
- compiled version
- (38.22 KiB) Downloaded 608 times
-
- screenshot
- TE3DTracks012a.png (11.42 KiB) Viewed 19165 times
-
- TE3DTracks012_uncompiled.zip
- uncompiled version
- (13.69 KiB) Downloaded 491 times
Last edited by PJayTycy on 17 Dec 2004 17:58, edited 1 time in total.
This is starting to looking verry good now. Althroght I think it hanged once. It didn't have to kill it, but it didn't respond to any input exept clicking on the close window button that my window mannager draws. (not your Exit button.) It did hapen when I was trying to add a thrid track section from a point. I succeded to add a third trac section to a point later when I restarted the application.
Good luck with you work.
Good luck with you work.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
I managed to hang it once more.
I used the command from run.bat to start it.
Now nothing happend if i press the cloce button, which is drawn by my window mannager. The window contents is not redrawn.
Ctrl + C works to kill it. No segment fault or such is displayed in the terminal. Actully ther is no aditional output after I press Ctrll + C.
Console output:
I used the command from run.bat to start it.
Now nothing happend if i press the cloce button, which is drawn by my window mannager. The window contents is not redrawn.
Ctrl + C works to kill it. No segment fault or such is displayed in the terminal. Actully ther is no aditional output after I press Ctrll + C.
Console output:
EDIT: this crash happend when I had selected the first point (connected to an existing end point) and was moving around the mouse to find a good second point.TrackChecker constructor started
TrackChecker constructor completed : (-1,-1) - (-1,-1)
newCheck : (50,50) - (50,66) wait = true visible = false
start checking (50,50) - (50,66)
done checking (50,50) - (50,66) maybeValid = true
just before return : (50,50) - (50,66) valid = true
newCheck : (50,66) - (54,81) wait = true visible = false
stop checking (50,50) - (50,66) valid = true
start checking (50,66) - (54,81)
done checking (50,66) - (54,81) maybeValid = true
stop checking (50,66) - (54,81) valid = true
just before return : (50,66) - (54,81) valid = true
newCheck : (54,81) - (62,95) wait = true visible = false
start checking (54,81) - (62,95)
done checking (54,81) - (62,95) maybeValid = true
stop checking (54,81) - (62,95) valid = true
just before return : (54,81) - (62,95) valid = true
newCheck : (62,95) - (73,106) wait = true visible = false
start checking (62,95) - (73,106)
done checking (62,95) - (73,106) maybeValid = true
stop checking (62,95) - (73,106) valid = true
just before return : (62,95) - (73,106) valid = true
newCheck : (73,106) - (81,120) wait = true visible = false
start checking (73,106) - (81,120)
done checking (73,106) - (81,120) maybeValid = true
stop checking (73,106) - (81,120) valid = true
just before return : (73,106) - (81,120) valid = true
newCheck : (81,120) - (85,135) wait = true visible = false
start checking (81,120) - (85,135)
done checking (81,120) - (85,135) maybeValid = true
stop checking (81,120) - (85,135) valid = true
just before return : (81,120) - (85,135) valid = true
newCheck : (85,135) - (85,151) wait = true visible = false
start checking (85,135) - (85,151)
done checking (85,135) - (85,151) maybeValid = true
stop checking (85,135) - (85,151) valid = true
just before return : (85,135) - (85,151) valid = true
newCheck : (85,151) - (85,167) wait = true visible = false
start checking (85,151) - (85,167)
done checking (85,151) - (85,167) maybeValid = true
stop checking (85,151) - (85,167) valid = true
just before return : (85,151) - (85,167) valid = true
newCheck : (85,167) - (81,182) wait = true visible = false
start checking (85,167) - (81,182)
done checking (85,167) - (81,182) maybeValid = true
stop checking (85,167) - (81,182) valid = true
just before return : (85,167) - (81,182) valid = true
newCheck : (81,182) - (73,196) wait = true visible = false
start checking (81,182) - (73,196)
done checking (81,182) - (73,196) maybeValid = true
stop checking (81,182) - (73,196) valid = true
just before return : (81,182) - (73,196) valid = true
newCheck : (73,196) - (62,207) wait = true visible = false
start checking (73,196) - (62,207)
done checking (73,196) - (62,207) maybeValid = true
stop checking (73,196) - (62,207) valid = true
just before return : (73,196) - (62,207) valid = true
newCheck : (62,207) - (48,215) wait = true visible = false
start checking (62,207) - (48,215)
done checking (62,207) - (48,215) maybeValid = true
stop checking (62,207) - (48,215) valid = true
just before return : (62,207) - (48,215) valid = true
newCheck : (48,215) - (33,219) wait = true visible = false
start checking (48,215) - (33,219)
done checking (48,215) - (33,219) maybeValid = true
stop checking (48,215) - (33,219) valid = true
just before return : (48,215) - (33,219) valid = true
newCheck : (33,219) - (17,219) wait = true visible = false
start checking (33,219) - (17,219)
done checking (33,219) - (17,219) maybeValid = true
stop checking (33,219) - (17,219) valid = true
just before return : (33,219) - (17,219) valid = true
newCheck : (50,50) - (50,50) wait = false visible = true
start checking (50,50) - (50,50)
newCheck : (50,50) - (47,45) wait = false visible = true
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Who is online
Users browsing this forum: No registered users and 13 guests