"IOW, the code I gave above."
Yes! Thanks, great- using that. But am I missing something else?
The gimbal lock I don't think is the issue...?
If you guys would indulge me and try this script?
It's what I am using to test all this with. I placed the little pallet
looking bridge segment in the map; //bridges//wood bridge mid//
First I turn the object on 'x' axle and a little 'z' axle then control is selected for 'y' ...
of course as it's rotated, these angles get all over the place.
But this is what I'm seeing:
local U = require "scriptbank\\utillib"
local Q = require "scriptbank\\quatlib"
local rotx = {}
local roty = {}
local rotz = {}
local rotxr = {}
local rotyr = {}
local rotzr = {}
local doonce = {}
local rad = math.rad
local deg = math.deg
local camview = {}
local camx = {}
local camy = {}
local camz = {}
local pressed = {}
function spinning_testcam_init(e)
rotx[e] = 0
roty[e] = 0
rotz[e] = 0
rotxr[e] = 0
rotyr[e] = 0
rotzr[e] = 0
doonce[e] = 0
camview[e] = 0
camx[e] = 0
camy[e] = 0
camz[e] = 0
pressed[e] = 0
-- 1 degree to radian = d * 0.0174533
-- 1 radian to degree = r * 57.295804
end
function spinning_testcam_main(e)
if doonce[e] == nil then doonce[e] = 0 end
if doonce[e] < 14 then
doonce[e] = doonce[e] + 1
SetRotation(e, g_Entity[e]['anglex'] + 3, g_Entity[e]['angley'] + 0, g_Entity[e]['anglez'] + 1 )
rotx[e] = g_Entity[e]['anglex']
roty[e] = g_Entity[e]['angley']
rotz[e] = g_Entity[e]['anglez']
return
end -- doonce assignments
rotx[e] = g_Entity[e]['anglex']
roty[e] = g_Entity[e]['angley']
rotz[e] = g_Entity[e]['anglez']
local q1 = Q.FromEuler( math.rad( rotx[e] ), math.rad( roty[e] ), math.rad( rotz[e] ) )
local q2 = Q.FromEuler( 0, math.rad(3), 0 )
local fq = Q.Mul( q1, q2 )
xa, ya, za = Q.ToEuler( fq )
if g_Scancode == 16 then -- 'Q' to test Quaternion rotation
SetRotation(e, math.deg( xa ), math.deg( ya ), math.deg( za ) )
end
if g_Scancode == 19 then-- 'R' to test standard rotation
SetRotation(e, g_Entity[e]['anglex'], g_Entity[e]['angley'] + 2, g_Entity[e]['anglez'] )
end
if g_Scancode == 47 and pressed[e] == 0 then
pressed[e] = 1
camview[e] = camview[e] + 1
if camview[e] > 1 then camview[e] = 0 end
end
if g_Scancode == 0 then pressed[e] = 0 end
Text(11,11,1,"'Q'= quatern rotate.")
Text(11,14,1,"'R'= regular rotate.")
if camview[e] == 0 then
Text(22,22,3,"Press 'V' for camview ON...")
else
Text(22,22,3,"Press 'V' for camview OFF...")
camx[e] = NewXValue(g_Entity[e]['x'], g_Entity[e]['angley'], 150)
camy[e] = 650 ------- g_Entity[e]['y'] // + planerise[e]
camz[e] = NewZValue(g_Entity[e]['z'], g_Entity[e]['angley'], 150)
SetFreezePosition(camx[e], camy[e], camz[e])
SetFreezeAngle(10, g_Entity[e]['angley']+180, 0)
TransportToFreezePosition()
end
end -- main