Hello:
I am trying to devise a was for the aircraft to bank/roll into a turn. I would like to roll it the angle amount to the next way point, never to exceed 180 degrees on the Z axis. Here is what I have for my waypoints setup.
Rem Project: ShipFlying
Rem Created: 10/10/2004 12:27:25 a.m.
Rem ***** Main Source File *****
sync on
sync rate 0
set display mode 1600, 1200, 32
Rem set globals
global objCubeSource = 1
global objCubeDestination = 2
global vecCubeSource = 1
global vecCubeDestination = 2
global vecDistance = 3
global intCurrentWaypoint = 1
global vecAngle#
type typWaypoint
X as float
Y as float
Z as float
endtype
Dim aryWaypoint(5) as typWaypoint
Initialize()
null = make Vector3(vecCubeSource)
null = make Vector3(vecCubeDestination)
null = make Vector3(vecDistance)
make object box objCubeSource, 10,5,5
make object cube objCubeDestination, .10
position object objCubeSource, 0, 0, 0
position object objCubeDestination, aryWaypoint(intCurrentWaypoint).X, aryWaypoint(intCurrentWaypoint).Y, aryWaypoint(intCurrentWaypoint).Z
point object objCubeSource, object position x(objCubeDestination), object position y(objCubeDestination), object position z(objCubeDestination)
position camera 0, 0, 0
point camera 0, 0, -1
do
UpdatePosition()
text 0, 0, "Vector Length: " + str$( length vector3(vecDistance) )
text 0, 16, "Screen FPS: " + str$ ( screen fps() )
text 0, 32, "Angle: " + str$( vecAngle# )
sync
loop
function UpdatePosition
set vector3 vecCubeSource, object position x(vecCubeSource), object position y(vecCubeSource), object position z(vecCubeSource)
set vector3 vecCubeDestination, object position x(vecCubeDestination), object position y(vecCubeDestination), object position z(vecCubeDestination)
subtract vector3 vecDistance, vecCubeDestination, vecCubeSource
MoveSource()
if length vector3(vecDistance) < 50
inc intCurrentWaypoint
if intCurrentWaypoint = 6 then intCurrentWaypoint = 1
position object objCubeDestination, aryWaypoint(intCurrentWaypoint).X, aryWaypoint(intCurrentWaypoint).Y, aryWaypoint(intCurrentWaypoint).Z
endif
endfunction
function MoveSource
EZro_SetEuler OBJECT ANGLE X(objCubeSource),OBJECT ANGLE Y(objCubeSource),OBJECT ANGLE Z(objCubeSource)
EZro_SetPos OBJECT POSITION X(objCubeSource),OBJECT POSITION Y(objCubeSource), OBJECT POSITION Z(objCubeSource)
EZro_TurnPitchTo OBJECT POSITION X(objCubeDestination),OBJECT POSITION Y(objCubeDestination), OBJECT POSITION Z(objCubeDestination),1
EZro_FindEuler
ROTATE OBJECT objCubeSource,EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ()
MOVE OBJECT objCubeSource,.5
EZro_FindAxisAngles
vecAngle# = EZro_AngleBetweenPoints(0, 0, 0, object position x(vecCubeSource), object position y(vecCubeSource), object position z(vecCubeSource), object position x(vecCubeDestination), object position y(vecCubeDestination), object position z(vecCubeDestination))
endfunction
function Initialize
rem Waypoint definitions
aryWaypoint(1).X = 10
aryWaypoint(1).Y = -50
aryWaypoint(1).Z = -100
aryWaypoint(2).X = -10
aryWaypoint(2).Y = -11
aryWaypoint(2).Z = -200
aryWaypoint(3).X = 5
aryWaypoint(3).Y = 10
aryWaypoint(3).Z = 1
aryWaypoint(4).X = 100
aryWaypoint(4).Y = 100
aryWaypoint(4).Z = -200
aryWaypoint(5).X = 50
aryWaypoint(5).Y = 1
aryWaypoint(5).Z = -400
endfunction
I was going to use the Dot Product to get the angle and bank/roll the plane at a set amount of 50 units but depending on the speed, I will change that amount.
Let me know what you think I can do.
Thanks in advance.
-This...is my boomstick!