Highway's splitube direction - help

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Realspace
Posts: 1378
Joined: Wed, 15. Nov 06, 10:21
x4

Highway's splitube direction - help

Post by Realspace » Mon, 4. Mar 24, 13:59

Configuration of highways is driving me crazy. While superhighways ignore the orientation for assessing the real direction (they just make the curve smoother), in local highways the direction seems to interfer with the pathfinding. If say I need to go East but the highway points to West, autopilot chooses another route because it thinks that in the straight east direction there is no highway (and my mod's sectors are huge).

Spliposition is regulated by the tx="0.0" ty="0" tz="0.0" coordinates. But I could not understand how they really work, they are not quaternion nor Euler if I see correctly. The TZ is always within 0.0 to 1.0, so is TX never above 1.0, if I read correctly.

So is this some kind of Euler angle radians normalized within a 0.0 to 1.0 range? How are negatives considered?
If so, TY=0.0 is YAW=180? or 90?
Is TY positive 0 to 180 while TY negative 180 to 360?

Thanks you

edit:

Looking at this thread, I am even more confused: viewtopic.php?f=181&t=436953&p=5039309& ... z#p5038730

Must I add the outlength up to the next node? My highways are thousands kms, so is distance between nodes, Must I add that in the outlength or divide /2 and set half in the outlength and half in the inlength? Or is it just the length of the tube to be straight (before turning)?

DeadAirRT
Posts: 1022
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Highway's splitube direction - help

Post by DeadAirRT » Mon, 4. Mar 24, 18:01

Not sure exactly how to explain this so may get confusing

Take a circle, origin point is xyz(0,0,0), and no rotation means you are facing heading 360.

If we start a circle from (0,0,17500) and use 5 points for 4 curved lines.

<splineposition x="0" y="0" z="175000" tx="1" ty="0" tz="0" inlength="0.0" outlength="87500" />
<splineposition x="175000" y="0" z="0" tx="0" ty="0" tz="-1" inlength="87500" outlength="87500" />
<splineposition x="0" y="0" z="-175000" tx="-1" ty="0" tz="0" inlength="87500" outlength="87500" />
<splineposition x="-175000" y="0" z="0" tx="0" ty="0" tz="1" inlength="87500" outlength="87500" />
<splineposition x="0" y="0" z="175000" tx="1" ty="0" tz="0" inlength="87500" outlength="0.0" />

A left to right perpendicular line in front of you would be tx="1" ty="0" tz="0" because it only describes the angle of the line at that point. The game engine will continue a line from that to the next point and the next spline position describes how to intercept that point.

Realspace
Posts: 1378
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Highway's splitube direction - help

Post by Realspace » Mon, 4. Mar 24, 19:14

Thank you DAir, helpfull as always :)
About inlegth+outlength, can it be also less than the splitube's distance (but never more I imagine)?
I ask bc I do them by hand and angles can be not 90 so calculating real distances is a nightmare. If I set a smaller out/inlegth will it result in the tubes having "holes"?

----------------------------

I made a reference graphic to help me, is it correct? So it can help other people too ;-)

Code: Select all

                                              
										
										
							[tx 0 / ty +1]
					[tx-0.1 / ty+0.9]		[tx+0.1 / ty+0.9]
				[tx-0.7 / ty+0.7]				[tx+0.7 / ty+0.7]
			[tx-0.9 / ty+0.1]						[tx+0.9 / ty+0.1]
	<--	[tx-1 / ty+0]										[tx+1 / ty+0] -->
			[tx-0.9 / ty-0.1]						[tx+0.9 / ty-0.1]
				[tx-0.7 / ty-0.7]				[tx+0.7 / ty-0.7]
					[tx-0.1 / ty-0.9]		[tx+0.1 / ty-0.9]
							[tx 0 / ty -1]
										
								       
 

DeadAirRT
Posts: 1022
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Highway's splitube direction - help

Post by DeadAirRT » Mon, 4. Mar 24, 22:41

