Implementation Rails

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
#1
Admin edit: There is an updated thread

Name:
Rails
Summary: A library mod that adds rail blocks and different types of minecart
Scope: Mod (extra content)
Current Goal:
  1. Fix some glitches =)
  2. Add new rail blocks, like a detector rail, a powered rail, activator rail.
  3. Add the support for the Signalling mod
  4. Add more types of minecart
  5. Add some gui
  6. Add multiplayer
Phase: Design/Implementation
Curator: Adeon(small-jeeper)
Repository: https://github.com/Terasology/Rails
Current version: 0.3
What has been done:

  1. Block system
  2. Physic of the minecart(with some glitches)
  3. 3d model of the minecart and 3d model of the locomotive
Blocks
Plain

Curve

Switching area for a railroad track

Cross for a railroad track


Video:
 
Last edited by a moderator:

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
#3
Nice! How did you fix / make the smoke particles work ? They stopped working for the charcoal oven Marcin Sciesinski was playing with a while back

Will post that on the social networks :)
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
#4
Nice! How did you fix / make the smoke particles work
Thanks =) I created the "pipe entity" like this:
https://github.com/Terasology/Rails/blob/master/assets/prefabs/pipe.prefab
"Pipe entity" is minecart's child.
Code:
{
    "Location" : {
    },
    "blockParticleEffect" : {
        "spawnCount" : 0,
        "initialVelocityRange" : [0, 0, 0],
        "spawnRange" : [0, 0, 0],
        "destroyEntityOnCompletion" : false,
        "minSize" : 0.1,
        "maxSize" : 0.4,
        "minLifespan" : 0.5,
        "maxLifespan" : 1,
        "targetVelocity" : [0, 10, 0],
        "acceleration" : [0, 5, 0],
        "collideWithBlocks" : true,
        "texture" : "engine:fx_smoke",
        "color" : [0.5, 0.5, 0.5, 1]
    }
}
And I added the code that updates the number and direction of the particles.
https://github.com/Terasology/Rails...ls/carts/controllers/MinecartSystem.java#L359
Code:
 private void showSmoke(MinecartComponent minecartComponent) {
        if (minecartComponent.pipe != null) {
            BlockParticleEffectComponent particleEffectComponent = minecartComponent.pipe.getComponent(BlockParticleEffectComponent.class);
            if (minecartComponent.drive != 0) {
                particleEffectComponent.spawnCount = 20;
                particleEffectComponent.targetVelocity.set(minecartComponent.direction);
                particleEffectComponent.targetVelocity.negate();
                particleEffectComponent.targetVelocity.y = 0.7f;
                particleEffectComponent.acceleration.set(minecartComponent.pathDirection);
                particleEffectComponent.acceleration.y = 0.7f;
                particleEffectComponent.targetVelocity.scale(4f);
                particleEffectComponent.acceleration.scale(2.5f);
                minecartComponent.pipe.saveComponent(particleEffectComponent);
            } else {
                particleEffectComponent.targetVelocity.set(0,0,0);
            }
        }
    }
Will post that on the social networks
Cool! Thanks =)
 

manu3d

Active Member
Contributor
Architecture
#6
Hi Adeon! Nice module you've got (literally!) going on here!

I was thinking about rails in the past few days and I was wondering how hard it would be to generalize them a bit. For example, I'm thinking about rails on the bottom of blocks, to simulate the hanging carriages of a monorail or the moving parts of a crane. In some cases it might even be useful to have "rails" in mid-air, i.e. to simulate the cables holding a cable-car, or "rails" on the -side- of a blocks, which would allow proper lifts.

I guess the whole thing could be generalized to a "Paths" module, providing mechanics and barebone UI (i.e. simple lines in place of rails) which would then be used as a dependency module for higher level modules such as "Rails". These would then provide overriding graphic assets and perhaps constrain item placement, i.e. standard iron railways being allowed only on the top face of blocks.

What do you think?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
#7
In theory "Rails" seem pretty close to "Railings" although I admit that's a stretch :)

Could put all kinds of rails and railings in that module, then put the train itself in a higher level module

It should be very easy to get the rails on different block faces, Adeon ended up including ladders back when he first put some rails together :D
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
#8
Yeah, maybe it's a good idea. And I am taking your idea into consideration:) At the moment I devote much time to the basic elements like a train movement and the general concept of the module. Firstly I want to release something that could be played with:) And after this I will refactor the code and the structure of module. =)
 
#9
Yeah, maybe it's a good idea. And I am taking your idea into consideration:) At the moment I devote much time to the basic elements like a train movement and the general concept of the module. Firstly I want to release something that could be played with:) And after this I will refactor the code and the structure of module. =)
So, whatever happened to this? I've been waiting to make a rollercoaster for ages in any of the block games. Why is it so hard to have rails connect to a vertical or bottom surface? Essentially, you could make a plus sign and go around it infinitely with rails and a train:

