Module laneutil
Module for lane handling
| networkEdgeData |
Edge data as a table, changes here will not affect the actual edge |
-
laneNetwork (lType)
-
Constructor returning laneNetworkInstance
Parameters:
- lType
string
base lane type (TRACK or ROAD)
Returns:
laneNetworkInstance
-
nodeHandler (laneBuilder)
-
Constructor returning nodeHandlerInstance
Parameters:
- laneBuilder
function
function to create the lane models based on the end nodes
Returns:
nodeHandlerInstance
-
networkEdgeData
-
Edge data as a table, changes here will not affect the actual edge
Fields:
-
networkNodeInstance:setSnap (value)
-
Set if this node may be a snapNode or not
Parameters:
-
networkNodeInstance:getSnap ()
-
Return if this node may be a snapNode
Returns:
bool
isSnap
-
networkNodeInstance:setRemovable (value)
-
Set if this node may be removed when using subNetworkInstance:reduceEdges
Parameters:
-
networkNodeInstance:getRemovable ()
-
Return if this node may be removed
Returns:
bool
removable
Edge class for track/street networks, derived from
edgeInstance
-
networkEdgeInstance:addTerminal (t)
-
Link a terminal id to this edge
Parameters:
-
networkEdgeInstance:addObject (obj)
-
Add an edgeObject to this edge
Parameters:
-
networkEdgeInstance:fromTable (tab)
-
Set table-type edge info based on the given table (using the respective internal functions)
Parameters:
-
networkEdgeInstance:getConnectedEdge ([index[, hasTerminal=false]])
-
Get edge that is connected with this edge at the given index (or the first valid connected edge), optionally checking for existing terminals
Parameters:
- index
number
which side of the edge should be looked at (1: first node; 2: last node)
(optional)
- hasTerminal
boolean
only return edges that have terminals
(default false)
Returns:
optional networkEdgeInstance
-
networkEdgeInstance:extend ([index])
-
Extend edge as much as possible to given side (or both sides if index is omitted)
Parameters:
- index
number
to which side the edge should be extended (nil: both sides; 1: previous edges; 2: next edges)
(optional)
Returns:
networkEdgeData
-
networkEdgeInstance:split ([factor=0.5])
-
Split edge into two new edges with half length or lengths factor*length and (1-factor)*length
Parameters:
- factor
number
(default 0.5)
Returns:
-
networkEdgeInstance
-
networkEdgeInstance
-
networkEdgeInstance:getNodes (edges, snapNodes[, createTerminals=true])
-
Write edge informations to the format required by the game, optionally not writing the terminal data
Parameters:
- edges
table
- snapNodes
table
- createTerminals
boolean
(default true)
Subnetwork defined by the track/street params
-
subNetworkInstance:addLane (v1, t1, v2, t2)
-
Add a edge between the given points using tangents
Parameters:
- v1
vec3
- t1
vec3
- v2
vec3
- t2
vec3
Returns:
networkEdgeInstance
-
subNetworkInstance:addStraight (v1, v2)
-
Add a straight edge between the given points
Parameters:
Returns:
networkEdgeInstance
-
subNetworkInstance:reduceEdges (parent)
-
Create a new network by merging as much edges as possible
Parameters:
Returns:
subNetworkInstance
the reduced network
-
subNetworkInstance:export ()
-
Returns a edgeList representing this network, which can be used in the edgeLists table of a construction.
May contain additional information about terminals, edgeObjects, etc.
Returns:
table
Network constructor for outside use.
You should at most have one for all tracks and one for all streets, otherwise snapNodes may not be correct
-
laneNetworkInstance:get (fileName, params)
-
Get subNetwork for the filename and given params (will be created, if it doesn't exist)
Parameters:
- fileName
string
name of the track/road definition file
- params
table
additional edge params (catenary, tunnel/bridge, etc.)
Returns:
subNetworkInstance
-
laneNetworkInstance:getByID (id)
-
Get existing subNetwork by id
Parameters:
Returns:
subNetworkInstance
-
laneNetworkInstance:createNode (v, t)
-
Create a new node
Parameters:
- v
vec3
node position
- t
vec3
node tangent (only direction is imported, length will be calculated by the script)
Returns:
networkNodeInstance
-
laneNetworkInstance:reduce ()
-
Create a new laneNetwork with reduced number of nodes (edges are combined if possible)
Returns:
laneNetworkInstance
-
connectionNodeInstance:setAngle (a)
-
Set max connection angle for this node
Parameters:
-
connectionNodeInstance:setDist (d)
-
Set max connection distance for this node
Parameters:
-
connectionNodeInstance:setModule (m)
-
Link the node to a module index
Parameters:
Class to handle inter model connections
-
nodeHandlerInstance:addNode (v, t, mID[, dist=100[, angle=2.3562]])
-
Create or update a node with the given position and tangent, optionally setting its connection params
Parameters:
- v
vec3
node position
- t
vec3
node direction(tangent)
- mID
number
ID of module this node belongs to (we don't want the script to connect two nodes in the same module)
- dist
number
max connection distance
(default 100)
- angle
number
max connection angle
(default 2.3562)
Returns:
connectionNodeInstance
-
nodeHandlerInstance:export (models)
-
Export the best connections as models
Parameters: