Okay so here's what I've done - I've loaded an image and gathered the color byte values through the memblock commands. Using a matrix it was very easy to (1 dbpro unit = 3ft) read the color values, * it by 0.33 and raise the matrix height at each corresponding point and create a matrix terrain from the image - but the scale is always wrong and when I scale it to the correct size - the amount of detail becomes lacking - as it must i suppose. The trouble is I need to create HUGE landscapes with as much detail as possible while using very little system resource. There are two options for the user which also keep me from using the Adv. Terrain commands - one being that every landscape will be terraformable and the other is purely to do with the scaling of each terrain. The user has the option to load a height map - each map can be different and the scale must be adjusted... so I'm wondering - How do I split up an image so that different portions of that image can be applied to different objects i use as terrains (like sections of an adv. terrain object) - How do I then split up an object into sections for said images? I've already gathered how to create vertices but not how to separate an image or a plane into sections. Any method or small examples would really help - but I am predominately looking for understanding.
EDIT-
Okay I've figured out the image splitting for the most part. I have to designate a limit for the amount of pixels when using a memblock... like this sort of
ImagesizeX=Image Width (number)
ImageSizeY=Image Height (number)
If ImageSizeX > (((Value in relation to pixel to feet scale)))
ImageSizeWidth=ImageSizeX/(((How many times it must be divided to = maximum image size for object)))
endif
If ImageSizeY > (((Value in relation to pixel to feet scale)))
ImageSizeHeight=ImageSizeY/(((How many times it must be divided to = maximum image size for object)))
endif
For Split=Num_After_Divide (((How many times it was divided to = maximum image size for object)))
Xstart=ImageSizeWidth/Split
Ystart=ImageSizeHeight/Split
For X=Xstart to Width_After_Split step 4
For Y=Ystart to Height_After_Split step 4
(((Invert the image for the object)))
location = ((Y-1)*(((The image width after split))) + X-1)*4 + 12
(((Memblock s***)))
Next Y
Next X
Next Split
That's just an example but it revolves around the same premise - splitting an image and I suppose in one way or another it can be used to divide one object into several. But then the question becomes - HOW do I attain which vertices on each side of every object to align with the others? - (As to keep the terrain seamless).
The only limitation I can see for the user is that the pixel to feet ratio isn't stated any where... so depending on how far the image of the terrain was taken in conjunction to the camera which took the image (of the real world heightmap) - 1 pixel could = anywhere from 1 foot to a million feet. The scale of the image (pixel - foot ratio) would be what you use to divide the image into segments - you then would make a memblock and create an image from it - then apply it to the object through another memblock (or set of them for multiple objects) - The smaller the objects - the more you hide, the less amount of cpu/ram used. Oh the life of a programmer!!!
That's all for now
EDIT II:
Here's what I've got but I'm getting lost in my own work!
SET DISPLAY MODE DESKTOP WIDTH(), DESKTOP HEIGHT(), 32, 1, 4, 0
LOAD IMAGE "Images\Height Maps\Heightmap.bmp", 1, 1
HeightMap=Get_Free_Memblock()
MAKE MEMBLOCK FROM IMAGE HeightMap, 1
Width#=MEMBLOCK DWORD(HeightMap, 0)
Height#=MEMBLOCK DWORD(HeightMap,4)
AUTOCAM OFF
Width_To_3DX# = Width#*3.33
Height_To_3DZ# = Height#*3.33
POSITION CAMERA 0, -50, 20, 0
POINT CAMERA 0, Width_To_3DX#/2, 0, Height_To_3DZ#/2
Repeat
Inc DivideX#, 1.0
Until Width_To_3DX#/DivideX#=<500.0
Repeat
Inc DivideY#, 1.0
Until Height_To_3DZ#/DivideY#=<500.0
center text desktop width()/2, Desktop Height()/2, "Divide X by: "+Str$(DivideX#)+Chr$(10)+Chr$(13)+"Divide Y by: "+Str$(DivideY#)+Chr$(10)+Chr$(13)+Chr$(10)+Chr$(13)+"Press any key to continue..."
WAIT KEY
OffSetX=1
OffSetY=1
`Get a new memblock number and write the header for later converting into an image portion of the heightmap loaded.
`then apply how many times each x and y section shall be divided
For Split=1 to int(DivideX#)
NextMem=Get_Free_Memblock()
MAKE MEMBLOCK NextMem, ((Width#/(DivideX#)*(Height#/(DivideY#))*4)+12)
WRITE MEMBLOCK DWORD NextMem, 0, Width#/DivideX#
WRITE MEMBLOCK DWORD NextMem, 4, Height#/DivideY#
Depth=Memblock Dword (HeightMap,8)
WRITE MEMBLOCK DWORD NextMem, 8, Depth
For PosZ=Offsety to Height#/DivideY#-Split
For PosX=Offsetx to Width#/DivideX#-Split
location = ((posz-1)*(Width#/DivideX#-Split) + posx - 1)*4 + 12
Blue#=MEMBLOCK BYTE(HeightMap, Location)
Green#=MEMBLOCK BYTE(HeightMap, Location+1)
Red#=MEMBLOCK BYTE(HeightMap, Location+2)
Alpha#=MEMBLOCK BYTE(HeightMap, Location+3)
WRITE MEMBLOCK BYTE Nextmem, Location, Blue#
WRITE MEMBLOCK BYTE Nextmem, Location+1, Green#
WRITE MEMBLOCK BYTE Nextmem, Location+2, Red#
WRITE MEMBLOCK BYTE Nextmem, Location+3, Alpha#
Next PosX
Next PosZ
`Gather the size needed for each object
SizeX#=Width_To_3DX#/DivideX#
SizeY#=Height_To_3DZ#/DivideY#
`make the object
ObjTerrain=Make_Grid(SizeX#, SizeY#, SizeX#/10, SizeY#/10)
`position it and offset the image being used by the memblocks
POSITION OBJECT ObjTerrain, OffsetX, 0, OffsetY
Inc OffsetX, Width_To_3DX#/DivideX#
Inc OffsetY, Height_To_3DZ#/DivideY#
`create an image from the memblock and texture the corresponding object
ImageNumber=Get_Free_Image()
MAKE IMAGE FROM MEMBLOCK ImageNumber, NextMem
TEXTURE OBJECT ObjTerrain, ImageNumber
DELETE MEMBLOCK NextMem
Next Split
VecPoint=MAKE VECTOR3(1)
SET VECTOR3 1, Width_To_3DX#/2, 0, Height_To_3DZ#/2
Do
remstart
CameraDist#=Width_To_3DX#/10
Do
CamX#=NewXValue(Width_To_3DX#/2, Ang#, CameraDist#)
CamZ#=NewZValue(Height_To_3DZ#/2, Ang#, CameraDist#)
Ang#=Wrapvalue(Ang#+0.0)
`Zooming
Newmousez = MousemoveZ()
If oldmousez <> newmousez
If oldmousez < newmousez then mousezz=-10
If oldmousez > newmousez then mousezz=10
Oldmousez =Mousemovez()
CameraDist#=CameraDist#+MouseZz
Position camera 0,CamX#,CameraDist#,CamZ#
SET VECTOR3 1, Width_To_3DX#/2, CenterPos#, Height_To_3DZ#/2
POINT CAMERA 0, X VECTOR3(1), Y VECTOR3(1), Z VECTOR3(1)
Mousezz=0
endif
`Rotating
If mouseclick()=2
Newang#=MousemoveX()
If oldang# <> NEWANG#
If Oldang# < Newang# then Mousexx#=5
If oldang# > Newang# then Mousexx#=-5
Oldang#=MousemoveX()
ang#=ang#+Mousexx#
Position camera 0,CamX#,CameraDist#,CamZ#
SET VECTOR3 1, Width_To_3DX#/2, CenterPos#, Height_To_3DZ#/2
POINT CAMERA 0, X VECTOR3(1), Y VECTOR3(1), Z VECTOR3(1)
else
MouseXX#=0
endif
endif
`Changeing Center
If mouseclick()=4
Newang#=MousemoveY()
If oldang# <> NEWANG#
If Oldang# < Newang# then MouseYY#=-10
If oldang# > Newang# then MouseYY#=10
Oldang#=MousemoveY()
CenterPos#=CenterPos#+MouseYY#
Position camera 0,CamX#,CameraDist#-(MouseYY#*2),CamZ#
SET VECTOR3 1, Width_To_3DX#/2, CenterPos#, Height_To_3DZ#/2
POINT CAMERA 0, X VECTOR3(1), Y VECTOR3(1), Z VECTOR3(1)
else
MouseXX#=0
endif
endif
Remend
CONTROL CAMERA USING ARROWKEYS 0, 10.0, 3.3
loop
function Get_Free_Object()
repeat
inc obj,1
until object exist(obj) = 0
endfunction obj
Function Get_Free_Memblock()
Repeat
inc mem
until MEMBLOCK EXIST(mem)=0
endfunction mem
Function Get_Free_Image()
repeat
inc img, 1
until IMAGE EXIST(img)=0
endfunction img
function create_memblock_object(mem,v)
make memblock mem,(v * 36) + 12
write memblock dword mem,0,338
write memblock dword mem,4,36
write memblock dword mem,8,v
endfunction
function create_vertex(mem,v,xpos#,ypos#,zpos#,nx#,ny#,nz#,color as dword,u#,v#)
write memblock float mem,12 + (v * 36),xpos#
write memblock float mem,16 + (v * 36),ypos#
write memblock float mem,20 + (v * 36),zpos#
write memblock float mem,24 + (v * 36),nx#
write memblock float mem,28 + (v * 36),ny#
write memblock float mem,32 + (v * 36),nz#
write memblock dword mem,36 + (v * 36),color
write memblock float mem,40 + (v * 36),u#
write memblock float mem,44 + (v * 36),v#
endfunction
function create_object(mem)
make mesh from memblock 1,mem
obj = Get_Free_Object()
make object obj,1,0
delete mesh 1
endfunction obj
function Make_Grid(sizex#,sizez#,tilex#,tilez#)
Number=Get_Free_Memblock()
Normals=MAKE VECTOR3(3)
Start=MAKE VECTOR3(2)
create_memblock_object(Number,6 * (tilex# * tilez#))
for z# = 0.0 to (tilez# - 1)
for x# = 0.0 to (tilex# - 1)
SET VECTOR3 2, 0, 0, 0
SET VECTOR3 3, X#, 0.0, Z#
Light#=DOT PRODUCT VECTOR3(2, 3)
ux# = x# / (tilex# - 1)
uy# = ((z# / (tilez# - 1)) * -1.0) + 1.0
create_vertex(Number,v,x#+1 * (sizex# / (tilex# - 1)),0.0,z# * (sizez# / (tilez# - 1)),Light#,Light#,Light#,rgb(255, 255, 255),ux#,uy#)
ux# = x# / (tilex# - 1)
uy# = (((z# / (tilez# - 1)) * -1.0) + 1.0) - (z# / ((tilez# - 1) + 1))
create_vertex(Number,v + 1,x# * (sizex# / (tilex# - 1)),0.0,(z#) * (sizez# / (tilez# - 1)),Light#,Light#,Light#,rgb(255, 255, 255),ux#,uy#)
ux# = (x# / (tilex# - 1)) + (x# / ((tilex# - 1) + 1.0))
uy# = ((z# / (tilez# - 1)) * -1.0) + 1.0
create_vertex(Number,v + 2,(x# + 1) * (sizex# / (tilex# - 1)),0.0,z# * (sizez# / (tilez# - 1)),Light#,Light#,Light#,rgb(255, 255, 255),ux#,uy#)
ux# = (x# / (tilex# - 1)) + (x# / ((tilex# - 1) + 1.0))
uy# = ((z# / (tilez# - 1)) * -1.0) + 1.0
create_vertex(Number,v + 3,(x# + 1) * (sizex# / (tilex# - 1)),0.0,z# * (sizez# / (tilez# - 1)),Light#,Light#,Light#,rgb(255, 255, 255),ux#,uy#)
ux# = x# / (tilex# - 1)
uy# = (((z# / (tilez# - 1)) * -1.0) + 1.0) - (z# / ((tilez# - 1) + 1))
create_vertex(Number,v + 4,x# * (sizex# / (tilex# - 1)),0.0,(z#) * (sizez# / (tilez# - 1)),Light#,Light#,Light#,rgb(255, 255, 255),ux#,uy#)
ux# = (x# / (tilex# - 1)) + (x# / ((tilex# - 1) + 1.0))
uy# = (((z# / (tilez# - 1)) * -1.0) + 1.0) - (z# / ((tilez# - 1) + 1))
create_vertex(Number,v + 5,(x# + 1) * (sizex# / (tilex# - 1)),0.0,(z#+1) * (sizez# / (tilez# - 1)),Light#,Light#,Light#,rgb(255, 255, 255),ux#,uy#)
inc v,6
next x#
next z#
obj = create_object(Number)
SET OBJECT NORMALS Obj
endfunction obj
The height map I used is
here
-Daryn
Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