* /[]\
|[][][]|
* \[]/

I think it would make this game very unique.
 
Last edited:

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
#10
Hey @MajorLunaC :)

@Adeon is somewhat inconsistently active - sometimes he has time for a while and updates this and other modules, then he disappears again for a bit.

Likely the tricky part with your scenario, not that it is insurmountable, is that you generally can only put one block per "block space" - so you couldn't simply put two differently aligned tracks (floor + wall) in the same space. It has to be a special single block that contains both pieces in a single custom shape, possibly with some extra handling. That's not at all impossible it just isn't as simple as making normal track pieces (a simple texture and nothing special) so just nobody has taken the time to do it yet.

I'd be thrilled to see more support for roller coasters in Terasology :D

@Adeon cooommmeee baaaaccckkkk! :cool:
 
#11
Maybe I didn't explain it clearly. There will be no case when 2 "block-occupying" rails will overlap, just using the current rails and rail systems. All it needs is to attach and connect to sides (like ladders) and bottoms, check and link to those locations, and keep the train from falling off the rail (not sure if it would or not). I tried to make the diagram, but it was misaligned (somewhat fixed). It would continue to use flat and angled rails, and no right angles would ever happen. For a simpler example, think of an L-shaped group of blocks: You put a rail on top of the L, then one in the right angle of the L, making it a 45 degree slanted rail, then put another rail on the right side of the L, connecting to the 45 degree rail. The rail system just needs to check in a couple of extra areas and orient in a set way, albeit in a considerably more complex way.
_
[]\
[][]|

Although now that I think about it, it might have to make a right angle if this structure were floating in space and you put a rail right in the bottom of the L. I would prefer it wouldn't connect then, but I'm not sure how that could be checked for specifically.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
#12
Ah! Yeah, that diagram fix looks a bit different now, sorry about getting the wrong idea.

The current trains can indeed fall off tracks (and then down the sides of hills, with the player still attached, which is amusing), or at least that was the case I still tested it.

If the goal is to support a "loop-de-loop" so to say, in typical roller coaster fashion, then we'd need to be able to put rails on walls (just like ladders, so no big deal) and have a train remain attached to it (maybe slightly bigger deal, depending on how the current code works), as well as on diagonals and roofs. Should be totally doable. Just effort and understanding :)
 
#13
I only found the case of derailments when running out of track or hitting a wall (are there supposed to be brakes? lol). It IS very fun, even realistic.

I'll have to really examine the code when I can then, but it's nice to hear it is likely doable.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
#14
Would be awesome if you want to poke at it some in @Adeon's absence, I'm sure he'd be fine with that! :)

I suspect the derailment I've experienced related to having carts on the track and/or involving enough latency to throw something off, making the game think I was in a position deserving of derailment. Unsure, but it was fun :rofl:
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
#15
Bump! Arise thread, from the tomb!

Thanks to first @SkySom then @Michael we have the Rails module working again! The last round of fixes got it to where the master branch both compiles and runs, with the locomotive and minecart able to roll around on rails again! It feels about like what I remember from way back, complete with hilarious crashes causing locomotives to go flying all over the place :)

Appreciate it guys! I hope you get the notification somehow @Adeon that your creation is moving again :coffee:

The develop branch with the large rails still needs some CPR but may be getting that as well.

I'm going to put the module back in the lineup soon. Maybe we can get some movement back for Metal Renegades soon too! Pinging @glasz and @SuperSnark for reference :)
 

Michael

Moderator
Contributor
Architecture
#17
I still haven't been able to integrate the physics stuff in but I've corrected the rotation stuff for the most part and implemented a way to match curves up correctly with track segments that have a junction.


edit:

I've finally got some rudimentary physics in.


edit 2:

Made a small tweak to get the physics to behave conservatively.
 
Last edited:

SuperSnark

Lore Master
Contributor
Design
Art
#19
Bump! Arise thread, from the tomb!

I'm going to put the module back in the lineup soon. Maybe we can get some movement back for Metal Renegades soon too! Pinging @glasz and @SuperSnark for reference :)

Just a note that a cool combo of current mods would be city generation and rails. We just skin everything custom for a "wild west" world. Throw in our deer with some tweaks to Robo-Fy them or get some of glasz' custom robot models in there and you've almost got something there.
 

Skaldarnar

Badges badges badges badges mushroom mushroom!
Contributor
Art
World
SpecOps
#20
Cool stuff happening :) I already see the inter-city railroads coming! Generating wild west styled cities is just a matter of having fitting templates ready at this point. Maybe world gen would need some tweaks to generate the expected type of landscape, with canyions, etc.