Page 1 of 1

RotateEntity() with MoveEntity()

Posted: Tue Jan 12, 2010 1:02 am
by ChebbyShabby
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)

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

Re: RotateEntity() with MoveEntity()

Posted: Tue Jan 12, 2010 2:08 am
by IdeasVacuum
Hello ChebbyShabby

Is it that the rotate value rotates the Ship by more than 360 degrees? I don't know, the nearest I have to a ship is a cube :)

If I change your KeyR values to 0.01 and -0.01 respectively, the behavior seems to be correct - but I've had a long day so only got one brain cell running at the moment. Also, I set CameraLocate(0,0,0,500) (500 suites my cube mesh).