you can position grass models wherever you want, there is a function to get the ground height on a blitzterrain, You just use that function to place things on the ground. you can randomize the locations with rnd function or if you want to control where things are placed, you can either make a world editor and output a save file, or you can make a image map to use as a guide to place things.
I have done this before. first I make my height map, then using a new photoshop layer, I paint the areas I want things in(trees in my case). all one solid color. I save this painted area as a placement map
I then make a nested for loop to cross check the terrain and the color of the placement map in order to decide whether or not to place anything in that spot.
long story short, check map, if its green plant a tree.
you could really use this approach for any kind of object placement.
Here is another grass placement approach that I use for non static near field foliage. if you get a few folders full of different plant models and set them all to different ranges you get a pretty good foliage spread. It all just comes down to managing resources so that the game doesnt chunk to badly.
give this a go. you can use it freely, chop and change it rework it. it should give at least one idea.
Rem Project: Dark Basic Pro Project
Rem Created: Wednesday, July 17, 2013
Rem ***** Main Source File *****
`grass positioning vars--------------------------------------------------------------
`adjust these to your preferred detail
grassmax = 3000
grassrad# = 1000
`--------------------------------------------------------------
sync on
sync rate 60
hide mouse
// generate a grass texture for the matrix
grasstexture(1,255)
//make grass object
gosub grassobject
//set up matrix
gosub matrixsetup
//Load grass objects
gosub loadgrass
//setup player object
player = grassmax+1
make object cube player,12
position object player,5000,0,5000
hide object player
//scatter grass models
matrix_scatter(1,object position x(player),object position z(player),grassrad#,1,grassmax)
color backdrop rgb(108,235,235)
set ambient light 50
//main loop===============================================
do
grass_system(1,grassmax,grassrad#,4,1,8,0.3)
object_wasd(player,10)
object_mouselook(player)
ground_to_matrix(player,1)
text 0,0,"WASD + mouse to move"
text 0,20,"shift to run, ctl to walk"
sync
loop
//==========================================================
loadgrass:
`make an array, this will hold grass sway modifier data
dim multiplier#(grassmax)
for x = 2 to grassmax
clone object x,1,1
next x
return
matrixsetup:
make matrix 1,10000,10000,50,50
randomize matrix 1,100
prepare matrix texture 1,1,1,1
set matrix 1,0,0,1,1,1,1,1
update matrix 1
return
grassobject:
autocam off
position camera 50,10,-30
backdrop on
color backdrop 0
sync
`load some cones for the grass objects
for x = 1 to 50
make object cone x,10
scale object x,50,300+(rnd(100)),50
rotate object x,rnd(10),rnd(10),rnd(10)
color object x,rgb(10,rnd(200)+55,10)
position object x,rnd(100),0,rnd(10)
next x
sync
`take a picture for the bilboard texture
get image 2,0,0,screen width(),screen height()
sprite 1,0,0,2
size sprite 1,128,128
cls
paste sprite 1,0,0
delete image 2
get image 2,0,0,128,128
delete objects 1,100
delete sprite 1
`setup a cross bilboard grass object and texture it
make object plane 1,20,20
offset limb 1,0,0,10,0
make mesh from object 1,1
delete object 1
make object 1,1
delete mesh 1
make object plane 2,20,20
rot = 0
texture object 1,2
for x = 1 to 4
yrotate object 2,rot
make mesh from object x,2
rot = rot + 90
add limb 1,x,x
texture limb 1,x,2
offset limb 1,x, 0,10,0
next x
delete object 2
set object transparency 1,6
scale object 1,100,200,100
return
function grasstexture(imagenumber,size)
for x = 1 to size
for y = 1 to size
dot x,y,rgb(20+rnd(50),rnd(100)+55,20)
next y
next x
get image imagenumber,1,1,size,size
endfunction
function matrix_scatter(matrixno,x#,z#,rad,startno,endno)
//scatter models around matrix
for x = startno to endno
obx = x#-rad +rnd(rad*2)
obz = z#-rad +rnd(rad*2)
position object x, obx,get ground height(matrixno,obx,obz), obz
Xrotate object x,object angle x(x)-9+rnd(18)
next x
endfunction
function grass_system(startno,finishno,radius#,transparencymode,sway,swaydegree#,swayspeed#)
for x = startno to finishno
// set object transparency, this is more for when the routine is being used for more than one object group
set object transparency x,transparencymode
//sway grass======================================================
if sway = 1
if object angle x(x)<=(0-(swaydegree#/2)) then multiplier#(X) = swayspeed#
if object angle x(x)>=(swaydegree#/2) then multiplier#(X) = 0-swayspeed#
xrotate object x,object angle x(x)+multiplier#(X)
endif
//this section is to determine which side of the player grass is placed when walking
if keystate(17) = 1 then Angle = camera angle y()-90 + rnd(180)
if keystate(31) = 1 then Angle = camera angle y()+90 + rnd(180)
if keystate(30) = 1 then Angle = camera angle y() - rnd(180)
if keystate(32) = 1 then Angle = camera angle y() + rnd(180)
//check for grass outside perimeter===============================
if scancode()<> 0 `this is for first run because as all models would be placed in one spot after no keypress to set the angle
if (object position x(x) > camera position x()+radius#) or (object position x(x) < camera position x()-radius#) or (object position z(x) > camera position z()+radius#) or (object position z(x) < camera position z()-radius#)
CirX_Obj = sin(Angle) * radius# + camera position x()
CirY_Obj = cos(Angle) * radius# + camera position z()
position object x, CirX_Obj,get ground height(1,cirx_obj,ciry_obj), CirY_Obj
xrotate object x,object angle x(x)-9+rnd(18)
yrotate object x,rnd(360)
endif
endif
next x
endfunction
//mouselook tied to object
function object_mouselook(object)
xrotate camera 0,camera angle x()+mousemovey()
yrotate object object,object angle y(object)+mousemovex()
rotate camera 0,camera angle x(),object angle y(object),object angle z(object)
endfunction
//WASD tied to an object
function object_WASD(object,speed#)
if shiftkey() = 1 then speed# = speed# *2
if controlkey() = 1 then speed# = speed#/2
if keystate(17) = 1
move object object, speed#
walking = 1
endif
if keystate(31) = 1
move object object, negative(speed#)
walking = 1
endif
if keystate(30) = 1
move object left object, speed#
walking = 1
endif
if keystate(32) = 1
move object right object, speed#
walking = 1
endif
position camera 0,object position x(object),72+object position y(object),object position z(object)
if keystate(17) = 0 and keystate(31) = 0 and keystate(30) = 0 and keystate(32) = 0
walking = 0
//if sound playing(steps) = 1 then stop sound steps
endif
//if walking = 1 and sound playing(steps) = 0 then loop sound steps
endfunction walking
//sets an objects y position to the matrix ground height
function ground_to_matrix(object,matrixno)
position object object,object position x(object),get ground height(matrixno,object position x(object),object position z(object)),object position z(object)
endfunction
//simple negative number function
function negative(number#)
neg# = 0-number#
endfunction neg#
I'm not a complete idiot -- Some parts are just missing.