I wrote this down during my systems analysis class. So I don't have a way of testing it, but I think it'll work.
Remember, I said I THINK this will work. I made this before for a snowboard game I never finished, but it was maybe 2 years ago. So if this doesn't work, I'll dig it up and post something thats accurate.
rem a-e-b
rem | |
rem g h
rem | |
rem c-f-d
size# = 50
make object plain 1, size#,size#
randomize timer()
make matrix 1, 1000,1000,30,30
randomize matrix 1, 100
update matrix 1
rem Plane is assumed its a square (even length and width)
rem points A,B,C,D are the 4 corners of the plane.
rem E,F,G,H are midpoints
DO
a.x=x#-(size#/2)
a.z=z#+(size#/2)
a.y=get ground height(1,a.x,a.z)
b.x=x#+(size#/2)
b.z=z#+(size#/2)
b.y=get ground height(1,b.x,b.z)
c.x=x#-(size#/2)
c.z=z#-(size#/2)
c.y=get ground height(1,c.x,c.z)
d.x=x#+(size#/2)
d.z=z#-(size#/2)
d.y=get ground height(1,d.x,d.z)
e.y=(a.y+b.y)/2
f.y=(c.y+d.y)/2
f.y=(a.y+c.y)/2
g.y=(b.y+d.y)/2
y#=(e.y+f.y+g.y+h.y)/4
anglex#=xangle(e.y, f.y,size#)
anglez#=zangle(g.y, h.y, size#)
position object 1,x#,y#,z#
rotate object 1,anglex#,0,anglez#
sync
LOOP
function xangle(mid_e#, mid_f#, size#)
xang# = asin(mid_e# - mid_f# / size#)
endfunction xang#
function zangle(mid_g#, mid_h#, size#)
zang# = asin(mid_g# - mid_h# / size#)
endfunction zang#