loadLDS("map.lds", 1, 1)
ai start
AI Set Radius 2.5
make object sphere 2,10
make object cube 3,10 : color object 3,rgb(255,000,000)
global dim wPoints$(0,2)
open to write 1, "points.txt"
// adds waypoints
ai make path 1
ai path add point 1, 906, 652
ai path add point 1, 1175, 2602
ai path add point 1, 566, 2824
ai path add point 1, 371, 693
ai path add point 1, 759, 295
ai add neutral 1,1
AI Entity Assign Patrol Path 1,1
do
r = pick object (mousex(), mousey(), 1,1)
if r = 1
pickX = get pick vector x() + camera position x(0)
pickY = get pick vector y() + camera position y(0) + (object size y(2) / 2)
pickZ = get pick vector z() + camera position z(0)
endif
if mouseclick()=1
position object 2, pickX, pickY, pickZ
endif
if keystate(17)=1
move camera up 0,1
endif
if keystate(31)=1
move camera down 0,1
endif
control camera using arrowkeys 0,1,1
update terrain
sync
ai update
loop
// Struktur på waypoint lagring
// waypoint{
// X 90
// Y 442
// Z 532
// }
function loadLDS(filename$,imageStartNum,objNum)
currDir$ = get dir$()
rem pull out directory info
i = len(filename$) - 1
while i>=0 and mid$(filename$,i)<>"\" and mid$(filename$,i)<>"/"
dec i
endwhile
if i>0
directory$ = left$(filename$,i-1)
filename$ = right$(filename$,len(filename$)-i)
set dir directory$
endif
if file Exist(filename$)=0
exit prompt "Terrain file does not exist","Error"
end
else
open to read 1,filename$
read string 1,fileType$
if fileType$<>"LDS1"
exit prompt "File not a valid landscape file","Error"
end
else
read string 1,textureFile$
read string 1,detailFile$
read string 1,lightMapFile$
read float 1,x#
read float 1,y#
read float 1,z#
read long 1,layers
read long 1,osize
read long 1,osplit
read long 1,size
read long 1,detailTilingX
read long 1,detailTilingZ
mapFile$="default-Map.bmp"
if file exist(mapFile$)=1 then delete file mapFile$
rem make a flat heightmap to start
make memblock 255,12 + osize*osize*4
write memblock dword 255,0,osize
write memblock dword 255,4,osize
write memblock dword 255,8,32
index = 12
for i=0 to osize-1
for j=0 to osize-1
write memblock dword 255,index,rgb(0,0,0)
inc index,4
next j
next i
make image from memblock imageStartNum,255
save image mapFile$,imageStartNum
delete memblock 255
delete image imageStartNum
make object terrain objNum
set terrain heightmap objNum,mapFile$
set terrain scale objNum,x#/size,y#/255,z#/size
set terrain split objNum,osplit
set terrain light objNum,0,-1,0,1,1,1,0.5
set terrain tiling objNum,4
build terrain objNum
delete file mapFile$
convert object fvf objNum,1090
if (layers && 0x01) > 0
detailImageNum = imageStartNum : inc imageStartNum
load image detailFile$,detailImageNum
set blend mapping on objNum,0,detailImageNum,0,4
else
set blend mapping on objNum,0,detailImageNum,0,3
endif
if (layers && 0x04) > 0
textureImageNum = imageStartNum : inc imageStartNum
load image textureFile$,textureImageNum
set blend mapping on objNum,1,textureImageNum,0,8
else
set blend mapping on objNum,1,textureImageNum,0,3
endif
if (layers && 0x08) > 0
lightmapImageNum = imageStartNum : inc imageStartNum
load image lightmapFile$,lightmapImageNum
set blend mapping on objNum,2,lightmapImageNum,0,4
else
set blend mapping on objNum,2,lightmapImageNum,0,3
endif
dim points(size,size) as float
dim color(size,size) as dword
for i=0 to size-1
for j=0 to size-1
read float 1,value#
points(i,j) = value#
read long 1,value
color(i,j) = value
next j
next i
perform checklist for object limbs objNum
limbs = checklist quantity()
segSizeX# = x# / size
segSizeZ# = z# / size
for l=0 to limbs-1
lock vertexdata for limb objNum,l
vert = get vertexdata vertex count()
for v = 0 to vert-1
vertx# = get vertexdata position x(v)
vertz# = get vertexdata position z(v)
indexX = int( (vertx#/segSizeX#)+0.01 )
indexZ = int( (vertz#/segSizeZ#)+0.01 )
verty# = points( indexX, indexZ )
vertcolor = color( indexX, indexZ )
set vertexdata position v,vertx#,verty#,vertz#
set vertexdata diffuse v,vertcolor
u# = vertx# / ( x# - segSizeX# )
v# = vertz# / ( z# - segSizeZ# )
u1# = u# * detailtilingX
v1# = v# * detailtilingZ
set vertexdata uv v,0,u1#,v1#
set vertexdata uv v,1,u#,v#
set vertexdata uv v,2,u#,v#
next z
next x
close file 1
calculate object bounds objNum
endif
endif
set dir currDir$
endfunction
thats the complete source.
Okey, if i remove all the AI commands it works fine,and with all AI commands without "ai update" it works fine.
But when i put on ai update the terrain seems to get invisible when i get closer : /
sry for my english, and sorry for telling u to STFU...
it was a funny joke, just needed some food..