Page 1 of 1

AttachEntityObject with CameraID

Posted: Sat Jun 21, 2025 5:43 pm
by Realizimo
"AttachEntityObject" with "CameraID" does not work with newer versions (620,621), is it a bug?
612 works fine.

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()
OpenWindow(0, 0, 0, 640, 480, "Cube example", #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
#cam=0
CreateCamera(#cam, 0, 0, 100, 100)
#ent0=0:#ent1=1
CreateCube(0,1)
CreateEntity(#ent0, MeshID(0), #PB_Material_None,0,0,5)
AttachEntityObject(#ent0, "", CameraID(#cam))
CreateEntity(#ent1, MeshID(0), #PB_Material_None)
Repeat
  ExamineKeyboard()
  RotateEntity(#ent0,0,KeyboardPushed(#PB_Key_Left)-KeyboardPushed(#PB_Key_Right),0,#PB_Relative)
  MoveEntity(#ent0,0,0,(KeyboardPushed(#PB_Key_Down)-KeyboardPushed(#PB_Key_Up))*0.1,#PB_Relative)
  RenderWorld()
  FlipBuffers()
Until WindowEvent() = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)

Re: AttachEntityObject with CameraID

Posted: Sat Jun 21, 2025 6:40 pm
by miso
I never really used this until today (so I don't know how it supposed to work with prior versions), but it works with a dummy bone.

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()
OpenWindow(0, 0, 0, 640, 480, "Cube example", #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
#cam=1
CreateCamera(#cam, 0, 0, 100, 100)
CameraBackColor(#cam,RGB(130,30,0))
#ent0=0:#ent1=1

CreateCube(0,1)
CreateSkeleton(0)
CreateBone(0,"root","",0,0,0,0,0,0,1,#PB_Orientation_PitchYawRoll)
VertexBoneAssignment(0,0,0,0,1) : FinishBoneAssignment(0,0)
CreateEntity(#ent0, MeshID(0), #PB_Material_None,0,0,5)
AttachEntityObject(#ent0, "root", CameraID(#cam))

CreateEntity(#ent1, MeshID(0), #PB_Material_None,0,0,0)

Repeat
  Repeat
    event=WindowEvent()
    If event = #PB_Event_CloseWindow:End:EndIf
  Until event = 0
  
  ExamineKeyboard()
  RotateEntity(#ent0,0,KeyboardPushed(#PB_Key_Left)-KeyboardPushed(#PB_Key_Right),0,#PB_Relative)
  MoveEntity(#ent0,0,0,(KeyboardPushed(#PB_Key_Down)-KeyboardPushed(#PB_Key_Up))*0.1,#PB_Relative)
  RenderWorld()
  FlipBuffers()
Until  KeyboardPushed(#PB_Key_Escape)

Re: AttachEntityObject with CameraID

Posted: Sat Jun 21, 2025 6:57 pm
by Realizimo
Thanks, and I've never worked with "bones"

Re: AttachEntityObject with CameraID

Posted: Sat Jun 21, 2025 7:05 pm
by miso
It say's "If the bone name is empty, then the object is not attached to a bone but directly to the entity. "
So it is a bug imho.

Re: AttachEntityObject with CameraID

Posted: Sun Jun 22, 2025 8:16 pm
by minimy
Tested and youre right.