You need to use SetObjectRotation():
SetObjectRotation(x1, GetObjectAngleX(x1) + 0.5, GetObjectAngleY(x1), GetObjectAngleZ(x1))
And then the physics object matches up with the drawn object. I think the RotateObjectLocal should be functional tho so agree its a bug.
I tried to get yours working and ended up re-writing, came up with this:
// Project: testKin
// Created: 21-11-13
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "testKin" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
SetPrintSize(20)
create3DPhysicsWorld(1)
Set3DPhysicsGravity(0, -40, 0)
SetCameraPosition(1, 46, 56, -78)
SetCameraRotation(1, 27.5, 0, 0)
myGround = CreateObjectPlane(1000, 1000)
SetObjectColor(myGround, 0x40, 0x40, 0x40, 0xff)
RotateObjectLocalX(myGround, 90)
Create3DPhysicsStaticBody(myGround)
myKinematicBox = CreateObjectBox(100, 5, 20)
SetObjectPosition(myKinematicBox, 50, 20, 10)
SetObjectColor(myKinematicBox, 150, 0, 0, 255)
Create3DPhysicsKinematicBody(myKinematicBox)
global myDropBoxes as integer[]
myDropBoxes.length = -1
cameraMove as float = 0.75 //Amount to move camera
cameraRotate as float = 1.0 //Amount to rotate camera
boxTime as float = 150.0
currentTimer as float = 0.0
do
if (currentTimer = 0)
currentTimer = GetMilliseconds()
else
if ((currentTimer + boxTime) < GetMilliseconds())
makeItRainBoxes()
currentTimer = 0
endif
endif
if GetRawKeyState(asc("X"))
`RotateObjectLocalX(myKinematicBox, 0.5)
`SetObject3DPhysicsAngularVelocity(myKinematicBox, 5.0, 0, 0, 1)
SetObjectRotation(myKinematicBox, GetObjectAngleX(myKinematicBox) + 0.5, GetObjectAngleY(myKinematicBox), GetObjectAngleZ(myKinematicBox))
endif
if GetRawKeyState(asc("Y"))
`RotateObjectLocalY(myKinematicBox, 0.5)
`SetObject3DPhysicsAngularVelocity(myKinematicBox, 0, 5.0, 0, 1)
SetObjectRotation(myKinematicBox, GetObjectAngleX(myKinematicBox), GetObjectAngleY(myKinematicBox) + 0.5, GetObjectAngleZ(myKinematicBox))
endif
if GetRawKeyState(asc("Z"))
`RotateObjectLocalZ(myKinematicBox, 0.5)
`SetObject3DPhysicsAngularVelocity(myKinematicBox, 0, 0, 5.0, 1)
SetObjectRotation(myKinematicBox, GetObjectAngleX(myKinematicBox), GetObjectAngleY(myKinematicBox), GetObjectAngleZ(myKinematicBox) + 0.5)
endif
if (GetRawKeyState(65)) then MoveCameraLocalX(1, cameraMove * -1) //Camera Move L/R: WASD
if (GetRawKeyState(68)) then MoveCameraLocalX(1, cameraMove)
if (GetRawKeyState(87)) then MoveCameraLocalY(1, cameraMove) //Camera Move U/D (Page Up/Dn)
if (GetRawKeyState(83)) then MoveCameraLocalY(1, cameraMove * -1)
if (GetRawKeyState(38)) then RotateCameraLocalX(1, cameraRotate * -1) //Camera Rotate: Arrow keys
if (GetRawKeyState(40)) then RotateCameraLocalX(1, cameraRotate)
if (GetRawKeyState(37)) then RotateCameraGlobalY(1, cameraRotate * -1)
if (GetRawKeyState(39)) then RotateCameraGlobalY(1, cameraRotate)
if (GetRawKeyState(33)) then MoveCameraLocalZ(1, cameraMove) //Camera Zoom
if (GetRawKeyState(34)) then MoveCameraLocalZ(1, cameraMove * -1)
Step3DPhysicsWorld()
Sync()
loop
function makeItRainBoxes()
newDroppedBox = CreateObjectBox(5, 5, 5)
SetObjectColor(newDroppedBox, 0, 0, 150, 255)
SetObjectPosition(newDroppedBox, Random(0, 100), 100, Random(0, 25))
Create3DPhysicsDynamicBody(newDroppedBox)
myDropBoxes.insert(newDroppedBox)
if (myDropBoxes.length > 500)
for i=100 to 0 step -1
DeleteObject(myDropBoxes[i])
myDropBoxes.remove(i)
next i
endif
endfunction