'Ello all,
I have been trying to get my trees to randomly spawn on top of my object terrain. I have been successfull in getting the trees to spawn at random cords, but am having a problem with keeping them on the terrain. They seem to spawn on the terrain and off of the terrain..
Here is my code (compliments of tehcoderer)
This is the first part, the loading of the original tree, and the instancing for the rest of them.
Load object "treesFtree1ftree1.dbo",3
scale object 3,30,10,30
set alpha mapping on 3,100
Position object 3, rnd(2000),rnd(2000),500
for t=4 to 200
instance object t,3
position object t, rnd(8000),0,rnd(8000)
c#= get terrain ground height (1, object position x (t), Object position z (t))
position object t, object position x (t), c# , object position z (t)
next t
This next bit is the collision, distance viewed.
for t=4 to 200
d#=(camera position x()-object position x(t))^2+(camera position z()-object position z(t))^2
if d#>(450^2)
exclude object on t
else
exclude object off t
if d#<400.0
xdif#=object position x(t)-camera position x()
zdif#=object position z(t)-camera position z()
angle#=atanfull(xdif#,zdif#)
x#=camera position x()-(sin(angle#)*(20.0-sqrt(d#)))
z#=camera position z()-(cos(angle#)*(20.0-sqrt(d#)))
y#=get terrain ground height(1,x#,z#)+9.0
position camera x#,y#,z#
endif
endif
next t
Thanks in advnace to those who would help me.
Cheers,
Dave