FPS in OGRE3D - (SOLVED) by Dark Dragon

Advanced game related topics
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

FPS in OGRE3D - (SOLVED) by Dark Dragon

Post by Rook Zimbabwe »

OK I am settling two source codes here for a FPS in OGRE.

This is the first one... all graphics come from a folder called NEWIDEA which I has thoughtfully zipped up and you can find here:

http://www.bluemesapc.com/Downloads/NEWIDEA.zip

code 1:
(no attempt at physics)

Code: Select all


;
; ------------------------------------------------------------
;
;   PureBasic - Terrain
;
;   modified by Ralph W Dunn / Rook ZImbabwe
;    (c) 2003 - Fantaisie Software
;    modified 7 MARCH 2011
;    Changes applied from examples by Daniel (Dark Dragon)
;
; ------------------------------------------------------------
;

version$ = "0.09"

#CameraSpeed = 0.4

#Thing1 = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALLn = 5
#WALLs = 6
#WALLe = 7
#WALLw = 8
#DOORn = 9
#DOORs = 10
#DOORe = 11
#DOORw = 12
#RING = 13
#FLOOR = 14


Global Dim stones(10,10)

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  Add3DArchive("Data", #PB_3DArchive_FileSystem)
  Add3DArchive("NEWIDEA", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    
    LoadMesh(#FLOOR , "flor1.mesh") ; a block or cube... can be gotten from my basic MESH pack
    LoadMesh(#WALLn , "WALn1.mesh")
    LoadMesh(#WALLs , "WALs1.mesh")
    LoadMesh(#WALLe , "WALe1.mesh")
    LoadMesh(#WALLw , "WALw1.mesh")
    LoadMesh(#RING, "RING0.mesh")
    
    LoadTexture(0, "flor1.jpg") ; something to make it look nice
    LoadTexture(1, "WAL2.jpg") ; something to make it look nice
    LoadTexture(2, "WAL.jpg") ; something to make it look nice
    
    CreateMaterial(#CRETE, TextureID(0))
    walltex = CreateMaterial(#PB_Any, TextureID(1))
    ringtex = CreateMaterial(#PB_Any, TextureID(2))
    
    CreateEntity(#WALLn, MeshID(#WALLn), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLs, MeshID(#WALLs), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLe, MeshID(#WALLe), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLw, MeshID(#WALLw), MaterialID(walltex),0,0,0)
    CreateEntity(#RING, MeshID(#RING), MaterialID(ringtex),0,0,0)
    
    CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(#CRETE),0,0,0)
    
    ; throw down a floor for gravity to work on
    ey = 0
    ez = 0
    For cx = 0 To 10
      For cy = 0 To 10
        Result = CopyEntity(#FLOOR, #PB_Any)
        EntityLocate(Result, ey, 0, ez)
        ez = ez + 10
      Next
      ey = ey + 10
      ez = 0
    Next
    ; north wall
    For nx = 0 To 10
      Result = CopyEntity(#WALLn, #PB_Any)
      EntityLocate(Result, wx, 0, ez)
      wx = wx + 10
    Next
    ; south wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLs, #PB_Any)
      EntityLocate(Result, wx, 0, 100)
      wx = wx + 10
    Next
    ; east wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLe, #PB_Any)
      EntityLocate(Result, 100, 0, wx)
      wx = wx + 10
    Next
    ; west wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLw, #PB_Any)
      EntityLocate(Result, 0, 0, wx)
      wx = wx + 10
 Next
 ey = 0
 ez = 0
    ; RANDOM RINGS
     For cx = 1 To 10
          For cy = 1 To 10
               doit = Random(5)
               If doit = 1
        Result = CopyEntity(#RING, #PB_Any)
        EntityLocate(Result, ey, 0, ez)
        EndIf
        ez = ez + 10
      Next
      ey = ey + 10
      ez = 0
    Next
    
    ; hide the originals
    HideEntity(#WALLn, #True)
    HideEntity(#WALLs, #True)
    HideEntity(#WALLe, #True)
    HideEntity(#WALLw, #True)
    HideEntity(#RING, #True)
    ; make something to see the floor with
    
   CreateCamera(#PLAYER, 0, 0, 100, 150)
    CameraLocate(#PLAYER, 10, 0, 10)
    
    ;CreateWater(#PLAYER, 0,-1,0, 190,#PB_World_WaterMediumQuality)
    
    SkyDome("blue_sky_1.jpg",-10) ; my clouds texture...
    
    ;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity  /  #PB_World_DebugBody = no work
    
    Repeat
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_A)
          KeyX = -0.5
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyX = 0.5
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_W)
          KeyY = -0.5 ;#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_X)
          KeyY  = 0.5 ;#CameraSpeed
        Else
          KeyY = 0
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)*#CameraSpeed ; dropped the /2 cause it was slowing me down
        MouseY = -(MouseDeltaY()/10)*#CameraSpeed
      EndIf
      
      ; to move the new node entity
      
      RotateCamera(#PLAYER, MouseY, MouseX, RollZ, #PB_Relative)
      MoveCamera  (#PLAYER, KeyX, -CameraY(#PLAYER)+4, KeyY)
      
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End

:mrgreen:
Last edited by Rook Zimbabwe on Sun Mar 13, 2011 4:19 am, edited 3 times in total.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues but probably solvable

Post by Rook Zimbabwe »

Code 2... attempting to use the physics and make sure the camera does not pass through the walls...

so far a failure...

I admit it was easier in Blitz3D as the B3D models did most of the bounding work for you and the camera was attached to a pivot and that could be set to bounce off easily...

I cannot make it stop at an object... it takesd the entity mass and physic body for the camera without complaint... so???

{{{ REVISED CODE FURTHER DOWN WITH NODE }}}

:mrgreen:
Last edited by Rook Zimbabwe on Tue Mar 08, 2011 4:34 pm, edited 1 time in total.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: FPS in OGRE3d small issues but probably solvable

Post by J. Baker »

Rook Zimbabwe wrote:Code 2... attempting to use the physics and make sure the camera does not pass through the walls...
Create a box mesh. Make sure the box is not visible and is placed right in front of the camera. Setup the camera to follow the box when moving. Set collisions with the box and walls. I think that should work. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues but probably solvable

Post by Rook Zimbabwe »

yeah I know HOW... I just don't know HOW in OGRE!!! camera follow is getting lost on me... is a node like a pivot?
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues but probably solvable

Post by Rook Zimbabwe »

this is my attempt using NODEs... camera seems to rotate around and the node does not stop at anything... at a serious loss as to why!

you are going to need the following mesh:
http://www.bluemesapc.com/Downloads/GUY.mesh

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Terrain
;
;   modified by Ralph W Dunn / Rook ZImbabwe
;    (c) 2003 - Fantaisie Software
;    modified 7 MARCH 2011
;    Changes applied from examples by Daniel (Dark Dragon)
; ****** THIS IS MY ATTEMPT AT SOLID MESH
;
; ------------------------------------------------------------
;

version$ = "0.09"

#CameraSpeed = 0.4
#GUY = 0
#NODE1 = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALLn = 5
#WALLs = 6
#WALLe = 7
#WALLw = 8
#DOORn = 9
#DOORs = 10
#DOORe = 11
#DOORw = 12
#RING = 13
#FLOOR = 14

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
  Add3DArchive("NEWIDEA", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  EnableWorldPhysics(#True)
  EnableWorldCollisions(#True)
  
  WorldGravity(98.1)  ;EARTH // (41.1) ; MARSish
  
  If Screen3DRequester()
    ;- LOAD ENTITY
    
    LoadMesh(#FLOOR , "flor1.mesh") ; a block or cube... can be gotten from my basic MESH pack
    LoadMesh(#WALLn , "WALn1.mesh")
    LoadMesh(#WALLs , "WALs1.mesh")
    LoadMesh(#WALLe , "WALe1.mesh")
    LoadMesh(#WALLw , "WALw1.mesh")
    LoadMesh(#RING, "RING0.mesh")
    LoadMesh(#GUY, "GUY.mesh") ; ****** our player for the node
    
    LoadTexture(0, "RUST1.jpg") ; something to make it look nice
    LoadTexture(1, "WAL1.jpg") ; something to make it look nice
    LoadTexture(2, "WAL.jpg") ; something to make it look nice
    
    CreateMaterial(#CRETE, TextureID(0))
    walltex = CreateMaterial(#PB_Any, TextureID(1)) ; notice works both ways!
    ringtex = CreateMaterial(#PB_Any, TextureID(2))
    
    CreateEntity(#WALLn, MeshID(#WALLn), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLs, MeshID(#WALLs), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLe, MeshID(#WALLe), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLw, MeshID(#WALLw), MaterialID(walltex),0,0,0)
    CreateEntity(#RING, MeshID(#RING), MaterialID(ringtex),0,0,0)
    CreateEntity(#GUY, MeshID(#GUY), MaterialID(ringtex),50,0,50)
    
    ;- SET BODY FOR BUMPING
    EntityPhysicBody(#WALLn, #PB_Entity_StaticBody)
    EntityPhysicBody(#WALLs, #PB_Entity_StaticBody)
    EntityPhysicBody(#WALLe, #PB_Entity_StaticBody)
    EntityPhysicBody(#WALLw, #PB_Entity_StaticBody)
    EntityPhysicBody(#RING, #PB_Entity_StaticBody)
    EntityPhysicBody(#GUY, #PB_Entity_SphereBody)
    
    SetEntityMass(#WALLn, 10.0)
    SetEntityMass(#WALLs, 10.0)
    SetEntityMass(#WALLe, 10.0)
    SetEntityMass(#WALLw, 10.0)
    SetEntityMass(#RING, 10.0)
    SetEntityMass(#GUY, 1.0)
    
    CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(#CRETE),0,0,0)
    
    ;- CREATE CAMERA
    
    CreateCamera(#PLAYER, 0, 0, 100, 100)
    CameraLocate(#PLAYER, 50, 0, 50)
    EntityPhysicBody(#PLAYER, #PB_Entity_BoxBody | #PB_Entity_AbsoluteBodyMove)
    SetEntityMass(#PLAYER, 1.0)
    
   ; SkyDome("blue_sky_1.jpg",-10) ; my clouds texture...
    
    ;- CAMERA AS ENTITY WITH NODE
    CreateNode(#DUDE , 50, 0, 50)
    AttachNodeObject(#DUDE, CameraID(#PLAYER), #PB_Node_Camera)
    AttachNodeObject(#DUDE, EntityID(#GUY), #PB_Node_Entity )
    
    Fog(RGB(0,0,0), 1, 0, 30)
    
    
    ;- MAKE FLOOR 10 X 10
    ey = 0
    ez = 0
    For cx = 0 To 10
      For cy = 0 To 10
        Result = CopyEntity(#FLOOR, #PB_Any)
        EntityLocate(Result, ey, 0, ez)
        ez = ez + 10
      Next
      ey = ey + 10
      ez = 0
    Next
    
    ; north wall
    For nx = 0 To 10
      Result = CopyEntity(#WALLn, #PB_Any)
      EntityLocate(Result, wx, 0, ez)
      wx = wx + 10
    Next
    
    ; south wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLs, #PB_Any)
      EntityLocate(Result, wx, 0, 100)
      wx = wx + 10
    Next
    
    ; east wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLe, #PB_Any)
      EntityLocate(Result, 100, 0, wx)
      wx = wx + 10
    Next
    
    ; west wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLw, #PB_Any)
      EntityLocate(Result, 0, 0, wx)
      wx = wx + 10
    Next
    
    ey = 0
    ez = 0
    
    ; RANDOM RINGS
    For cx = 1 To 10
      For cy = 1 To 10
        doit = Random(6)
        If doit = 1
          Result = CopyEntity(#RING, #PB_Any)
          EntityLocate(Result, ey, 0, ez)
        EndIf
        ez = ez + 10
      Next
      ey = ey + 10
      ez = 0
    Next
    
    ;- hide the originals
    HideEntity(#WALLn, #True)
    HideEntity(#WALLs, #True)
    HideEntity(#WALLe, #True)
    HideEntity(#WALLw, #True)
    HideEntity(#RING, #True)
    
    ; *** uncomment to see bounding boxes
    ; WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity  /  #PB_World_DebugBody = no work
    jump = 4
    ;- START OF LOOP
    Repeat
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_A)
          KeyX = -0.5 ; was 1 but the camera was running on STEROIDS!
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyX = 0.5
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_W)
          KeyY = -0.5 ;#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_X)
          KeyY  = 0.5 ;#CameraSpeed
        Else
          KeyY = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Space) ; gravity does not work on this
          For howhigh = 1 To 6
            jump = jump + howhigh
            MoveEntity(#GUY, KeyX, jump, KeyY)
          Next
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)*#CameraSpeed ; dropped the /2 cause it was slowing me down
        MouseY = -(MouseDeltaY()/10)*#CameraSpeed
      EndIf
      
      RotateCamera(#PLAYER, MouseY, MouseX, RollZ, #PB_Relative)
      MoveCamera(#PLAYER, KeyX, -CameraY(#PLAYER)+4, KeyY)
      ;RotateNode(#DUDE, MouseY, MouseX, RollZ, #PB_Relative)
      ; MoveNode(#DUDE, KeyX, -CameraY(#PLAYER)+4, KeyY) ; THE -CameraY(#PLAYER)+4, is the HEIGHT of the camera off the ground
      RotateEntity(#GUY, MouseY, MouseX, RollZ, #PB_Relative)
      MoveEntity(#GUY, KeyX, -CameraY(#PLAYER)+4, KeyY)
      
      
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End


code updated 8 MAR 2011 // 15:05 Central USA Time
Last edited by Rook Zimbabwe on Tue Mar 08, 2011 9:58 pm, edited 1 time in total.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues but probably solvable

Post by Rook Zimbabwe »

I have updated code above and I think the reason it does not work is that the entity is HIDDEN???
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues but probably solvable

Post by Rook Zimbabwe »

OK third version of code... now have the GUY on screen... had to remake model for some reason so I have re uploaded it... now called GUY1.mesh

Sometimes #GUY does not come in screen... i figure he hits the ground too hard...

I can rotate him but I cannot make him move... I do not understand this... makes no sense!

I turned off the FOG to see what was happening.

code is much slower without the fog... kind of slow with fog. I suspect that is because of all the pieces to check collision on.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Terrain
;
;   modified by Ralph W Dunn / Rook ZImbabwe
;    (c) 2003 - Fantaisie Software
;    modified 7 MARCH 2011
;    Changes applied from examples by Daniel (Dark Dragon)
; ****** THIS IS MY ATTEMPT AT SOLID MESH
;
; ------------------------------------------------------------
;

version$ = "0.09"

#CameraSpeed = 0.4
#GUY = 0
#NODE1 = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALLn = 5
#WALLs = 6
#WALLe = 7
#WALLw = 8
#DOORn = 9
#DOORs = 10
#DOORe = 11
#DOORw = 12
#RING = 13
#FLOOR = 14

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY

If InitEngine3D()
  
  Add3DArchive("NEWIDEA", #PB_3DArchive_FileSystem)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  EnableWorldPhysics(#True)
  EnableWorldCollisions(#True)
  
  WorldGravity(51.1)  ;EARTH // (91.1) ; MARSish
  
  If Screen3DRequester()
    ;- LOAD ENTITY
    
    LoadMesh(#FLOOR , "flor1.mesh") ; a block or cube... can be gotten from my basic MESH pack
    LoadMesh(#WALLn , "WALn1.mesh")
    LoadMesh(#WALLs , "WALs1.mesh")
    LoadMesh(#WALLe , "WALe1.mesh")
    LoadMesh(#WALLw , "WALw1.mesh")
    LoadMesh(#RING, "RING0.mesh")
    ;LoadMesh(#GUY, "DORe1.mesh") ; ****** our player for the node
    LoadMesh(#GUY , "GUY1.mesh") ; a block or cube... can be gotten from my basic MESH pack
    
    LoadTexture(0, "RUST1.jpg") ; something to make it look nice
    LoadTexture(1, "WAL1.jpg") ; something to make it look nice
    LoadTexture(2, "WAL.jpg") ; something to make it look nice
    
    CreateMaterial(#CRETE, TextureID(0))
    walltex = CreateMaterial(#PB_Any, TextureID(1)) ; notice works both ways!
    ringtex = CreateMaterial(#PB_Any, TextureID(2))
    
    CreateEntity(#WALLn, MeshID(#WALLn), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLs, MeshID(#WALLs), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLe, MeshID(#WALLe), MaterialID(walltex),0,0,0)
    CreateEntity(#WALLw, MeshID(#WALLw), MaterialID(walltex),0,0,0)
    CreateEntity(#RING, MeshID(#RING), MaterialID(ringtex),0,0,0)
    CreateEntity(#GUY, MeshID(#GUY), MaterialID(ringtex),0,0,0)
    
    ;- SET BODY FOR BUMPING
    EntityPhysicBody(#WALLn, #PB_Entity_StaticBody)
    EntityPhysicBody(#WALLs, #PB_Entity_StaticBody)
    EntityPhysicBody(#WALLe, #PB_Entity_StaticBody)
    EntityPhysicBody(#WALLw, #PB_Entity_StaticBody)
    EntityPhysicBody(#RING, #PB_Entity_StaticBody)
    EntityPhysicBody(#GUY, #PB_Entity_BoxBody ) ;| #PB_Entity_AbsoluteBodyMove)
    
    SetEntityMass(#GUY, 5.0)
    SetEntityFriction(#GUY, 1.0)
    
    CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(#CRETE),0,0,0)
    
    ;- CREATE CAMERA
    
    CreateCamera(#PLAYER, 0, 0, 100, 100)
    CameraLocate(#PLAYER, 0, 0, 0)
    
    ; SkyDome("blue_sky_1.jpg",-10) ; my clouds texture...
    
    ;- CAMERA AS ENTITY WITH NODE
    CreateNode(#DUDE , 00, 0, 00)
    ;AttachNodeObject(#DUDE, CameraID(#PLAYER), #PB_Node_Camera)
    ;AttachNodeObject(#DUDE, EntityID(#GUY), #PB_Node_Entity )
    ; EntityPhysicBody(#DUDE, #PB_Entity_BoxBody | #PB_Entity_AbsoluteBodyMove)
    
    ; Fog(RGB(0,0,0), 1, 0, 30)
    
    EntityLocate(#GUY, 10,10,10)
    
    ;- MAKE FLOOR 10 X 10
    ey = 0
    ez = 0
    For cx = 0 To 10
      For cy = 0 To 10
        Result = CopyEntity(#FLOOR, #PB_Any)
        EntityLocate(Result, ey, 0, ez)
        EntityPhysicBody(Result, #PB_Entity_StaticBody)
        SetEntityMass(Result, 10.0)
        ez = ez + 10
      Next
      ey = ey + 10
      ez = 0
    Next
    
    ; north wall
    For nx = 0 To 10
      Result = CopyEntity(#WALLn, #PB_Any)
      EntityLocate(Result, wx, 0, ez)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; south wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLs, #PB_Any)
      EntityLocate(Result, wx, 0, 100)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; east wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLe, #PB_Any)
      EntityLocate(Result, 100, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ; west wall
    wx = 0
    For nx = 0 To 10
      Result = CopyEntity(#WALLw, #PB_Any)
      EntityLocate(Result, 0, 0, wx)
      EntityPhysicBody(Result, #PB_Entity_StaticBody)
      SetEntityMass(Result, 10.0)
      wx = wx + 10
    Next
    
    ey = 0
    ez = 0
    
    ; RANDOM RINGS
    For cx = 1 To 10
      For cy = 1 To 10
        doit = Random(10)
        If doit = 1
          Result = CopyEntity(#RING, #PB_Any)
          EntityLocate(Result, ey, 0, ez)
          EntityPhysicBody(Result, #PB_Entity_StaticBody)
          SetEntityMass(Result, 10.0)
        EndIf
        ez = ez + 10
      Next
      ey = ey + 10
      ez = 0
    Next
    
    ;- hide the originals
    HideEntity(#WALLn, #True)
    HideEntity(#WALLs, #True)
    HideEntity(#WALLe, #True)
    HideEntity(#WALLw, #True)
    HideEntity(#RING, #True)
    
    ; *** uncomment to see bounding boxes
    ;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity  /  #PB_World_DebugBody = no work
    jump = 4
    ;- START OF LOOP
    Repeat
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_A)
          KeyX = -0.5 ; was 1 but the camera was running on STEROIDS!
        ElseIf KeyboardPushed(#PB_Key_D)
          KeyX = 0.5
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_W)
          KeyY = -0.5 ;#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_X)
          KeyY  = 0.5 ;#CameraSpeed
        Else
          KeyY = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Space) ; gravity does not work on this
          For howhigh = 1 To 6
            jump = jump + howhigh
            MoveEntity(#GUY, KeyX, jump, KeyY)
          Next
        EndIf
        
      EndIf
      
      If ExamineMouse()
        MouseX = -(MouseDeltaX()/10)*#CameraSpeed ; dropped the /2 cause it was slowing me down
        MouseY = -(MouseDeltaY()/10)*#CameraSpeed
      EndIf
      
      ;ExamineWorldCollisions()
      
      ;CheckEntityCollision(#GUY, #RING)
      
      RotateCamera(#PLAYER, MouseY, MouseX, RollZ, #PB_Relative)
      MoveCamera(#PLAYER, KeyX, -CameraY(#PLAYER)+6, KeyY)
      RotateEntity(#GUY, MouseY, MouseX, 0, #PB_Relative)
      
      ;RotateNode(#DUDE, MouseY, MouseX, RollZ, #PB_Relative)
      ;MoveNode(#DUDE, KeyX, -CameraY(#PLAYER)+4, KeyY) ; THE -CameraY(#PLAYER)+4, is the HEIGHT of the camera off the ground
      
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End


Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Zach
Addict
Addict
Posts: 1678
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: FPS in OGRE3d small issues {update}

Post by Zach »

Just a thought... have you tried visting a forum specifically for Ogre users?
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues {update}

Post by Rook Zimbabwe »

If they created a new forum here I don't see it. I am pretty sure my issue us based in PB. I have read the OGRE wiki with little success... :(
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues {update}

Post by Rook Zimbabwe »

This is the best I have found so far... my dyslexia kicks in and whoop... words become alphabet soup!

I think I can access some of what they are talking about in PB... but I may have to create my own class objects or macros to call them and I have no idea how to do that!

http://www.ogre3d.org/tikiwiki/OgreOde+ ... collisions

:mrgreen:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues {update}

Post by Rook Zimbabwe »

these three commands seem to work differently:

Code: Select all

RotateNode(#DUDE, MouseY, MouseX, RollZ, #PB_Relative)
       MoveNode(#DUDE, KeyX, -CameraY(#PLAYER) + 6, KeyY)
      
      ;RotateCamera(#PLAYER, MouseY, MouseX, RollZ, #PB_Relative)
      ;MoveCamera(#PLAYER, KeyX, -CameraY(#PLAYER)+6, KeyY)
      
     ;RotateEntity(#GUY, MouseY, MouseX, RollZ, #PB_Relative)
     ; MoveEntity(#GUY, KeyX , -CameraY(#PLAYER)+6, KeyY)
I have also tried the locate commands with no success... if I use the NODE commandset the camera will rotate and tile crazy but it refuses to move in the direction facing... but the CAMERA commandset works fine... NO BUMPING but FINE!!!

I know you can code a FPS in OGRE I have seen it... this stinks!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues {update}

Post by Rook Zimbabwe »

it is possible that they handle this with the mesh in front (also known as the WEAPON mesh) and that is how the check for bumps...

I am going to try this...

Oneone of my examples I can see the cube bouncing arouns but it will NOT connect to the NODE... nor will it MOVE with the node... I am going to attempt to attach a SMALL cube in fron of the node to simulate a weapon and see if I can get it to move with the node... If I can't this MAY be unsolvable until the next update of PB (hopefully solvable then!)

:evil:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: FPS in OGRE3d small issues {update}

Post by Rook Zimbabwe »

It cannot be done...

Perhaps we should abandon OGRE?
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Zach
Addict
Addict
Posts: 1678
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: FPS in OGRE3d small issues {update}

Post by Zach »

Rook Zimbabwe wrote:If they created a new forum here I don't see it. I am pretty sure my issue us based in PB. I have read the OGRE wiki with little success... :(
Well, the original reason I said it was because you have made comments such as,
Rook Zimbabwe wrote:yeah I know HOW... I just don't know HOW in OGRE!!! camera follow is getting lost on me... is a node like a pivot?
Ogre has been around for quite some time, and though I have never used it personally I would like to think it is quite capable of producing a simple FPS game, in any proper (which PB certainly is) programming language.

So again, perhaps you should try and see if you can get any help on the official ogre forums, if there is something you don't know how to do? It makes sense that more people over there would be focused on gaming vs. here where most are focused on Applications instead.

If its also a matter of something ogre does, which isn't supported in PB for some reason, then maybe you should approach it from a different angle and write a wrapper for those functions you need (PB support or not, I would hope they are in the DLL for whichever version it is PB uses, anyway).

It's not my intention to be rude or anything like that.. I've seen you struggle with Ogre issues over quite a few posts, so I thought I would suggest the Ogre forums instead, since not many here seem to use it for games or anything. If anything your posts have convinced me to stay away from Ogre when I finally do try to do something with 3D.. It seems to have a reputation for being difficult to work with, etc.. But I could be wrong..
Nituvious
Addict
Addict
Posts: 1030
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: FPS in OGRE3D - cannot be done!

Post by Nituvious »

Rook, someone posted an FPS example a year or so ago. It was done with the PB version of Ogre.
I don't remember if the source was included, I think it was because it used PB's included models and textures.

You shouldn't need a camera bounding box as the player would always be in FPS mode. If you absolutely need it, you could probably hack something together like the previous posters said and just check collisions of this box with other objects.

[edit] here is the fps example: http://www.purebasic.fr/english/viewtop ... hilit=ogre
▓▓▓▓▓▒▒▒▒▒░░░░░
Post Reply