Page 1 of 1

PB 6.21: EntityYaw with RotateEntity bug

Posted: Fri Jul 04, 2025 11:26 pm
by MikeHart
I am convinced that there is some kind of abnormal behaviour when you retrieve Yaw/Roll/Pitch, increment them and feeding the result back into RotateEntity in absolute mode. With EntityYaw alone you can see it clearly.

Btw: I thought using #PB_Engine3D_Adjusted returns a value from 0 to 360. But it doesn't. There is no difference to #PB_Engine3D_Raw.

Code: Select all

  InitEngine3D()
  InitSprite()

  OpenWindow(0, 0, 0, 640, 480, "RotateEntity Bug", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)

  ; Light
  CreateLight(#PB_Any, RGB(25, 25, 180), -5, 10, 5, #PB_Light_Point)

  ; Camera
  CreateCamera(0, 0, 0, 100, 100)
  MoveCamera(0, 2, 4, 3, #PB_Absolute | #PB_Local)
  CameraLookAt(0, 0, 0, 0)

  ; Create the torus and attach it to the scene
  CreateTorus(0, 1, 0.3)
  CreateEntity(0, MeshID(0), #PB_Material_None)
  OpenConsole()
  Repeat
    RotateEntity(0, EntityPitch(0,#PB_Engine3D_Adjusted)+0.0,EntityYaw(0,#PB_Engine3D_Adjusted)+0.25,EntityRoll(0,#PB_Engine3D_Adjusted)+0.0, #PB_Absolute)
    ;RotateEntity(0, 0.25, 0.25, 0.25,#PB_Relative)
    Print(StrF(EntityPitch(0),1)+":"+StrF(EntityYaw(0),1)+":"+StrF(EntityRoll(0),1)+Chr(10))
    RenderWorld()
    FlipBuffers()
  Until WaitWindowEvent(1) = #PB_Event_CloseWindow

Re: PB 6.22: EntityYaw with RotateEntity bug

Posted: Sun Jul 06, 2025 8:34 pm
by minimy
Btw: I thought using #PB_Engine3D_Adjusted returns a value from 0 to 360. But it doesn't. There is no difference to #PB_Engine3D_Raw.
Hello, with this can convert the angle (0/359), where P is your entityYaw or other axis.

Code: Select all

For p= -180 To 180
  Debug Degree(Radian(p+180))
Next p
Or this

Code: Select all

  Procedure.f get360(ay,offa.f=0)
    ;devuelve el angulo en grados del angulo en Euler de Ogre3D
    Protected.f na
    If ay<0
      na= Abs(ay)
    Else
      na= (180-Abs(ay))+180
    EndIf
    na+offa:If na>=360:na-360:EndIf
    ProcedureReturn na
  EndProcedure
I am convinced that there is some kind of abnormal behaviour when you retrieve Yaw/Roll/Pitch, increment them and feeding the result back into RotateEntity in absolute mode. With EntityYaw alone you can see it clearly.
The problem is when change an axis the rest change too.
I was crazy with angles and this was my solution.
The trip to recover exact angle is use entitydirection( to set and entitydirectionX( to get.

Re: PB 6.22: EntityYaw with RotateEntity bug

Posted: Sun Jul 06, 2025 8:59 pm
by miso
This should be fixed for cases used with the #PB_Engine3D_Adjusted parameter.

Re: PB 6.21: EntityYaw with RotateEntity bug

Posted: Sat Jul 12, 2025 8:55 am
by MikeHart
thanks guys for your suggestions. With closed source tools I am not so fond of work arounds. Hope it gets fixed soon.
But I am glad you guys found a way.