calculating edge vectors

Willkommen in der Transport Fever Community

Wir begrüßen euch in der Fan-Community zu den Spielen Transport Fever und Train Fever, den Wirtschaftssimulatoren von Urban Games. Die Community steht euch kostenlos zur Verfügung damit ihr euch über das Spiel austauschen und informieren könnt. Wir pflegen hier einen freundlichen und sachlichen Umgang untereinander und unser Team steht euch in allen Fragen gerne beiseite.

 

Die Registrierung und Nutzung ist selbstverständlich kostenlos.

 

Wir wünschen euch viel Spaß und hoffen auf rege Beteiligung.

Das Team der Transport-Fever Community


  • Building a track in the game is easy... but when it comes to building a shape of tracks in a construction (.con file) with edgeList I'm lost. That is why I create curves in Blender. This is very time consuming, so why not using the possibility to make track directly in the construction. The only thing I can do is straight tracks. Curved need proper vectors and I don't know how to calculate them. Looking in the WIKI givs nothing.


    Here is what I have


    I need a 45° bend.


    I have the starting and ending position, but how to get the vectors?

    Is there a formula that I can use?


    edges[#edges + 1] = { { 100.0, 0.0, 0.0 }, { ???, ???, 0.0 } }

    edges[#edges + 1] = { { 130.0, 20.0, 0.0 }, { ???, ???, 0.0 } }

    result.edgeLists = {

    {

    type = "TRACK",

    params = { type = "standard.lua" },

    edges = edges,

    snapNodes = snapTrack

    },

    }

  • You will need some knowledge about Hermite/Bezier splines. Perhaps you download my "track builder" mod* and have a look at scripts/wktb_geoutil.lua. The functions that you need for constructing, rotating and placing curves are

    geo.createFullCurve**

    geo.createPositiveCurve**

    geo.rotTranslEdge

    geo.rot


    I always construct a curve from the zero point and then shift and turn it with geo.rotTranslEdge to the place I want to have it. Mostly this is the end of the preceding edge. ;)


    The variables used are:

    r: radius

    radiant: angle in rad

    curved: -1 left, 1 right

    zEnd: end height

    mConn: end slope of preceding edge

    mEnd: slope of the end of current edge

    pConn: end point of preceding edge

    tConn: end tangent point of preceding edge


    Sometimes I use different names for the points:

    p0 / pStart: start point

    p1 / pEnd: end point

    t0 / tStart: left tangent point

    t1 / tEnd: right tangent point


    A special feature of my curves is to build them in at least two parts. This was necessary beacause TPF crashed when building an intersection with a segment only from one edge. I have not yet tested if this issue still exists.


    The basics for handling Hermite and Bezier splines you can find here:

    Kurven konstruieren

    Punkte, Vektoren, Koordinaten in Lua programmieren

    I intended to continue this to make a tutorial from it, but I didn't yet finde the time. :(:rolleyes: It is not a simple stuff, so if you have questions perhaps we can start a conversation - or for simpler things I'll try to post the answer here.


    *) Latest version, former versions use a more complicated algorithm.

    **) You can leave out the last argument in the lines 74 and 93, it was originally thought for another purpose, but p0 will always be {0,0,0}, so this is not necessary.

    ... don't know much trigonometry ... don't know much about algebra ... don't know what a slide rule is for ...

    Einmal editiert, zuletzt von WernerK () aus folgendem Grund: Wichtiger Zusatzhinweis

BlueBrixx