Issue with Orthographic View.

Everything related to 3D programming
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Issue with Orthographic View.

Post by Samuel »

If you switch the camera to Orthographic Mode. Then try moving the camera forward you get a weird effect. Maybe, this is normal, but I kinda think it's not supposed to happen.
If you zoom in. Your camera will stay in one place, but the mesh will start disappearing. Kinda like when the camera is going through a mesh it no longer has a need
to render what is behind it. In this case though the camera is still in the original location.

Code: Select all

;PRESS Escape to exit

#CameraSpeed = 1

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()

  InitSprite()
  InitKeyboard()
  InitMouse()
  ExamineDesktops()
  
DeskWid=DesktopWidth(0)
DeskHei=DesktopHeight(0)

 If OpenWindow(0, 0, 0, DeskWid, DeskHei, "Orthographic Viewing", #PB_Window_ScreenCentered)
  If OpenWindowedScreen(WindowID(0), 0, 0, DeskWid, DeskHei, 0, 0, 0)
  
    BoxTexture=CreateTexture(#PB_Any,32,32)
    StartDrawing(TextureOutput(BoxTexture))
      Box(0,0,32,32,RGB(255,0,0))
    StopDrawing()
    
    BoxMaterial=CreateMaterial(#PB_Any, TextureID(BoxTexture))
    
    BoxMesh=CreateCube(#PB_Any,100)
    BoxEntity=CreateEntity(#PB_Any,MeshID(BoxMesh),MaterialID(BoxMaterial),0,-50,0)
    
    PlaneTexture=CreateTexture(#PB_Any,32,32)
    StartDrawing(TextureOutput(PlaneTexture))
      Box(0,0,32,32,RGB(0,0,255))
    StopDrawing()
    
    PlaneMaterial=CreateMaterial(#PB_Any, TextureID(PlaneTexture))
    
    PlaneMesh=CreatePlane(#PB_Any,10000,10000,10,10,10,10)
    PlaneEntity=CreateEntity(#PB_Any,MeshID(PlaneMesh),MaterialID(PlaneMaterial),0,-500,0)
    
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 0, 100, #PB_Absolute)
    CameraLookAt(0,0,-50,0)
    CameraProjectionMode(0, #PB_Camera_Orthographic)
    
    CreateLight(0,RGB(255,255,255),500,500,200)
    
    Repeat
            
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf  
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed 
        Else
          KeyX = 0
        EndIf
                  
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed 
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed 
        Else
          KeyY = 0
        EndIf

      EndIf
            
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera(0, KeyX, 0, KeyY)

    
      RenderWorld()

      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) 
  EndIf
 EndIf
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
  
End
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Issue with Orthographic View.

Post by Olby »

I might be wrong but you need to make sure the camera is always as far as necessary to not enter the 3D geometry i.e. far enough to prevent clipping of the closest meshes. Orthographic means it does not have 3D perspective but the camera(s) still exhibit near and far rendering ranges. See CameraRange(#Camera, Near, Far).
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Issue with Orthographic View.

Post by Samuel »

Hello Olby,

After doing some more research on the Ogre site. It seems like you can't zoom a Orthographic camera because of the lack of depth.
You have to scale your meshes instead to get the desired effect. Which is fine by me because I only need this for a simple task. So, if you or anyone else has any more ideas on this I'll be glad to hear about them, but my problem is now taken care of.
Thanks!
Post Reply