It took a while but I finally figured out a solution
sync on:sync rate 60
set camera range .01, 100000
Global worldObject as integer
Global plainMesh as integer
Global worldCubeSize as float
WorldSetCubeSize(1)
createEmptyWorld()
lockWorld()
cube1 = addWorldCube( 0, 0, 0 )
unlockWorld()
position camera 0, -worldCubeSize*2, worldCubeSize*2, 0
point camera 0, 0, 0
NULL# = mousemovex()
NULL# = mousemovey()
do
rotate camera camera angle x() + mousemovey() , camera angle y() + mousemovex() , 0
move camera (upkey()-downkey())*0.1
set cursor 0, 0
sync
loop
Function WorldSetCubeSize( size as float )
worldCubeSize = size
endFunction
Function createEmptyWorld()
worldObject = find free object()
plainMesh = find free mesh()
make object plain worldObject, 0, 0, 1, 1
tmpObject = find free object()
make object plain tmpObject, worldCubeSize, worldCubeSize, 1, 1
make mesh from object plainMesh, tmpObject
delete object tmpObject
endFunction
Function addWorldCube( x as float , y as float , z as float )
index = 0
for i=0 to 5
if i=0
index = addWorldPlain( x, y, z, i )
else
addWorldPlain( x, y, z, i )
endif
next i
endFunction index
Function addWorldPlain( x as float , y as float , z as float , direction as integer )
add mesh to vertexdata plainMesh
index = get vertexdata vertex count()-4
if direction=0
set vertexdata position index,x+worldCubeSize,y,z
set vertexdata position index+1,x,y,z
set vertexdata position index+2,x+worldCubeSize,y,z-worldCubeSize
set vertexdata position index+3,x,y,z-worldCubeSize
for i=0 to 3
set vertexdata normals index+i,0,-1.0,0
next i
endif
if direction=1
set vertexdata position index,x,y+worldCubeSize,z
set vertexdata position index+1,x+worldCubeSize,y+worldCubeSize,z
set vertexdata position index+2,x,y+worldCubeSize,z-worldCubeSize
set vertexdata position index+3,x+worldCubeSize,y+worldCubeSize,z-worldCubeSize
for i=0 to 3
set vertexdata normals index+i,0,1.0,0
next i
endif
if direction=2
set vertexdata position index,x+worldCubeSize,y+worldCubeSize,z-worldCubeSize
set vertexdata position index+1,x+worldCubeSize,y+worldCubeSize,z
set vertexdata position index+2,x+worldCubeSize,y,z-worldCubeSize
set vertexdata position index+3,x+worldCubeSize,y,z
for i=0 to 3
set vertexdata normals index+i,1.0,0,0
next i
endif
if direction=3
set vertexdata position index,x,y+worldCubeSize,z
set vertexdata position index+1,x,y+worldCubeSize,z-worldCubeSize
set vertexdata position index+2,x,y,z
set vertexdata position index+3,x,y,z-worldCubeSize
for i=0 to 3
set vertexdata normals index+i,-1.0,0,0
next i
endif
if direction=4
set vertexdata position index,x,y+worldCubeSize,z-worldCubeSize
set vertexdata position index+1,x+worldCubeSize,y+worldCubeSize,z-worldCubeSize
set vertexdata position index+2,x,y,z-worldCubeSize
set vertexdata position index+3,x+worldCubeSize,y,z-worldCubeSize
for i=0 to 3
set vertexdata normals index+i,0,0,-1.0
next i
endif
if direction=5
set vertexdata position index,x+worldCubeSize,y+worldCubeSize,z
set vertexdata position index+1,x,y+worldCubeSize,z
set vertexdata position index+2,x+worldCubeSize,y,z
set vertexdata position index+3,x,y,z
for i=0 to 3
set vertexdata normals index+i,0,0,1.0
next i
endif
endFunction index
Function lockWorld()
lock vertexdata for limb worldObject, 0, 1
endFunction
Function unlockWorld()
unlock vertexdata
endFunction
Still don't know what the problem was exactly, but I did figure out that it doesn't work with this command:
make object plain id, size, size
But it does work with this one:
make object plain id, size, size, 1, 1
From the matrixUtil plugin (Matrix1Util_18.dll), this one also creates a plain with 4 vertices instead of 6.
Quote: "I don't want to use any plugins because I'm actually using GDK in my project, but dark basic for testing"
Maybe you can find a way without a dll
edit
The code for positioning the plains in a cube was taken from the open source engine:
http://forum.thegamecreators.com/?m=forum_view&t=187219&b=1