I do not think that OGRE is culling unseen TRIs... Each #WALL on screen is 8 TRI... the #FLOOR is 2 TRI and the #DOOR (the most complex) is 60ish... in no way should that overload the most basic graphics card!
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"
#FLOOR = 1
#CRETE = 2
#PLAYER = 3
#DUDE = 4
#WALL = 5
#DOOR = 6
#CameraSpeed = 16
; create an array to hold the junk
; * KNOW this works as the program does not DIE when added
Global mazewidth = 20
Global mazeheight = 20
Global Dim maze(mazewidth,mazeheight)
; fill array with nothings
For x = 0 To mazewidth
For y = 0 To mazeheight
maze(x,y) = 0
Next
Next
Procedure ScreenWidth()
!extrn _PB_Screen_RealWidth
!mov eax, dword [_PB_Screen_RealWidth]
ProcedureReturn
EndProcedure
Procedure ScreenHeight()
!extrn _PB_Screen_RealHeight
!mov eax, dword [_PB_Screen_RealHeight]
ProcedureReturn
EndProcedure
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(#WALL , "CUBE1.mesh")
LoadMesh(#DOOR, "DOOR1.mesh")
LoadMesh(#DUDE, "GUY1.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, "flor2.jpg") ; something to make it look nice
walltex = CreateMaterial(#PB_Any, TextureID(1)) ; notice works both ways!
DOORtex = CreateMaterial(#PB_Any, TextureID(0))
floortex = CreateMaterial(#PB_Any, TextureID(2))
CreateEntity(#FLOOR, MeshID(#FLOOR), MaterialID(floortex),0,0,0)
CreateEntity(#WALL, MeshID(#WALL), MaterialID(walltex),0,0,0)
CreateEntity(#DOOR, MeshID(#DOOR), MaterialID(DOORtex),0,0,0)
CreateEntity(#DUDE, MeshID(#DUDE), MaterialID(DOORtex),100,4,100)
EntityPhysicBody(#DUDE ,#PB_Entity_BoxBody , #PB_Entity_AbsoluteBodyMove)
SetEntityMass(#DUDE, 1.0)
;- CREATE CAMERA
CreateCamera(#PLAYER, 0, 0, 100, 100)
; Fog(RGB(0,0,0), 1, 0, 30)
;- MAKE FLOOR 20 X 20
ey = 0
ez = 0
For cx = 0 To 20
For cy = 0 To 20
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 20
Result = CopyEntity(#WALL, #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 20
Result = CopyEntity(#WALL, #PB_Any)
EntityLocate(Result, wx, 0, 200)
EntityPhysicBody(Result, #PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
wx = wx + 10
Next
; east wall
wx = 0
For nx = 0 To 20
Result = CopyEntity(#WALL, #PB_Any)
EntityLocate(Result, 200, 0, wx)
EntityPhysicBody(Result, #PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
wx = wx + 10
Next
; west wall
wx = 0
For nx = 0 To 20
Result = CopyEntity(#WALL, #PB_Any)
EntityLocate(Result, 0, 0, wx)
EntityPhysicBody(Result, #PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
wx = wx + 10
Next
ey = 0
ez = 0
; now For a small test...
times = Random(80) + 30 ; random number of objects between 30 and 80
For whop = 0 To times
x = Random(20)
y = Random(20)
maze(x,y) = Random(1)+2 ; random between 2 and 3 for now to place walls and doors
Debug "SET = "+Str(times)
Next
; * program still working
; *** read array to set the random walls and doors
blocksize = 10
Debug "=-=-=-=-=-=- READING ARRAY!"
For y=1 To mazeHeight-1
For x=1 To mazeWidth-1
If maze(x,y) = 2
Result = CopyEntity(#DOOR, #PB_Any)
EntityLocate(Result, x*blockSize, 0, y*blockSize)
EntityPhysicBody(Result ,#PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
Debug "****** DOOR SET!"
ElseIf maze(x,y) = 3
Result = CopyEntity(#WALL, #PB_Any)
EntityLocate(Result, x*blockSize, 0, y*blockSize)
EntityPhysicBody(Result ,#PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
Debug "****** WALL SET!"
EndIf
Next
Next
Debug "<><><><><>< ARRAY READ"
; make sure there is a clear space for us to start on
Result = CopyEntity(#FLOOR, #PB_Any)
EntityPhysicBody(Result ,#PB_Entity_StaticBody)
SetEntityMass(Result, 10.0)
;- hide the originals
HideEntity(#WALL, #True)
HideEntity(#DOOR, #True)
HideEntity(#DUDE, #True)
; *** uncomment to see bounding boxes
;WorldDebug(#PB_World_DebugEntity) ; #PB_World_DebugEntity / #PB_World_DebugBody = no work
EnableWorldCollisions(1)
EnableWorldPhysics(1)
EntityLocate(#DUDE, 100,0,100)
;- START OF LOOP
Repeat
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_A)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_D)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_W)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_X)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
MouseX - MouseDeltaX() / 2
MouseY - MouseDeltaY() / 2
EndIf
PointPick(#PLAYER, ScreenWidth() / 2, ScreenHeight() / 2)
RotateCamera(#PLAYER, MouseY, MouseX, 0, #PB_Absolute)
RotateEntity(#DUDE, 0, MouseX, 0, #PB_Absolute)
MoveEntity(#DUDE, -KeyY * PickX() - KeyX * PickZ(), 0, -KeyY * PickZ() + KeyX * PickX())
CameraLocate(#PLAYER, EntityX(#DUDE), EntityY(#DUDE)+4, EntityZ(#DUDE))
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
http://www.bluemesapc.com/Downloads/FPS01.zip
Any help would be nice!
{{EDIT}}
OK I have just changed line 89 to:
Code: Select all
CreateEntity(#DUDE, MeshID(#DUDE), MaterialID(DOORtex),100,4,100)
EntityPhysicBody(#DUDE ,#PB_Entity_SphereBody , #PB_Entity_AbsoluteBodyMove)
SetEntityMass(#DUDE, 1.0)
{{ / EDIT }}
OK now someone can attempt Joakims MAZE as I have other ideas!



