Gem Placement on Static Mesh

Blitz3D Forums/Blitz3D Beginners Area/Gem Placement on Static Mesh

CodeOrc(Posted 2007) [#1]
Hi All,

I was wondering what is the best method for Gem Placement on Static Mesh.

Meaning, I have a large .3ds mesh with rolling hills. I want to have like 100 collectible gems on it randomly placed.

How can I get each gem to follow/place itself just above my mesh without manually placing each one or having them go into the mesh?

thx for any help :)


Stevie G(Posted 2007) [#2]
Set the static mesh to be pickable - entitypickmode 2 then use linepicks.

Assuming the mesh is 200x200 units square and the maximum height of the mesh is 100 units ..


gem = loadmesh("mygem")

for l = 1 to 100 

  x# = rand(-100,100 )  
  z# = rand(-100,100 )
  copy = copyentity( gem )

  linepick x, 110, z, 0,-120,0
  positionentity copy, x,pickedy()+1, z

next




You may want to add in checks to make sure there aren't 2 gems at the same point.

If you need the gem to align to the landscape you could use ...

aligntovector pickednx(), pickedny(), pickednz(), 2

after positioning.

Stevie


CodeOrc(Posted 2007) [#3]
that works great, thank you.

I'll give it a shot across my whole map and let you know it it turns out

:)


CodeOrc(Posted 2007) [#4]
Ok, I have spreading 6000 items across my map.

I notice a bit performance difference from 1k to 6k items. Is there a framerate friendly way to get 9k items with 5 faces each across my map?


Jsoren(Posted 2007) [#5]
reducing the camera range, and hiding all the items that are not visible are some of the ways you can do that.


Stevie G(Posted 2007) [#6]
Reducing the camera range will automatically cull everything outwith the view frostrum - don't think it's necessary to hide and show 9000 items - now that will be slooooow. You could put a bit of fog in there or use entityautofade etc..

Depends what yo want to do though - what frame rate hit do you actually get?


Ben(t)(Posted 2007) [#7]
you could do this

for i=0 to 100
positionentity gem(i),rnd(-150,150),50,rnd(-150,150)
next

then you use
for i=0 to 100
translateentity gem(i),0,-.5,0
next

and they will fall down on top of the hills


CodeOrc(Posted 2007) [#8]
I am getting around 150fps with 1000 gems....and around 10fps with 12000.

Today I will do the CameraRange and fog, and if needed, the autohide and see how that goes.

I appreciate all you guys input, thank you :)


Dreamora(Posted 2007) [#9]
With 12000 you will kill any GPU most likely. Implement some kind of oct tree culling or the like to remove the massive card load.


Jsoren(Posted 2007) [#10]
@stevie G: i meant cam range OR hideing, since there are some instances that camerarange just wont do what you need.

@CodeOrc: thats ALOT of gems, even hiding most of them will cause alittle slowdown just because of the stress of trying to keep track of 12000 items.


CodeOrc(Posted 2007) [#11]
Ok, can I ask another question then?

How do people using B3D get mega grass across their terrains? Is that not like 10k sprites to make up all that grass?

And if so, how are they kept track of?

thx :)


Jsoren(Posted 2007) [#12]
well, it depends, usually the ground would be textured like grass and the actual grass clumps would be spread around. ive never had to make grass all arcross a terrain fairly densly, but i suppose if i did i would probly make decent amount of grass sprites around the player, keep track of their x,z coords in relation to the player, and when one was too far away him, reposition it in the opposit direction of him, using appropriate alpha levels to make sure they blend (if that makes any sence). theres also a grass demo that comes in the blitz3d samples.


Stevie G(Posted 2007) [#13]

How do people using B3D get mega grass across their terrains? Is that not like 10k sprites to make up all that grass?



Using individual sprites would be a killer for dense vegitation due to the simple fact that each is a new surface. The more surfaces you use the more it kills the frame rate. Clumps of quads created as single surfaces is the way to go for this.

Stevie


CodeOrc(Posted 2007) [#14]
@ Stevie- Could you show me an example of how to do this? I am confused by your idea.