Loading thousands of mesh trees, fast?

Blitz3D Forums/Blitz3D Programming/Loading thousands of mesh trees, fast?

nazca(Posted 2007) [#1]
Hey there, in my game, I need to load and position quite a few (maybe over a thousand) low-poly tree models.

The problem is, you can imagine that code like this is very slow:
for n=1 to 1000
t.tree = new tree
t\id = loadmesh("tree.b3d")
next

is there a way I can speed this up? Maybe by using copyEntity or CopyMesh?

Thanks


big10p(Posted 2007) [#2]
Yes - don't have 1000 different trees. Load X amount and reuse them.


Vertigo(Posted 2007) [#3]
Try something like this... even though there are better ways of optimizing it.

[CODE]

Tree1=loadmesh("tree1.b3d")
Tree2=loadmesh("tree2.b3d")
Tree3=loadmesh("tree3.b3d")

hideentity tree1
hideentity tree2
hideentity tree3

type tree
field entity
field x,y,z
end type

Number_of_trees% = 1000

for MakeTrees = 1 to Number_of_trees%

Type_of_tree=Rand(0,2)
Tree_x# = Rand(-100,100)
Tree_y# = 0 ; put all trees in y at 0
Tree_z# = Rand(-100,100)

T.Tree = new Tree
T\X = Tree_X#
T\Y = Tree_Y#
T\Z = Tree_Z#

Select Type_of_tree

case 0
T\entity = copyentity tree1

case 1
T\entity = copyentity tree2

case 2
T\entity = copyentity tree3

end select

positionentity T\entity,T\X, T\Y, T\Z

next

[/CODE]

This saves on surfaces etc, but will be excessive due to poly count. I would suggest creating the trees using types like above, but use a function and have a tree constructor.

Good luck,

Scott


boomboom(Posted 2007) [#4]
unless you spesifically did todo your own tree routine, i would consider buying this: http://blitzbasic.com/Community/posts.php?topic=72001


Beaker(Posted 2007) [#5]
mytree = loadmesh("tree.b3d")
HideEntity mytree
for n=1 to 1000
t.tree = new tree
t\id = CopyEntity(mytree)
next



puki(Posted 2007) [#6]
Or you can buy this:
http://gothasoft.com/Default.aspx?tabid=81

Depending on hardware, you can achieve tens of thousands of trees.




boomboom(Posted 2007) [#7]
.


boomboom(Posted 2007) [#8]
beat you too it puki.

I always like to buy lib's. If you think about it, it would take you longer than 2 hours to program a tree lib as good as treeparty (if ever, since the developer has many years experiance with tree systems)

but for 2 hours work at min wage will get you it.


Wings(Posted 2007) [#9]
http://www.blitzbasic.com/Community/posts.php?topic=72044

Why Buy stupid libs. then Blitz3d has the power built in. ?
Somthing like this. ?






boomboom(Posted 2007) [#10]
lol...well I know which one I would like my game to look like.


Naughty Alien(Posted 2007) [#11]
:)


big10p(Posted 2007) [#12]
:P


Jack(Posted 2007) [#13]
This is great


jfk EO-11110(Posted 2007) [#14]
As far as I see treeparty trees have about 10 times more tris than the ones by Wings. You need the right polycount for every kind of job IMHO. So with a little polish Wings trees ain't that bad.


boomboom(Posted 2007) [#15]
you can design your own trees in treeparty. Even loading in just normal model files and using them as trees within the system.


Wings(Posted 2007) [#16]
Never mind the tris.
My gfx card can handle 1.000.000 Tris and still have 60 fps

Thoe avarege gfx card can handle upp to 250.000 tris over that is trouble.

My gaming pc x800 handels 1.300.000 tris 60 fps
My new laptop cryes att 500.000 tris. 60 fps
My old laptop cyres at 100.000 tris 59 fps


Sir Gak(Posted 2007) [#17]
Simple solution for all this:

Everyone in the world needs to upgrade their vid cards!

Problem solved!

:)