Quote: "Just throwing this out there as some other ideas: the use of a single heightmap image has a few limits - including speed, size, memory usage (at once). A variation for virtually unlimited size would be to use a series of smaller sized heightmaps, say 256x256 or even smaller. Load them into the memblock on demand - or convert them into arrays ahead of time and load in the data as arrays on demand based on virtual matrix position."
I've thought about that. Perhaps I'll add it in the future. It'll go right in with the variations in detail. I'll probably change the code to load 10 tiles instead of each one.
Sidenote: I dont think an array would be that much faster than a bitmap (8bit), because a bitmap is just a strain of numbers with a header.
Quote: "I'm gonna have to play around with this idea."
That's exactly why I'm posting this
I'm working on creating objects from memblocks. so far I've recreated the plain object successfully. Just gotta flip it on it's side and make a matrix out of it.
edit: added a picture of the plain
edit2: well I've accidentally saved a different project over this one. Back to square one T_T
edit3: I don't want to lose this again.
set display mode 1280,1024,32
sync on : sync rate 0
hide mouse
load image "texture.jpg",1
matrix(1,500,500,50,50)
position camera 0,10,-10
point camera 0,0,0
do
`set cursor 0,0
`print get memblock size(1)
do_camera()
sync
loop
end
function matrix(id,width,height,xsegment,zsegment)
number_of_vertices = (xsegment+1)*(zsegment+1)
number_of_faces = xsegment*zsegment*2
size_of_facedata = number_of_faces*7
offset_to_normals = 32+number_of_vertices*12
offset_to_faces = offset_to_normals+number_of_vertices*12
offset_to_uv = offset_to_faces+size_of_facedata*4
make memblock id,offset_to_uv+number_of_vertices*8
`number of vertices
write memblock dword id,0,number_of_vertices
`offset to vericle data
write memblock dword id,4,32
`number of normals
write memblock dword id,8,number_of_vertices
`offset to normals data
write memblock dword id,12,offset_to_normals
`number of faces
write memblock dword id,16,number_of_faces
`offset to face data
write memblock dword id,20,offset_to_faces
`size of face data
write memblock dword id,24,size_of_facedata
`offset to uv data
write memblock dword id,28,offset_to_uv
`verticle data
for y = 0 to zsegment
for x = 0 to xsegment
write memblock float id,32+x*12+(xsegment+1)*12*y ,(width/xsegment)*x
write memblock float id,32+x*12+(xsegment+1)*12*y+4,0
write memblock float id,32+x*12+(xsegment+1)*12*y+8,(height/zsegment)*y
next x
next y
`normals data
for x = 0 to number_of_vertices-1
write memblock float id,offset_to_normals+12*x ,0
write memblock float id,offset_to_normals+12*x+4,0
write memblock float id,offset_to_normals+12*x+8,-1
next x
`face data
for y = 0 to zsegment-1
for x = 0 to xsegment-1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+0,3
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+4,(xsegment*y)+x+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+8,(xsegment*y)+x+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+12,(xsegment*y)+x
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+16,(xsegment*y)+x
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+20,(xsegment*y)+x+(xsegment)+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+24,(xsegment*y)+x+(xsegment)+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+28,3
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+32,(xsegment*y)+x+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+36,(xsegment*y)+x+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+40,(xsegment*y)+x+(xsegment)+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+44,(xsegment*y)+x+(xsegment)+1
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+48,(xsegment*y)+x+(xsegment)+2
write memblock dword id,offset_to_faces+x*56+xsegment*56*y+52,(xsegment*y)+x+(xsegment)+2
next x
next y
`uv data
for y = 0 to zsegment
for x = 0 to xsegment
write memblock float id,offset_to_uv+x*8+(xsegment+1)*8*y ,(1/xsegment)*x
write memblock float id,offset_to_uv+x*8+(xsegment+1)*8*y+4,(1/zsegment)*y
next x
next y
makeoutput()
make mesh from memblock 1,1
make object 1,1,1
set object 1,0,1,1
endfunction
function makeoutput()
if file exist("output.txt") then delete file "output.txt"
open to write 1,"output.txt"
write string 1,"memblock size: " + str$(get memblock size(1))
for i = 0 to get memblock size(1)-4
string$ = str$(i) + ": " + str$(memblock byte(1,i)) + " " + str$(memblock byte(1,i+1)) + " " + str$(memblock byte(1,i+2)) + " " + str$(memblock byte(1,i+3))
write string 1,string$
i = i+3
next i
endfunction
function do_camera()
camrotx# = wrapvalue(camrotx# + mousemovey() )
camroty# = wrapvalue(camroty# + mousemovex() )
rotate camera camrotx#,camroty#,0
move camera ((mouseclick()=1)-(mouseclick()=2) )*2
endfunction
remstart
Memblock-Mesh (32 Byte Header)
-Header
--4 BYTES (DWORD) Number Of Vertices
--4 BYTES (DWORD) Offset in Bytes to Vertice Data
--4 BYTES (DWORD) Number Of Normals
--4 BYTES (DWORD) Offset in Bytes to Normals Data
--4 BYTES (DWORD) Number of Faces
--4 BYTES (DWORD) Offset in Bytes to Face Data
--4 BYTES (DWORD) Size Of All Face Data
--4 BYTES (DWORD) Offset in Bytes to Texture UV Data
-Data
--Vertice Data
---For Each Vertex
----4 BYTES (FLOAT) - X Position of 3D Geometry
----4 BYTES (FLOAT) - Y Position of 3D Geometry
----4 BYTES (FLOAT) - Z Position of 3D Geometry
--Normals Data
---For Each Normal
----4 BYTES (FLOAT) - X Normalised Normal of 3D Geometry
----4 BYTES (FLOAT) - Y Normalised Normal of 3D Geometry
----4 BYTES (FLOAT) - Z Normalised Normal of 3D Geometry
--Face Data
---For Each Face (a face makes a polygon using A,B and C as vector points)
----2 BYTES (DWORD) - Number of Vectors in Face (always use 3)
----2 BYTES (DWORD) - Index to Vertex in Vertex Data for Vector A
----2 BYTES (DWORD) - Index to Normal in Vertex Data for Vector A
----2 BYTES (DWORD) - Index to Vertex in Vertex Data for Vector B
----2 BYTES (DWORD) - Index to Normal in Vertex Data for Vector B
----2 BYTES (DWORD) - Index to Vertex in Vertex Data for Vector C
----2 BYTES (DWORD) - Index to Normal in Vertex Data for Vector C
--Texture Data
---For Each Vertex
----4 BYTES (FLOAT) - U Value of Texture
----4 BYTES (FLOAT) - V Value of Texture
remend
function mmatrix()
`the memblock is oversized, but meh
make memblock 1,1000
`number of vertices
write memblock dword 1,0,4
`offset to vericle data
write memblock dword 1,4,32
`number of normals
write memblock dword 1,8,4
`offset to normals data
write memblock dword 1,12,80
`number of faces
write memblock dword 1,16,2
`offset to face data
write memblock dword 1,20,128
`size of face data
write memblock dword 1,24,14
`offset to uv data
write memblock dword 1,28,184
`verticle data
write memblock float 1,memblock dword(1,4),0
write memblock float 1,memblock dword(1,4)+4,0
write memblock float 1,memblock dword(1,4)+4*2,0
write memblock float 1,memblock dword(1,4)+4*3,1
write memblock float 1,memblock dword(1,4)+4*4,0
write memblock float 1,memblock dword(1,4)+4*5,0
write memblock float 1,memblock dword(1,4)+4*6,0
write memblock float 1,memblock dword(1,4)+4*7,0
write memblock float 1,memblock dword(1,4)+4*8,1
write memblock float 1,memblock dword(1,4)+4*9,1
write memblock float 1,memblock dword(1,4)+4*10,0
write memblock float 1,memblock dword(1,4)+4*11,1
`normals data
write memblock float 1,memblock dword(1,12),0
write memblock float 1,memblock dword(1,12)+4,0
write memblock float 1,memblock dword(1,12)+4*2,-1
write memblock float 1,memblock dword(1,12)+4*3,0
write memblock float 1,memblock dword(1,12)+4*4,0
write memblock float 1,memblock dword(1,12)+4*5,-1
write memblock float 1,memblock dword(1,12)+4*6,0
write memblock float 1,memblock dword(1,12)+4*7,0
write memblock float 1,memblock dword(1,12)+4*8,-1
write memblock float 1,memblock dword(1,12)+4*9,0
write memblock float 1,memblock dword(1,12)+4*10,0
write memblock float 1,memblock dword(1,12)+4*11,-1
`face data
write memblock dword 1,memblock dword(1,20),3
write memblock dword 1,memblock dword(1,20)+4,0
write memblock dword 1,memblock dword(1,20)+4*2,0
write memblock dword 1,memblock dword(1,20)+4*3,3
write memblock dword 1,memblock dword(1,20)+4*4,3
write memblock dword 1,memblock dword(1,20)+4*5,1
write memblock dword 1,memblock dword(1,20)+4*6,1
write memblock dword 1,memblock dword(1,20)+4*7,3
write memblock dword 1,memblock dword(1,20)+4*8,3
write memblock dword 1,memblock dword(1,20)+4*9,3
write memblock dword 1,memblock dword(1,20)+4*10,0
write memblock dword 1,memblock dword(1,20)+4*11,0
write memblock dword 1,memblock dword(1,20)+4*12,2
write memblock dword 1,memblock dword(1,20)+4*13,2
`uv data
write memblock float 1,memblock dword(1,28),0
write memblock float 1,memblock dword(1,28)+4,1
write memblock float 1,memblock dword(1,28)+4*2,1
write memblock float 1,memblock dword(1,28)+4*3,1
write memblock float 1,memblock dword(1,28)+4*4,0
write memblock float 1,memblock dword(1,28)+4*5,0
write memblock float 1,memblock dword(1,28)+4*6,1
write memblock float 1,memblock dword(1,28)+4*7,0
make mesh from memblock 1,1
make object 1,1,1
endfunction
- Link102