Quote: "As for Multi-Texturing, you'll have to add an extra set of Texture Co-ordinates. DBP supports upto 8, but this has to be changed using the FVF Code."
Ahhh, that makes perfect sense. Thanks for that.
----------------------
Raven, here's the snippet. I might as well post it anyway, since memblocks aren't secrets these days.
(Press space to get rid of matrix once generated)
set display mode 1024,768,32
sync on : sync rate 0
color backdrop rgb(128,128,128)
autocam off
position camera 0,10,0
set camera range 1,10000
Memblock=1 `Memblock number
Polygons=1000 `Number of polygons
fvf=338
global Matrix=1
Width=100
Height=100
xsegs=10
zsegs=10
make matrix Matrix,Width,Height,xsegs,zsegs
randomize matrix Matrix,5 : update matrix Matrix
Plot(Matrix,Width,Height,xsegs,zsegs)
Matrix(Memblock,fvf,Matrix,Width,Height,xsegs,zsegs)
for i = 2 to ((Width+1)*(Height+1))+2
if object exist(i) then delete object i
next i
do
text 20,20,str$(screen fps())+" - "+str$(statistic(1))
`controls
if upkey() then move camera 1
if downkey() then move camera -1
if leftkey() then turn camera left 1
if rightkey() then turn camera right 1
if shiftkey()
pitch camera up 90
move camera 1
pitch camera down 90
endIf
if controlkey()
pitch camera up 90
move camera -1
pitch camera down 90
endIf
if spacekey()=1
if matrix exist(1) then delete matrix Matrix
endif
sync
loop
function Plot(Matrix,Width,Height,xsegs,zsegs)
tile_x#= width/xsegs
tile_z#= height/zsegs
Range=(xsegs+1)*(zsegs+1)
Modify_x=0
Modify_z=0
for x = 2 to Range+1
make object cube x,1
YHeight#=get ground height(Matrix,Modify_x,Modify_z)
position object x,Modify_x,YHeight#,Modify_z
Modify_x=Modify_x+tile_x#
if Modify_x>Width
Modify_x=0
Modify_z=Modify_z+tile_z#
endif
next x
endfunction
function Matrix(Memblock,fvf,Matrix,Width,Height,xsegs,zsegs)
Byte_Size=36
a_tile_x#= Width/xsegs
a_tile_z#= Height/zsegs
btile_x#= xsegs
btile_z#= zsegs
Modify=12
Range=(xsegs+1)*(zsegs+1)
Vertices=Range*6
`Memblock and format
make memblock Memblock,12+(Vertices*Byte_Size)
write memblock dword 1,0,fvf
`Setup vertex storage
write memblock dword 1,4,Byte_Size
write memblock dword 1,8,Vertices
for a=2 to Range+1
x#=object position x(a)
y#=object position y(a)
z#=object position z(a)
Modifier1=a+btile_x#+2
Modifier2=a+btile_x#+1
if object exist(a-1) then y1#=object position y(a-1)
if object exist(a+1) then y2#=object position y(a+1)
if object exist(Modifier1) then y3#=object position y(Modifier1)
if object exist(Modifier2) then y4#=object position y(Modifier2)
`First vertex
write memblock float 1,Modify,x#
write memblock float 1,4+Modify,y#
write memblock float 1,8+Modify,z#
write memblock float 1,12+Modify,0
write memblock float 1,16+Modify,0
write memblock float 1,20+Modify,-1
write memblock dword 1,24+Modify,rgb(0,rnd(128),0)
write memblock float 1,28+Modify,0
write memblock float 1,32+Modify,0
Modify=Modify+36
`Second Vertex
write memblock float 1,Modify,x#+a_tile_x#
write memblock float 1,4+Modify,y2#
write memblock float 1,8+Modify,z#
write memblock float 1,12+Modify,0
write memblock float 1,16+Modify,0
write memblock float 1,20+Modify,-1
write memblock dword 1,24+Modify,rgb(0,rnd(128),0)
write memblock float 1,28+Modify,1
write memblock float 1,32+Modify,0
Modify=Modify+36
`Third Vertex
write memblock float 1,Modify,x#+a_tile_x#
write memblock float 1,4+Modify,y3#
write memblock float 1,8+Modify,z#+a_tile_z#
write memblock float 1,12+Modify,0
write memblock float 1,16+Modify,0
write memblock float 1,20+Modify,-1
write memblock dword 1,24+Modify,rgb(0,rnd(128),0)
write memblock float 1,28+Modify,1
write memblock float 1,32+Modify,1
Modify=Modify+36
`Fourth Vertex
write memblock float 1,Modify,x#
write memblock float 1,4+Modify,y4#
write memblock float 1,8+Modify,z#+a_tile_z#
write memblock float 1,12+Modify,0
write memblock float 1,16+Modify,0
write memblock float 1,20+Modify,-1
write memblock dword 1,24+Modify,rgb(0,rnd(128),0)
write memblock float 1,28+Modify,0
write memblock float 1,32+Modify,1
Modify=Modify+36
`Fifth Vertex
write memblock float 1,Modify,x#
write memblock float 1,4+Modify,y#
write memblock float 1,8+Modify,z#
write memblock float 1,12+Modify,0
write memblock float 1,16+Modify,0
write memblock float 1,20+Modify,-1
write memblock dword 1,24+Modify,rgb(0,rnd(128),0)
write memblock float 1,28+Modify,0
write memblock float 1,32+Modify,0
Modify=Modify+36
write memblock float 1,Modify,x#+a_tile_x#
write memblock float 1,4+Modify,y3#
write memblock float 1,8+Modify,z#+a_tile_z#
write memblock float 1,12+Modify,0
write memblock float 1,16+Modify,0
write memblock float 1,20+Modify,-1
write memblock dword 1,24+Modify,rgb(0,rnd(128),0)
write memblock float 1,28+Modify,1
write memblock float 1,32+Modify,1
Modify=Modify+36
next a
Make mesh from memblock 1,1
delete memblock Memblock
Make object 1,1,1
set object cull 1,0
endfunction
The only problem with the snippet is that a little bit the last farthest right x segment and the farthest forward z segment still draw out additional lines. I'll fix that up tomorrow before I explore multi-texturing.
Basically how it works is in 3 steps.
1.) Create a matrix and randomize it.(Smooth it if you like)
2.) Plot cubes on each x,z segment.
3.) Retrieve the location of each object, get its height, and then draw a plane. The vertices are then positioned based on the height of the object.
Actually simpler than I thought once I got the flat plane going.
Only other problem I can think of, is that turning culling on will hide too many polygons on smaller memblock matrices which is weird.
A book? I hate book. Book is stupid.
(Formerly known as Yellow)
