Game Runs Slow

Blitz3D Forums/Blitz3D Beginners Area/Game Runs Slow

Terry B.(Posted 2006) [#1]
I have a nice little terrain, and a little player (.b3d animation) and a skybox. I made my skybox useing a modified version of the function in the "Castle" sample by mak. But, when I run the program without the skybox, it runs at about 45 fps. When I run it with the skybox, it runs at 3 or 4 fps, but only when I am in view of a corner, when I'm not, it runs at about 40. Whats going on?


Sir Gak(Posted 2006) [#2]
You have discovered gremlins in your PC's inner space, and they are eating your CPU cycles. You must debug them!


GfK(Posted 2006) [#3]
Meanwhile back on planet earth, can you post some code?


Sir Gak(Posted 2006) [#4]
Well, yeah, that too.


Terry B.(Posted 2006) [#5]
This is what I'm using as the skybox

 
Global Sky = loadskybox()
EntityOrder sky,10

Then in the main loop
PositionEntity sky,EntityX(player\mesh),Entity(player\mesh),EntityZ(player\mesh)

The LoadSkyBox Function taken from Castle sample
Function LoadSkyBox()
	m=CreateMesh()
	;front face
	b=LoadBrush("media\terrain\front.jpg",49 )
	s=CreateSurface( m,b )
	AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
	AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	FreeBrush b
	;right face
	b=LoadBrush("media\terrain\right.jpg",49 )
	s=CreateSurface( m,b )
	AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
	AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	FreeBrush b
	;back face
	b=LoadBrush("media\terrain\back.jpg",49 )
	s=CreateSurface( m,b )
	AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
	AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	FreeBrush b
	;left face
	b=LoadBrush("media\terrain\left.jpg",49 )
	s=CreateSurface( m,b )
	AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
	AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	FreeBrush b
	;top face
	b=LoadBrush("media\terrain\up.jpg",49 )
	s=CreateSurface( m,b )
	AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
	AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	FreeBrush b
	;bottom face	
	b=LoadBrush("media\terrain\sky.png",49 )
	s=CreateSurface( m,b )
	AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1
	AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0
	AddTriangle s,0,1,2:AddTriangle s,0,2,3
	FreeBrush b
	ScaleMesh m,100,100,100
	FlipMesh m
	EntityFX m,1
	Return m
End Function



ingenium(Posted 2006) [#6]
did you call the func in the main cycle?
if yes, you have to call it out of the main cycle...
ex:
global a = 0
while not a > 20
 LoadSkyBox()
 a = a + 1
wend


You'll have about 20 skies...

global a = 0
LoadSkyBox()
while not a >20
 a = a + 1
wend


You'll have one sky


Terry B.(Posted 2006) [#7]
Thanks everyone, it turned out I was useing to big a picture for the brushes.


Trader3564(Posted 2007) [#8]
would there be a way to make a skybox without brushes?


Matty(Posted 2007) [#9]
Gobbo - create your skybox in a 3d app as a cube, texture the insides and invert the normals, then simply load the object, and treat as a normal skybox cube.


Trader3564(Posted 2007) [#10]
how do i "invert the normals" :) ?


Matty(Posted 2007) [#11]
The flipmesh command in b3d will invert the normals. Alternatively most 3d apps you can do the same although I might go by different names.


Trader3564(Posted 2007) [#12]
im having difficulties texturing... i used to know how todo this. what commands where used for texture mapping again? (repositiong the texturecordinates).


ingenium(Posted 2007) [#13]
Blitz Docs > 3D - Category > Texture > TextureCoords

texture - name of texture
coords -
0: UV coordinates are from first UV set in vertices (default)
1: UV coordinates are from second UV set in vertices


;)


Trader3564(Posted 2007) [#14]
doh.. how come i missed that... thanks!