AttachEntityObject with CameraID

Everything related to 3D programming
Realizimo
User
User
Posts: 71
Joined: Sun Nov 25, 2012 5:27 pm
Location: Sweden

AttachEntityObject with CameraID

Post 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)
miso
Enthusiast
Enthusiast
Posts: 410
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: AttachEntityObject with CameraID

Post 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)
Realizimo
User
User
Posts: 71
Joined: Sun Nov 25, 2012 5:27 pm
Location: Sweden

Re: AttachEntityObject with CameraID

Post by Realizimo »

Thanks, and I've never worked with "bones"
miso
Enthusiast
Enthusiast
Posts: 410
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: AttachEntityObject with CameraID

Post 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.
User avatar
minimy
Enthusiast
Enthusiast
Posts: 556
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: AttachEntityObject with CameraID

Post by minimy »

Tested and youre right.
If translation=Error: reply="Sorry, Im Spanish": Endif
Post Reply