Large Levels

Blitz3D Forums/Blitz3D Beginners Area/Large Levels

Buggy(Posted 2006) [#1]
How does one go about creating large levels? If I was to make a big, outdoor level, could I have the position of every tree in an array, and then load one tree and CopyEntity the other trees into their positions? Does this take too much memory? Should I instead check if the trees are within viewing range every loop and if so, put them there if they aren't there already and get rid of old ones? Is there an efficient way to do all of this?


caff_(Posted 2006) [#2]
Well, you could try distance culling like you say, i.e. check the distance from camera to objects, and use HideEntity and ShowEntity. Note that trees that are behind the camera will not be rendered, so its pointless to check those.

Also, use types instead of arrays, as types are very fast to loop round. I use a type even if it is just storing the mesh (tree in your case).

e.g.

Type tree
   field mesh
End Type

tree_original = LoadMesh("tree.b3d")

for x = 1 to 10
   for z = 1 to 10
      newtree.tree = New tree
      newtree\mesh = CopyMesh(tree_original)
      y = 0 ;change this so it finds the height on the landscape at position x, z
      PositionEntity newtree\mesh, x, y, z
   next
next



Naughty Alien(Posted 2006) [#3]
my suggestion is that after you done with your level, including lightening etc...load it in to game with LoadAnimMesh("My_Level.b3d) and blitz will do culling for you very nicely...when I did that for my large outdoor level, blitz use to render half of the poly count maximum...its really working nice..every additional check in is I think slower than actual procedure I just mentioned..and try to split your level in smaller chunks, so more chunks better will be culling..


Andy(Posted 2006) [#4]
do a search for large levels or large world in the B3D forum or the Miscellaneous forum.

Andy


Buggy(Posted 2006) [#5]
Thanks guys.

@SonicFactory: I use types for that too... I'm saying that I use arrays for the grid position of the trees.

I need the trees to be independent of the level. Think of them as powerups of weapons.


b32(Posted 2006) [#6]
I saw a code in the archives that used pivots where the objects should be, then when in view the objects were copied onto the pivots and when not in view, the objects were deleted. The idea was that a large amount of entities slows the rendering down and it is better to delete entities than to hide them. The code used a starfield as an example, however I can't find it.


Shambler(Posted 2006) [#7]
I divide the level into chunks and for each chunk I have a list of which other chunks can be seen from this one, then I just update the hide/show of the chunks when the player enters a new chunk. This keeps the poly count low.

You could use portals too but for my money just using the simple method above ( its called a potentially visible set ) is enough.