-
Notifications
You must be signed in to change notification settings - Fork 4
Polyline item
Roads and various other items in the game are procedurally generated by drawing a spline through the nodes of the items and creating geometry along that path.
To my great annoyance, the rotation of a node and the length of the path between the two nodes of an item are cached in the map files. If you don't get them right, the game will initially create the items with your inaccurate values, and to fix them, you need to open the properties dialog of each node and click Cancel. This will recalculate the node's rotation and the cached lengths of its attached items.
The spline function used is a Hermite spline. The tangents of each piece are calculated as follows:
-
Calculate the distance d between the two control nodes.
-
Rotate the vector (0, 0, -d) by the rotation of the start and end node respectively.
I don't know which method the game uses to approximate the length of the spline – I decompiled it and now I just plug my numbers in and the right number comes out, but all this SIMD math is a black box to me.
The rotation value of the two nodes of a polyline item can either be set manually using the Free Rotation flag, or the game can calculate it automatically like this:
-
For a node with only one "neighbor" in either direction, its rotation is simply the angles between the direction vector of the polyline segment and the ground plane.
-
For a node p1 with a "neighbor" in both directions: convert the direction p1-p0 to its rotation, then average it with the rotation of p2.
-
.base/.aux/.snd
- Animated Model
- Bezier Patch
- Buildings
- Bus Stop
- Camera Path
- Camera Point
- City
- Company
- Compound
- Curve
- Cut Plane
- Cutscene
- Environment Area
- Far Model
- Ferry
- Fuel Pump
- Garage
- Gate
- Hinge
- Hookup
- Map Area
- Map Overlay
- Model
- Mover
- Parking
- Prefab
- Road
- Service
- Sign
- Sound
- Terrain
- Traffic Area
- Trajectory
- Trigger
- Visibility Area
- Walker