Jump to content

Switching railway arrows and working with .DAT


Recommended Posts

Good afternoon, WHO has the opportunity to implement this:
1) It is necessary to implement that the arrow switches when the tram (train) is under electric current / coasting (the gas pedal is clamped or not).

And we need help with the implementation of this:

 

 

Please describe how this can be implemented and what functions will be needed for this.

Link to comment
  • 2 weeks later...

The trolley poles look like custom objects attached to the vehicle using attachElements and their rotation is controlled with setElementAttachedOffsets. Alternatively, they can be parts of custom vehicle model, rotated using setVehicleComponentRotation.

On every frame (in onClientPreRender event), you would find a particular point of the overhead wire and rotate the trolley poles towards that point, so it would look like they are connected all the time.

Finding the point of the overhead wire depends on the format of the wire data you're using, but generally it involves finding a sphere-line intersection point. That is, if a sphere is positioned where the trolley pole is mounted and its radius equals the length of the trolley pole, and a line matches the overhead wire, then the sphere-line intersection point is the point that the trolley pole should be rotated towards. That requires some math.

Calculating rotation from position is another part that requires math - if you have a position in world coordinate system, you can use getElementMatrix to get a matrix that you can then use to get the same position with respect to the vehicle. Then you can use math.atan2 to convert position to rotation angles (in radians), math.deg to convert angles from radians to degrees and pass the resulting values to setElementAttachedOffsets.

And when the power is disconnected, setVehicleEngineState can be used to disable the engine.

Link to comment
1 hour ago, DiSaMe said:

The trolley poles look like custom objects attached to the vehicle using attachElements and their rotation is controlled with setElementAttachedOffsets. Alternatively, they can be parts of custom vehicle model, rotated using setVehicleComponentRotation.

On every frame (in onClientPreRender event), you would find a particular point of the overhead wire and rotate the trolley poles towards that point, so it would look like they are connected all the time.

Finding the point of the overhead wire depends on the format of the wire data you're using, but generally it involves finding a sphere-line intersection point. That is, if a sphere is positioned where the trolley pole is mounted and its radius equals the length of the trolley pole, and a line matches the overhead wire, then the sphere-line intersection point is the point that the trolley pole should be rotated towards. That requires some math.

Calculating rotation from position is another part that requires math - if you have a position in world coordinate system, you can use getElementMatrix to get a matrix that you can then use to get the same position with respect to the vehicle. Then you can use math.atan2 to convert position to rotation angles (in radians), math.deg to convert angles from radians to degrees and pass the resulting values to setElementAttachedOffsets.

And when the power is disconnected, setVehicleEngineState can be used to disable the engine.

Yes, trolleybus pantographs are car components. You can write an example in which the current collectors (at least 1) will cling to the wires, and the wires will be a set of coordinate points in the dat File:
 

Spoiler

-231.872 -116.883 0.0 0
-236.027 -126.972 0.0 0
-236.039 -139.615 0.0 112
-228.727 -152.046 0.0 0
-222.22 -157.297 0.0 0
-209.845 -162.438 0.0 0
-209.489 -162.438 0.0 0
-30.0063 -162.438 0.0 0
-24.5542 -165.769 0.0 0
-23.288 -169.526 0.0 0
-23.2883 -424.187 0.0 0
-19.0018 -436.796 0.0 0
-4.68228 -443.151 0.0 0
672.415 -443.151 0.0 0
693.176 -440.428 0.0 0
713.093 -431.446 0.0 0
728.55 -417.768 0.0 0
738.121 -403.121 0.0 0
743.959 -387.349 0.0 0
746.13 -370.917 0.0 0
746.13 -130.304 0.0 0
747.269 -126.103 0.0 0
751.135 -124.194 0.0 61
751.745 -124.0 0.0 0
769.716 -117.909 0.0 0
779.294 -113.947 0.0 0
783.957 -104.385 0.0 91
783.788 -103.972 0.0 0
774.362 -80.2178 0.0 0
773.005 -76.9146 0.0 0
769.716 -75.5489 0.0 0
757.077 -75.546 0.0 0
752.998 -77.9445 0.0 0
750.716 -83.6348 0.0 0
746.941 -105.771 0.0 0
740.795 -119.239 0.0 0
734.246 -130.31 0.0 0

If so, how do I add the coordinates of the second wire for the second pantograph?
Returning to the beginning of the topic, how to implement the translation of a railway arrow by a roll or a button? How can this be implemented on the trolleybus contact network?
how do I rotate the train trolleys relative to the rail? Thank you for the answer:)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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