can anyone help me make a camera algorithm similar to an 3d MMORPG?

Everything related to 3D programming
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

can anyone help me make a camera algorithm similar to an 3d MMORPG?

Post by skinkairewalker »

Hello everyone, I would like some help, does anyone have an example of a camera movement algorithm, similar to a 3d mmorpg camera?

like this gameplay video > https://youtu.be/0o8UD01QYjE?t=1375
or this gameplay : https://gfycat.com/glassunimportantarro ... hort-clips
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: can anyone help me make a camera algorithm similar to an 3d MMORPG?

Post by Psychophanta »

I don't know what is your request, but as i understand, you refer to orbitate and control the camera distance to the object. So, if is this, i use something like this:

Code: Select all

InitEngine3D(#PB_Engine3D_NoLog,#PB_Compiler_Home+"Compilers\Engine3d.dll"):InitSprite():InitKeyboard():InitMouse()
OpenWindowedScreen(OpenWindow(0,0,0,1024,768,"t",#PB_Window_BorderLess|#PB_Window_ScreenCentered),0,0,1024,768,1,0,0,#PB_Screen_WaitSynchronization)

CreateLight(0,$EEEEEE,-1,1,6,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
CreateNode(0,0,0,0):AttachNodeObject(0,CameraID(0))
MoveCamera(0,0,0,4,#PB_Absolute)
CreateMaterial(0,0,$55DDEE)
CreateSphere(0,1,3,2)
CreateEntity(0,MeshID(0),MaterialID(0),0,0,0)


Procedure.b KeyEdgeDetection(key.a)
  Static pka.a
  If KeyboardPushed(key);<-if current key status is PUSHED
    If pka=0:pka=key:ProcedureReturn 1:EndIf;<-if previous key status was NOT PUSHED, then assign previous state to current one, and EXIT.
  ElseIf pka=key;<-else (if previous key status was PUSHED and current key status is NOT PUSHED):
    pka=0;:ProcedureReturn -1;<-set previous key status to NOT PUSHED.
  EndIf
  ProcedureReturn 0
EndProcedure
Macro TeclaControldecamara(tecla=LeftControl)
  If KeyEdgeDetection(#PB_Key_#tecla#); <- inicia control camara
    pasocam.f=0.01:pasocamincr.f=0.001
  ElseIf KeyboardReleased(#PB_Key_#tecla#)
  ElseIf KeyboardPushed(#PB_Key_#tecla#); <- mover el punto de vista
    ;para desplazar la camara hacia delante, atras, arriba, abajo, izq o der
    If mdx Or mdy Or mdz
      If mmb.b
        MoveNode(0,mdx,-mdy,0,#PB_Local); o MoveCamera(0,mdx,-mdy,0,#PB_Local) o MoveCamera(0,mdx,-mdy,0,#PB_Relative)
      Else
        RotateNode(0,-mdy*60,-mdx*60,0,#PB_Relative)
        If mdz
          MoveCamera(0,0,0,-mdz,#PB_Relative)
        EndIf
      EndIf
    ElseIf KeyboardPushed(#PB_Key_Add)
      MoveCamera(0,0,0,-pasocam,#PB_Relative)
      pasocam+pasocamincr
    ElseIf KeyboardPushed(#PB_Key_Subtract)
      MoveCamera(0,0,0,pasocam,#PB_Relative)
      pasocam+pasocamincr
    ElseIf KeyboardPushed(#PB_Key_Pad8)
      MoveCamera(0,0,pasocam,0,#PB_Relative)
      pasocam+pasocamincr
    ElseIf KeyboardPushed(#PB_Key_Pad2)
      MoveCamera(0,0,-pasocam,0,#PB_Relative)
      pasocam+pasocamincr
    ElseIf KeyboardPushed(#PB_Key_Pad6)
      MoveCamera(0,pasocam,0,0,#PB_Relative)
      pasocam+pasocamincr
    ElseIf KeyboardPushed(#PB_Key_Pad4)
      MoveCamera(0,-pasocam,0,0,#PB_Relative)
      pasocam+pasocamincr
    ElseIf KeyboardPushed(#PB_Key_Pad1)
      RotateNode(0,0,-0.5,0,#PB_Relative)
    ElseIf KeyboardPushed(#PB_Key_Pad7)
      RotateNode(0,0,0.5,0,#PB_Relative)
    ElseIf KeyboardPushed(#PB_Key_Pad3) Or lmb.b
      RotateNode(0,0,0,-0.5,#PB_Relative)
    ElseIf KeyboardPushed(#PB_Key_Pad9) Or rmb.b
      RotateNode(0,0,0,0.5,#PB_Relative)
    EndIf
EndMacro

Repeat:While WindowEvent()<>#PB_Event_None:Wend
  ExamineMouse():ExamineKeyboard()
  lmb.b=MouseButton(#PB_MouseButton_Left):rmb.b=MouseButton(#PB_MouseButton_Right):mmb.b=MouseButton(#PB_MouseButton_Middle)
  mdx.f=MouseDeltaX()/200:mdy.f=MouseDeltaY()/200:mdz.f=MouseWheel()/20
  TeclaControldecamara()
  EndIf
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: can anyone help me make a camera algorithm similar to an 3d MMORPG?

Post by skinkairewalker »

did not work ... :(
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: can anyone help me make a camera algorithm similar to an 3d MMORPG?

Post by Fred »

There is an example in the Examples/3D/Demo dir which do a third person moving
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 782
Joined: Fri Dec 04, 2015 9:26 pm

Re: can anyone help me make a camera algorithm similar to an 3d MMORPG?

Post by skinkairewalker »

very interesting and perfect example.
I'll try to study to find out, the problem is that I'm terrible at organizing algorithms.
Post Reply