PB 6.21: EntityYaw with RotateEntity bug

All bugs related to the 3D engine
User avatar
MikeHart
User
User
Posts: 16
Joined: Sat Sep 02, 2017 7:29 pm
Location: Germany

PB 6.21: EntityYaw with RotateEntity bug

Post 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
Last edited by MikeHart on Sun Jul 13, 2025 9:58 am, edited 1 time in total.
User avatar
minimy
Enthusiast
Enthusiast
Posts: 551
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: PB 6.22: EntityYaw with RotateEntity bug

Post 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.
If translation=Error: reply="Sorry, Im Spanish": Endif
miso
Enthusiast
Enthusiast
Posts: 407
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: PB 6.22: EntityYaw with RotateEntity bug

Post by miso »

This should be fixed for cases used with the #PB_Engine3D_Adjusted parameter.
User avatar
MikeHart
User
User
Posts: 16
Joined: Sat Sep 02, 2017 7:29 pm
Location: Germany

Re: PB 6.21: EntityYaw with RotateEntity bug

Post 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.
Post Reply