Realspace wrote:
Mon, 4. Mar 24, 19:14
Thank you DAir, helpfull as always :)
About inlegth+outlength, can it be also less than the splitube's distance (but never more I imagine)?
I ask bc I do them by hand and angles can be not 90 so calculating real distances is a nightmare. If I set a smaller out/inlegth will it result in the tubes having "holes"?

----------------------------

I made a reference graphic to help me, is it correct? So it can help other people too ;-)

Code: Select all

                                              
										
										
							[tx 0 / ty +1]
					[tx-0.1 / ty+0.9]		[tx+0.1 / ty+0.9]
				[tx-0.7 / ty+0.7]				[tx+0.7 / ty+0.7]
			[tx-0.9 / ty+0.1]						[tx+0.9 / ty+0.1]
	<--	[tx-1 / ty+0]										[tx+1 / ty+0] -->
			[tx-0.9 / ty-0.1]						[tx+0.9 / ty-0.1]
				[tx-0.7 / ty-0.7]				[tx+0.7 / ty-0.7]
					[tx-0.1 / ty-0.9]		[tx+0.1 / ty-0.9]
							[tx 0 / ty -1]
										
								       
 
For me it was fairly intuitive on the angles since I just think of it as a slope/tangent but I mostly used it for region splines where I thought of it from a top down perspective. The inlength/outlength is how you force more curvature since the engine will connect them even if you omit them. The influence of your tx/ty/tz is applied 100% at the point and transitions to the previous/next along the distance. The region definition I gave from my example earlier is for a pretty close to equidistant circle about the origin.

For your reference, I'm assuming its from the perspective of a ship on a highway? If so, then for example up and to the right at a 45 would be TX=0.5, TY=0.5 for example.

Realspace
Posts: 1378
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Highway's splitube direction - help

Post by Realspace » Tue, 5. Mar 24, 00:28

DeadAirRT wrote:
Mon, 4. Mar 24, 22:41
For your reference, I'm assuming its from the perspective of a ship on a highway? If so, then for example up and to the right at a 45 would be TX=0.5, TY=0.5 for example.
That's what I thought it was the 45° value but seems it is not, then found the various discussions on Rebirth where the Euler angles are elaborated, I don't get more than what is here: https://github.com/UniTrader/UTXReImagi ... ghways.xml
and the converter, where using quarternions I have the c.a. tx="7.66" ty="6.44" https://quaternions.online/

Well..numbers apart I don't need all this precision but what happens is that in HIGHWAYS things get weird. While a splitube works in one direction, the same values (inverted direction) cause the autopilot to exit the route and stop using the highway. This thing's insane. I use for instance these two tubes in Cluster_115

Code: Select all

          <splineposition x="1505000" y="5000" z="1500000" tx="-0.9" ty="0" tz="-0.1" weight="0" inlength="0" outlength="204030" /> 
			          <splineposition x="5000" y="5000" z="-0" tx="-0.766" ty="0" tz="-0.642" weight="0" inlength="376870" outlength="376870" />
	          <splineposition x="5000" y="5000" z="-5200000" tx="0.1" ty="0" tz="-0.9" weight="0" inlength="204030" outlength="0.0" /> 
  

this goes from NE to SW then S, it works no problem
then the other way

Code: Select all

          <splineposition x="0" y="0" z="-5200000" tx="-0.1" ty="0" tz="0.9" weight="0" inlength="0" outlength="204030" />
	          <splineposition x="-5000" y="-0" z="-0" tx="0.0" ty="0" tz="1.0" weight="0" inlength="376870" outlength="376870" />
		          <splineposition x="1500000" y="0" z="1500000" tx="0.9" ty="0" tz="0.1" weight="0" inlength="204030" outlength="0.0" />
or also the exact opposite (but tested verious orientations)

Code: Select all

 
          <splineposition x="1505000" y="5000" z="1500000" tx="-0.9" ty="0" tz="-0.1" weight="0" inlength="0" outlength="204030" />
          <splineposition x="5000" y="5000" z="-0" tx="-0.766" ty="0" tz="-0.642" weight="0" inlength="376870" outlength="376870" />
	          <splineposition x="5000" y="5000" z="-5200000" tx="0.1" ty="0" tz="-0.9" weight="0" inlength="204030" outlength="0.0" />
     
