RotateEntity() with MoveEntity()
Posted: Tue Jan 12, 2010 1:02 am
i have a mesh; when i rotate it with RotateEntity(), MoveEntity() then moves it in absolute coordinates and not relative ones. how do i fix this? (i'm trying to avoid trigonometry.)
here is the full code (you'll need a "ship.mesh" file in a "ship" folder)
here is the full code (you'll need a "ship.mesh" file in a "ship" folder)
Code: Select all
Define.f KeyX, KeyY, KeyR
#ShipMesh = 0
#Ship = 0
If InitEngine3D()
Add3DArchive("ship", #PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
AntialiasingMode(#PB_AntialiasingMode_x6)
If OpenScreen(1920, 1200, 32, "")
LoadMesh (#ShipMesh , "ShipEditable.mesh")
CreateEntity(#Ship, MeshID(#ShipMesh), #PB_Material_None )
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,0,7,25)
Repeat
ClearScreen(RGB(0, 0, 0))
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyR = 1
ElseIf KeyboardPushed(#PB_Key_Right)
KeyR = -1
Else
KeyR = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -1
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = 1
Else
KeyY = 0
EndIf
EndIf
RotateEntity(#Ship, 0, 0, KeyR, #PB_Relative)
MoveEntity(#Ship, 0, -KeyY/10, 0)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End