this goes from S to N to NE, but the ship leaves the highway circa at the junction between second and third(last) spline (1200km from last x="1500000" y="0" z="1500000" spline)
Not only player's ship, all ships do it.

In some cases (other hw's) by using different orientation of the tube I solved the issue, here nothing works, doing it straight W-E or S-N, nothing changes, the ship leaves the hw :evil:
And in any case, if I can not understand what is the cause, testing every single hw is a no go.

DeadAirRT
Posts: 1022
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Highway's splitube direction - help

Post by DeadAirRT » Tue, 5. Mar 24, 06:11

Realspace wrote:
Tue, 5. Mar 24, 00:28
*snip*
What you wrote above is starting to get very confusing. I don't think of it as an angle that you calculate based on pitch/yaw/roll/euler/tait-bryan. Keep it very simple, TZ = 1 is South to North. TZ = -1 is North to south. TX = 1 is West to East. TX = -1 is East to West. TY = 1 is Down to Up. TY = -1 is Up to Down.

The points must be in the order of travel direction for the route. The engine will connect the fixes, you only need to be more specific and use TX/TY/TZ when you are trying to be artsy. Here is a way to do the south->north->northeast from above as simple as possible.

Code: Select all

 
	<splineposition x="5000" y="5000" z="-5200000"/>
	<splineposition x="5000" y="5000" z="0"/>
	<splineposition x="1505000" y="5000" z="1500000"/>
Maybe this will put it into perspective a little differently. Imagine you are looking at 2 dimensional map of an X4 sector. Up is +z, down is -z, left is -x, right is +x. Coordinates will use the format (X,Z) in the examples below.

If you want to transform (0,0) to (0,100) then you need to move 100% along the +z axis. This would be TZ=1.
If you want to transform (0,0) to (100,0) then you need to move 100% along the +x axis. This would be TX=1.

This is where my memory begins to fail me, but I'm fairly certain on this (feel free to test and let me know. It is either 0.5 for both or 1.0 for both)
if you want to transform (0,0) to (100,100) then you need to move 50% along the +z axis and 50% along the +x axis. This would be TX=0.5, TZ=0.5.
if you want to transform (100,100) to (-100,-100) then you need to move 50% along the -z axis and 50% along the -x axis. This would be TX=-0.5, TZ=-0.5

So, if you wanted to have a highway start in the south and end in the north in an S shape (top down view). Now obviously, this wont turn out as well as defining more points along the shape but it should result in something that looks like an S. All I am defining here are three central coordinates along an "S" and telling it what direction to pass through those points, and how long it should smooth the portion of the bezier curve before going directly to the next coordinate (or it's inlength curve if defined).

Code: Select all

 
	<splineposition x="0" y="0" z="-10000" tx="1" outlength="13000"/>
	<splineposition x="0" y="0" z="0" tx="-1" inlength="13000" outlength="13000"/>
	<splineposition x="0" y="0" z="10000" tx="1" inlength="13000"/>
(if you are wondering why I used 13000 it's because I researched an approximate value to use to describe a circle using bezier curves and one of the formulas I found was

Code: Select all

(4/3)*tan(pi/(2n))
where n is the number of segments.)

Realspace
Posts: 1378
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Highway's splitube direction - help

Post by Realspace » Tue, 5. Mar 24, 14:17

Yes, confused I am. :) But not about splines, I got them. It was the fact that some hws refuse to work aka the autopilot discards them in the route. But after long xperiments I am sure it does not depend from splines or their orientation. Yes if you don't orient them right the curve is steep or strange, but I tested various angles. They work or not...regardless

My hws are so long that by using also long outlegths the curves are always smooth, even if I set only integer +x/y -x/y discarding 0.* values, as you suggest.

Btw I noticed that the autopilot sometimes fails also to intercept vanilla hws, so it must be an ai problem. But vanilla sectors are small, using huge sectors requires working highways.

Also, seems the ai likes to use hws if the target is on one side, not further on beyond where the hw ends. This happens always, so..making hws longer than the distance of the gates helps quite a bit.

Post Reply

Return to “X4: Foundations - Scripts and Modding”