this piece of code is a master piece!
// Project: customshapes
// Created: 2016-04-24
// set window properties
SetWindowTitle( "customshapes" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
createpointlight(1,0,0,0,500,255,255,255)
setfogmode(1)
setfogrange(1000,10000)
setfogcolor(0,0,0)
//change this to sync rate 0 if you wanna see how fast it can go
setsyncrate(30,1)
//this will initialize the memory to do the job
init_objectcreation()
//this will assign tile types with known texture uv mapping
init_tiletypes()
//lets make a dummy scene
dim scene[64,1,64] //x,y,z
//lets just load a single image in. you can add 32x32 image tiles to this one and
//split it with code so its usable. I have used a minecraft texture skin so you can
//see how uv mapping can be interchanged
//for simplicity i will just use 3 tiles 1=floor and 2=cubed wall with grass top
for x=1 to 64 step 1
for z=1 to 64 step 1
tp=1 //floor type
if z=1 or z=64 or x=1 or x=64 then tp=2 //wall type
// lets randomly plug walls in
a=random(1,100)
if a=<20 then tp=random(2,3)
scene[x,0,z]=tp
next z
next x
//comment this next stuff out if your not creating a new function file
//*************************************************************
//loadobj(1,"testcylinder.obj")
//
//createobjectfunctionfile("mynewfunction.txt","add_dirtcylinder")
//end
// find this file in the appdata folder under media
//**************************************************************
//ok so we got some sort of random scene with blocks in it
//lets count all the 3d data then construct it
//this could be optimized to save on further geometry not needing to be drawn... but for now try this.
//i dont want to make it too complicated to follow.
//ok count data
max_vertexcount=0
max_indexcount=0
for x=1 to 64 step 1
for z=1 to 64 step 1
rd=scene[x,0,z]
if rd=1
max_vertexcount=max_vertexcount+4 //floor object
max_indexcount=max_indexcount+6
endif
if rd=2
max_vertexcount=max_vertexcount+4 //wall cubed object **this could be optimized fyi**
max_indexcount=max_indexcount+6
//put some top grass on those walls for fun
max_vertexcount=max_vertexcount+4 //wall object
max_indexcount=max_indexcount+6
max_vertexcount=max_vertexcount+4 //wall object
max_indexcount=max_indexcount+6
max_vertexcount=max_vertexcount+4 //wall object
max_indexcount=max_indexcount+6
max_vertexcount=max_vertexcount+4 //wall object
max_indexcount=max_indexcount+6
endif
if rd=3 //the created function file
//vertex=vertex+52
//index=index+132
//change this to use your code or whatever
max_vertexcount=max_vertexcount+52
max_indexcount=max_indexcount+132
endif
next z
next x
//ok lets actually build the model now :)
loadimage(1,"test.png",0) //this file has up to 256 images each 32x32
setimagemagfilter(1,0)
setimageminfilter(1,0)
//make the array for scene single object
makenewobject(max_vertexcount,max_indexcount,max_vertexcount,max_vertexcount)
global vertex=0
global index=0
for x=1 to 64 step 1
for z=1 to 64 step 1
y=1
rd=scene[x,0,z]
usescalex=100
usescaley=100
//dont change scale 4 now
if rd=1
add_floor(vertex,index,1,usescalex,usescaley,usescalex,x,1,z) //( vertex,index,uvmap id,scalex,scaley,scalez,x grid,ygrid,zgrid)
vertex=vertex+4 //floor object
index=index+6// increase counters
endif
if rd=2
//grass top
add_floor(vertex,index,3,usescalex,usescaley,usescalex,x,2,z) //dimensions
vertex=vertex+4 //floor object
index=index+6
addwall_front(vertex,index,2,usescalex,usescaley,usescalex,x,2,z) //dimensions
vertex=vertex+4 //wall object
index=index+6
addwall_back(vertex,index,2,usescalex,usescaley,usescalex,x,2,z) //dimensions
vertex=vertex+4 //wall object
index=index+6
addwall_right(vertex,index,2,usescalex,usescaley,usescalex,x,2,z) //dimensions
vertex=vertex+4 //wall object
index=index+6
addwall_left(vertex,index,2,usescalex,usescaley,usescalex,x,2,z) //demensions
vertex=vertex+4 //wall object
index=index+6
endif
if rd=3 //again this is from the function file generated shape
//run function first before adding values
add_dirtcylinder(vertex,index,x*usescalex,y*usescaley+100,z*usescalex)
vertex=vertex+52
index=index+132
endif
next z
next x
//ok final stage... the object is in the array
//lets save it as an object file and load it back in.
savenewobject(2,"mytempobject.obj",1,1) //saved it and loaded it into id#2
setobjectposition(2,-1000,0,1000)
setobjectimage(2,1,0)
setcamerarange(1,1,20000)
//run collision simulation
testcollision()
end
function testcollision()
createobjectbox(1,50,50,50) //this will be our test character
setobjectposition(1,500,500,500)
setobjectcollisionmode(1,0) //shut off collision detection for this object
setobjectrotation(1,0,180,0)
global gravity#=0.0
global onground=0
do
rem Old position
oldx#=Getobjectx(1)
oldy#=Getobjecty(1)
oldz#=Getobjectz(1)
if ( GetRawKeyState( 87 ) ) then Moveobjectlocalz(1,12) //"w" to walk forward
if ( GetRawKeyState( 83 ) ) then Moveobjectlocalz( 1, -12 ) // "s" to walk back
if ( GetRawKeyState( 65 ) ) then rotateobjectlocaly(1,-6) //"a" turn
if ( GetRawKeyState( 68 ) ) then rotateobjectlocaly(1,6) //"d"
if getrawkeystate(32) and onground=1 then gravity#=30.0 // " " [spacekey to jump]
gravity#=gravity#-3.0
if onground=1 and gravity#<-2.0 then gravity#=-2.0
if gravity#<-30 then gravity#=-30
newx#=getobjectx(1)
newy#=getobjecty(1)+gravity#
newz#=getobjectz(1)
if ObjectSphereSlide(0,oldx#,oldy#,oldz#,newx#,newy#,newz#,35.0)>0
newx#=GetObjectRayCastSlideX(0)
//newy#=GetObjectRayCastSlideY(0)
newz#=GetObjectRayCastSlideZ(0)
setobjectposition(1,newx#,newy#,newz#)
endif
onground=0
//floor
if ObjectSphereSlide(0,newx#,oldy#-45,newz#,newx#,newy#-45,newz#,20.0)>0
//newx#=GetObjectRayCastSlideX(0)
newy#=GetObjectRayCastSlideY(0)+45
if gravity#<0.0 then gravity#=0.0
onground=1
//newz#=GetObjectRayCastSlideZ(0)
setobjectposition(1,newx#,newy#,newz#)
endif
//ceiling
if ObjectSphereSlide(0,newx#,oldy#+45,newz#,newx#,newy#+45,newz#,20.0)>0
//newx#=GetObjectRayCastSlideX(0)
newy#=GetObjectRayCastSlideY(0)-45
if gravity#>0.0 then gravity#=0.0
onground=0
//newz#=GetObjectRayCastSlideZ(0)
setobjectposition(1,newx#,newy#,newz#)
endif
setobjectposition(1,newx#,newy#,newz#)
//setobjectposition(1,newx#,newy#,newz#)
oldx#=newx#
oldy#=newy#
oldz#=newz#
setcameraposition(1,oldx#,oldy#+150,oldz#)
setcamerarotation(1,0,getobjectangley(1),0)
movecameralocalz(1,-100)
newx#=getcamerax(1)
newy#=getcameray(1)
newz#=getcameraz(1)
setcameralookat(1,oldx#,oldy#+120,oldz#,0)
//setcamerarotation(1,getcameraanglex(1),getobjectangley(1),getcameraanglez(1))
print( screenfps())
setpointlightposition(1,oldx#,oldy#,oldz#)
sync()
loop
endfunction
function add_floor(v,i,rd,sx,sy,sz,x,y,z)
lengthx#=sx/2.0
lengthy#=sy/2.0
lengthz#=sz/2.0
//vertex data
setvertexdataposition(v,-lengthx#+(x*sx),lengthy#+(y*sy),lengthz#+(z*sz))
setvertexdataposition(v+1,lengthx#+(x*sx),lengthy#+(y*sy),lengthz#+(z*sz))
setvertexdataposition(v+2,lengthx#+(x*sx),lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+3,-lengthx#+(x*sx),lengthy#+(y*sy),-lengthz#+(z*sz))
//uv mapping
//using uv mapper 1 id (dirt)
setvertexdatauv(v,uv_mapper#[rd,1],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+1,uv_mapper#[rd,3],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+2,uv_mapper#[rd,3],uv_mapper#[rd,4],0.0)
setvertexdatauv(v+3,uv_mapper#[rd,1],uv_mapper#[rd,4],0.0)
//normals
//this is a floor so should just point up
setvertexdatanormals(v,0.0,1.0,0.0)
setvertexdatanormals(v+1,0.0,1.0,0.0)
setvertexdatanormals(v+2,0.0,1.0,0.0)
setvertexdatanormals(v+3,0.0,1.0,0.0)
//final stage index the triangles
//what connects to what...
//face 1
setindexdata2(i,v)
setindexdata2(i+1,v+1)
setindexdata2(i+2,v+2)
//face 2
setindexdata2(i+3,v)
setindexdata2(i+4,v+2)
setindexdata2(i+5,v+3)
//we got a square
//thats it
endfunction
function addwall_front(v,i,rd,sx,sy,sz,x,y,z)
lengthx#=sx/2.0
lengthy#=sy/2.0
lengthz#=sz/2.0
//vertex data
setvertexdataposition(v,-lengthx#+(x*sx),lengthy#+(y*sy),lengthz#+(z*sz))
setvertexdataposition(v+1,lengthx#+(x*sx),lengthy#+(y*sy),lengthz#+(z*sz))
setvertexdataposition(v+2,lengthx#+(x*sx),-lengthy#+(y*sy),lengthz#+(z*sz))
setvertexdataposition(v+3,-lengthx#+(x*sx),-lengthy#+(y*sy),lengthz#+(z*sz))
//uv mapping
//using uv mapper 1 id (dirt)
setvertexdatauv(v,uv_mapper#[rd,1],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+1,uv_mapper#[rd,3],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+2,uv_mapper#[rd,3],uv_mapper#[rd,4],0.0)
setvertexdatauv(v+3,uv_mapper#[rd,1],uv_mapper#[rd,4],0.0)
//normals
//
setvertexdatanormals(v,0.0,0.0,1.0)
setvertexdatanormals(v+1,0.0,0.0,1.0)
setvertexdatanormals(v+2,0.0,0.0,1.0)
setvertexdatanormals(v+3,0.0,0.0,1.0)
//final stage index the triangles
//what connects to what...
//face 1
setindexdata2(i,v+2)
setindexdata2(i+1,v+1)
setindexdata2(i+2,v)
//face 2
setindexdata2(i+3,v+3)
setindexdata2(i+4,v+2)
setindexdata2(i+5,v)
//we got a square
//thats it
endfunction
function addwall_back(v,i,rd,sx,sy,sz,x,y,z)
lengthx#=sx/2.0
lengthy#=sy/2.0
lengthz#=sz/2.0
//vertex data
setvertexdataposition(v,-lengthx#+(x*sx),lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+1,lengthx#+(x*sx),lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+2,lengthx#+(x*sx),-lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+3,-lengthx#+(x*sx),-lengthy#+(y*sy),-lengthz#+(z*sz))
//uv mapping
//using uv mapper 1 id (dirt)
setvertexdatauv(v,uv_mapper#[rd,1],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+1,uv_mapper#[rd,3],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+2,uv_mapper#[rd,3],uv_mapper#[rd,4],0.0)
setvertexdatauv(v+3,uv_mapper#[rd,1],uv_mapper#[rd,4],0.0)
//normals
//
setvertexdatanormals(v,0.0,0.0,-1.0)
setvertexdatanormals(v+1,0.0,0.0,-1.0)
setvertexdatanormals(v+2,0.0,0.0,-1.0)
setvertexdatanormals(v+3,0.0,0.0,-1.0)
//final stage index the triangles
//what connects to what...
//face 1
setindexdata2(i,v)
setindexdata2(i+1,v+1)
setindexdata2(i+2,v+2)
//face 2
setindexdata2(i+3,v)
setindexdata2(i+4,v+2)
setindexdata2(i+5,v+3)
//we got a square
//thats it
endfunction
function addwall_right(v,i,rd,sx,sy,sz,x,y,z)
lengthx#=sx/2.0
lengthy#=sy/2.0
lengthz#=sz/2.0
//vertex data
setvertexdataposition(v,-lengthx#+(x*sx),lengthy#+(y*sy),lengthz#+(z*sz))
setvertexdataposition(v+1,-lengthx#+(x*sx),lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+2,-lengthx#+(x*sx),-lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+3,-lengthx#+(x*sx),-lengthy#+(y*sy),lengthz#+(z*sz))
//uv mapping
//using uv mapper 1 id (dirt)
setvertexdatauv(v,uv_mapper#[rd,1],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+1,uv_mapper#[rd,3],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+2,uv_mapper#[rd,3],uv_mapper#[rd,4],0.0)
setvertexdatauv(v+3,uv_mapper#[rd,1],uv_mapper#[rd,4],0.0)
//normals
//this is a floor so should just point up
setvertexdatanormals(v,-1.0,0.0,0.0)
setvertexdatanormals(v+1,-1.0,0.0,0.0)
setvertexdatanormals(v+2,-1.0,0.0,0.0)
setvertexdatanormals(v+3,-1.0,0.0,0.0)
//final stage index the triangles
//what connects to what...
//face 1
setindexdata2(i,v)
setindexdata2(i+1,v+1)
setindexdata2(i+2,v+2)
//face 2
setindexdata2(i+3,v)
setindexdata2(i+4,v+2)
setindexdata2(i+5,v+3)
//we got a square
//thats it
endfunction
function addwall_left(v,i,rd,sx,sy,sz,x,y,z)
lengthx#=sx/2.0
lengthy#=sy/2.0
lengthz#=sz/2.0
//vertex data
setvertexdataposition(v,lengthx#+(x*sx),lengthy#+(y*sy),lengthz#+(z*sz))
setvertexdataposition(v+1,lengthx#+(x*sx),lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+2,lengthx#+(x*sx),-lengthy#+(y*sy),-lengthz#+(z*sz))
setvertexdataposition(v+3,lengthx#+(x*sx),-lengthy#+(y*sy),lengthz#+(z*sz))
//uv mapping
//using uv mapper 1 id (dirt)
setvertexdatauv(v,uv_mapper#[rd,1],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+1,uv_mapper#[rd,3],uv_mapper#[rd,2],0.0)
setvertexdatauv(v+2,uv_mapper#[rd,3],uv_mapper#[rd,4],0.0)
setvertexdatauv(v+3,uv_mapper#[rd,1],uv_mapper#[rd,4],0.0)
//normals
//this is a floor so should just point up
setvertexdatanormals(v,1.0,0.0,0.0)
setvertexdatanormals(v+1,1.0,0.0,0.0)
setvertexdatanormals(v+2,1.0,0.0,0.0)
setvertexdatanormals(v+3,1.0,0.0,0.0)
//final stage index the triangles
//what connects to what...
//face 1
setindexdata2(i,v+2)
setindexdata2(i+1,v+1)
setindexdata2(i+2,v)
//face 2
setindexdata2(i+3,v+3)
setindexdata2(i+4,v+2)
setindexdata2(i+5,v)
//we got a square
//thats it
endfunction
function init_tiletypes()
dim uv_mapper#[256,4]
//assign tile 1 floor uv mapping
//this example image is 512x512 with 32x32 tiles that are 16x16 grid
//floor 1 (dirt)
uv_mapper#[1,1]=(32.000/512.00)
uv_mapper#[1,2]=1.000
uv_mapper#[1,3]=(63.000/512.00)
uv_mapper#[1,4]=1.0-(31.000/512.00)
//wall 1
uv_mapper#[2,1]=96.000/512.000
uv_mapper#[2,2]=1.000
uv_mapper#[2,3]=127.000/512.000
uv_mapper#[2,4]=1.0-(31.000/512.000)
//floor 2 grass
uv_mapper#[3,1]=(0.000/512.00)
uv_mapper#[3,2]=1.000
uv_mapper#[3,3]=(31.000/512.00)
uv_mapper#[3,4]=1.0-(31.000/512.00)
endfunction
function init_objectcreation()
dim edit_object1#[2,2]
dim edit_objectn1#[2,2]
dim edit_objectuv1#[2,2]
dim edit_object2[2,2]
global max_vertexcount
global max_normalscount
global max_uvcount
max_vertexcount=0
max_normalscount=0
max_uvcount=0
global max_indexcount
max_indexcount=0
endfunction
function makenewobject(vertex_cnt,index_cnt,normal_cnt,uv_cnt)
if vertex_cnt-1<2 then exitfunction
if index_cnt-1<2 then exitfunction
dim edit_object1#[vertex_cnt-1,2]
dim edit_object2[index_cnt-1,2]
max_vertexcount=vertex_cnt-1
max_indexcount=index_cnt-1
dim edit_objectn1#[normal_cnt-1,2]
dim edit_objectuv1#[uv_cnt-1,2]
max_normalscount=normal_cnt-1
max_uvcount=uv_cnt-1
endfunction
function setvertexdataposition(vertex,x#,y#,z#)
if vertex>max_vertexcount then exitfunction
if vertex<0 then exitfunction
edit_object1#[vertex,0]=x#
edit_object1#[vertex,1]=y#
edit_object1#[vertex,2]=z#
endfunction
function setvertexdatanormals(vertex,x#,y#,z#)
if vertex>max_normalscount then exitfunction
if vertex<0 then exitfunction
edit_objectn1#[vertex,0]=x#
edit_objectn1#[vertex,1]=y#
edit_objectn1#[vertex,2]=z#
endfunction
function setvertexdatauv(vertex,u#,v#,w#)
if vertex>max_uvcount then exitfunction
if vertex<0 then exitfunction
edit_objectuv1#[vertex,0]=u#
edit_objectuv1#[vertex,1]=v#
edit_objectuv1#[vertex,2]=w#
endfunction
function setindexdata(index,v1,s)
if index<0 then exitfunction
if index>max_indexcount then exitfunction
if v1<0 then exitfunction
edit_object2[index,s]=v1
endfunction
function setindexdata2(index,v1)
if index<0 then exitfunction
if index>max_indexcount then exitfunction
if v1<0 then exitfunction
//if v1>max_vertexcount then exitfunction
for s=0 to 2 step 1
edit_object2[index,s]=v1
next s
endfunction
function savenewobject(object_number,filename$,flag1,flag2)
//flag1 1 = overwrite existing file
//flag1 <>0 = fail if file exists
//flag2 load it in after saving it =1
if getfileexists(filename$)=1 and flag1<>1 then exitfunction
if max_vertexcount<2 then exitfunction
if max_indexcount<2 then exitfunction
//ok lets write the file
if getfileexists(filename$)=1 then deletefile(filename$)
opentowrite(1,filename$)
writeline(1,"# agk easy editable object format")
writeline(1,"# "+str(max_vertexcount+1)+" vertex positions" )
stp=-1
for v=0 to max_vertexcount step 1
writeline(1,"v "+str(edit_object1#[v,0])+" "+str(edit_object1#[v,1])+" "+str(edit_object1#[v,2]))
next v
writeline(1,"# "+str(max_uvcount+1)+" uv coordinates" )
for v=0 to max_uvcount step 1
writeline(1,"vt "+str(edit_objectuv1#[v,0])+" "+str(edit_objectuv1#[v,1])+" "+str(edit_objectuv1#[v,2]))
next v
writeline(1,"# "+str(max_normalscount+1)+" vertex normals" )
for v=0 to max_normalscount step 1
writeline(1,"vn "+str(edit_objectn1#[v,0])+" "+str(edit_objectn1#[v,1])+" "+str(edit_objectn1#[v,2]))
next v
ind_count=(max_indexcount+1)/3
writeline(1,"# Mesh 'object_name' with "+str(ind_count)+" faces" )
writeline(1,"# " ) // normally would specify material name but agk ignores this
writeline(1,"g object_name")
for i=0 to max_indexcount step 3
index1=edit_object2[i,0]+1
index2=edit_object2[i+1,0]+1
index3=edit_object2[i+2,0]+1
index4=edit_object2[i,1]+1
index5=edit_object2[i+1,1]+1
index6=edit_object2[i+2,1]+1
index7=edit_object2[i,2]+1
index8=edit_object2[i+1,2]+1
index9=edit_object2[i+2,2]+1
writeline(1,"f "+str(index1)+"/"+str(index4)+"/"+str(index7)+" "+str(index2)+"/"+str(index5)+"/"+str(index8)+" "+str(index3)+"/"+str(index6)+"/"+str(index9))
next i
writeline(1,"# thats it ")
//message("saved something?")
closefile(1)
if flag2=1
if getobjectexists(object_number)=1 then deleteobject(object_number)
loadobject(object_number,filename$)
endif
endfunction
function loadobj(object1,filename$)
//lets load the file 2 times to count data
opentoread(1,filename$)
vertex_counter=0
uv_counter=0
nm_counter=0
index_counter=0
while fileeof(1)=0
cmd$=readline(1)
if left(cmd$,2)="v "
vertex_counter=vertex_counter+1
endif
if left(cmd$,2)="vn"
nm_counter=nm_counter+1
endif
if left(cmd$,2)="vt"
uv_counter=uv_counter+1
endif
if left(cmd$,2)="f "
index_counter=index_counter+1
endif
endwhile
closefile(1)
//ok so we have some general data to actualy load the file in
//if vertex_counter<3 then exitfunction
//if index_counter<3 then exitfunction
ic=(index_counter*3)
makenewobject(vertex_counter,ic,nm_counter,uv_counter)
//makenewobject(vertex_cnt,index_cnt,normal_cnt,uv_cnt)
//load it in and fill in the data
opentoread(1,filename$)
vertex_counter=0
uv_counter=0
nm_counter=0
index_counter=0
while fileeof(1)=0
cmd$=readline(1)
if left(cmd$,2)="v "
vertex_counter=vertex_counter+1
num=countstringtokens(cmd$," ")
v1#=0.0
v2#=0.0
v3#=0.0
v1#=valfloat(getstringtoken(cmd$," ",2))
v2#=valfloat(getstringtoken(cmd$," ",3))
v3#=valfloat(getstringtoken(cmd$," ",4))
setvertexdataposition(vertex_counter-1,v1#,v2#,v3#)
endif
if left(cmd$,2)="vn"
nm_counter=nm_counter+1
num=countstringtokens(cmd$," ")
v1#=0.0
v2#=0.0
v3#=0.0
v1#=valfloat(getstringtoken(cmd$," ",2))
v2#=valfloat(getstringtoken(cmd$," ",3))
v3#=valfloat(getstringtoken(cmd$," ",4))
setvertexdatanormals(nm_counter-1,v1#,v2#,v3#)
endif
if left(cmd$,2)="vt"
uv_counter=uv_counter+1
num=countstringtokens(cmd$," ")
v1#=0.0
v2#=0.0
v3#=0.0
v1#=valfloat(getstringtoken(cmd$," ",2))
v2#=valfloat(getstringtoken(cmd$," ",3))
v3#=valfloat(getstringtoken(cmd$," ",4))
setvertexdatauv(uv_counter-1,v1#,v2#,v3#)
endif
if left(cmd$,2)="f "
index_counter=index_counter+1
//split into several strings
num=countstringtokens(cmd$," ")
st1$=getstringtoken(cmd$," ",2)
st2$=getstringtoken(cmd$," ",3)
st3$=getstringtoken(cmd$," ",4)
ind1=val(getstringtoken(st1$,"/",1))
indn1=val(getstringtoken(st1$,"/",2))
induv1=val(getstringtoken(st1$,"/",3))
ind2=val(getstringtoken(st2$,"/",1))
indn2=val(getstringtoken(st2$,"/",2))
induv2=val(getstringtoken(st2$,"/",3))
ind3=val(getstringtoken(st3$,"/",1))
indn3=val(getstringtoken(st3$,"/",2))
induv3=val(getstringtoken(st3$,"/",3))
ic=(index_counter*3.0)-3
setindexdata(ic,ind1-1,0)
setindexdata(ic+1,ind2-1,0)
setindexdata(ic+2,ind3-1,0)
setindexdata(ic,indn1-1,1)
setindexdata(ic+1,indn2-1,1)
setindexdata(ic+2,indn3-1,1)
setindexdata(ic,induv1-1,2)
setindexdata(ic+1,induv2-1,2)
setindexdata(ic+2,induv3-1,2)
endif
endwhile
closefile(1)
//ok lets save temp obj and loadit in.
setfolder("")
savenewobject(object1,"temporary_smd.obj",1,1)
if getfileexists("temporary_smd.obj")=1 then deletefile("temporary_smd.obj")
setfolder("media")
//benefits you ask? you can edit it and save it again!
//automatically fills vertex and index data into memory
endfunction
function createobjectfunctionfile(filename$,functionname$)
//this command should not be called when making an object
//the command should be called after loading the obj file in to memory using
//loadobj(object1,filename$) //first!
//check array data exists
if max_vertexcount<2 or max_indexcount<2 then exitfunction //should be some sufficient data loaded
if getfileexists(filename$)=1 then deletefile(filename$)
opentowrite(9,filename$)
writeline(9,"//new object creation function for agk by Sheldon MacDonald (sheldonscreations) 2016")
writeline(9,"//")
writeline(9,"//not recommended for large objects.... simple shapes only to construct something bigger")
writeline(9,"//use this code for size detection loop determining how much data will be used")
writeline(9,"//")
writeline(9," ")
writeline(9,"if rd=1 //edit this for detection type ")
writeline(9," vertex=vertex+"+str(max_vertexcount+1))
writeline(9," index=index+"+str(max_indexcount+1))
writeline(9,"endif")
writeline(9,"")
writeline(9,"//now the function that draws the shape/object")
writeline(9,"")
writeline(9,"function "+functionname$+"(atvertex,atindex,offsetx#,offsety#,offsetz#)")
writeline(9,"//to change the draw position just change the offset values when you call this function")
writeline(9,"//set vertex data /normals and uv first")
for v=0 to max_vertexcount step 1
writeline(9,"setvertexdataposition("+str(v)+"+atvertex,"+str(edit_object1#[v,0],6)+"+offsetx#,"+str(edit_object1#[v,1],6)+"+offsety#,"+str(edit_object1#[v,2],6)+"+offsetz#)")
writeline(9,"setvertexdatauv("+str(v)+"+atvertex,"+str(edit_objectuv1#[v,0],6)+","+str(edit_objectuv1#[v,1],6)+","+str(edit_objectuv1#[v,2],6)+")")
writeline(9,"setvertexdatanormals("+str(v)+"+atvertex,"+str(edit_objectn1#[v,0],6)+","+str(edit_objectn1#[v,1],6)+","+str(edit_objectn1#[v,2],6)+")")
next v
writeline(9,"//")
writeline(9,"//ok faces next the we are done")
for i=0 to max_indexcount step 1
writeline(9,"setindexdata2("+str(i)+"+atindex,"+str(edit_object2[i,0])+"+atvertex)")
next i
writeline(9,"//thats it")
writeline(9,"endfunction")
closefile(9)
endfunction
//this file was generated from the code
//new object creation function for agk by Sheldon MacDonald (sheldonscreations) 2016
//
//not recommended for large objects.... simple shapes only to construct something bigger
//use this code for size detection loop determining how much data will be used
//
//now the function that draws the shape/object
function add_dirtcylinder(atvertex,atindex,offsetx#,offsety#,offsetz#)
//to change the draw position just change the offset values when you call this function
//set vertex data /normals and uv first
setvertexdataposition(0+atvertex,50.000000+offsetx#,50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(0+atvertex,0.227654,0.999023,0.000000)
setvertexdatanormals(0+atvertex,0.968028,0.000000,-0.250841)
setvertexdataposition(1+atvertex,50.000000+offsetx#,50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(1+atvertex,0.209609,0.999023,0.000000)
setvertexdatanormals(1+atvertex,0.968028,0.000000,0.250841)
setvertexdataposition(2+atvertex,50.000000+offsetx#,-50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(2+atvertex,0.209609,0.938477,0.000000)
setvertexdatanormals(2+atvertex,0.968028,0.000000,0.250841)
setvertexdataposition(3+atvertex,50.000000+offsetx#,-50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(3+atvertex,0.227654,0.938477,0.000000)
setvertexdatanormals(3+atvertex,0.968028,0.000000,-0.250841)
setvertexdataposition(4+atvertex,37.500000+offsetx#,50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(4+atvertex,0.195837,0.999023,0.000000)
setvertexdatanormals(4+atvertex,0.874157,0.000000,0.485643)
setvertexdataposition(5+atvertex,37.500000+offsetx#,-50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(5+atvertex,0.195837,0.938477,0.000000)
setvertexdatanormals(5+atvertex,0.874157,0.000000,0.485643)
setvertexdataposition(6+atvertex,37.500000+offsetx#,50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(6+atvertex,0.241425,0.999023,0.000000)
setvertexdatanormals(6+atvertex,0.485643,0.000000,0.874157)
setvertexdataposition(7+atvertex,15.000000+offsetx#,50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(7+atvertex,0.227654,0.999023,0.000000)
setvertexdatanormals(7+atvertex,0.250841,0.000000,0.968028)
setvertexdataposition(8+atvertex,15.000000+offsetx#,-50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(8+atvertex,0.227654,0.938477,0.000000)
setvertexdatanormals(8+atvertex,0.250841,0.000000,0.968028)
setvertexdataposition(9+atvertex,37.500000+offsetx#,-50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(9+atvertex,0.241425,0.938477,0.000000)
setvertexdatanormals(9+atvertex,0.485643,0.000000,0.874157)
setvertexdataposition(10+atvertex,-15.000000+offsetx#,50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(10+atvertex,0.209609,0.999023,0.000000)
setvertexdatanormals(10+atvertex,-0.250841,0.000000,0.968028)
setvertexdataposition(11+atvertex,-15.000000+offsetx#,-50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(11+atvertex,0.209609,0.938477,0.000000)
setvertexdatanormals(11+atvertex,-0.250841,0.000000,0.968028)
setvertexdataposition(12+atvertex,-37.500000+offsetx#,50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(12+atvertex,0.195837,0.999023,0.000000)
setvertexdatanormals(12+atvertex,-0.707107,0.000000,0.707107)
setvertexdataposition(13+atvertex,-37.500000+offsetx#,-50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(13+atvertex,0.195837,0.938477,0.000000)
setvertexdatanormals(13+atvertex,-0.707107,0.000000,0.707107)
setvertexdataposition(14+atvertex,-50.000000+offsetx#,50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(14+atvertex,0.209609,0.999023,0.000000)
setvertexdatanormals(14+atvertex,-0.968028,0.000000,0.250841)
setvertexdataposition(15+atvertex,-50.000000+offsetx#,-50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(15+atvertex,0.209609,0.938477,0.000000)
setvertexdatanormals(15+atvertex,-0.968028,0.000000,0.250841)
setvertexdataposition(16+atvertex,-50.000000+offsetx#,50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(16+atvertex,0.227654,0.999023,0.000000)
setvertexdatanormals(16+atvertex,-0.968028,0.000000,-0.250841)
setvertexdataposition(17+atvertex,-50.000000+offsetx#,-50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(17+atvertex,0.227654,0.938477,0.000000)
setvertexdatanormals(17+atvertex,-0.968028,0.000000,-0.250841)
setvertexdataposition(18+atvertex,-37.500000+offsetx#,50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(18+atvertex,0.241425,0.999023,0.000000)
setvertexdatanormals(18+atvertex,-0.874157,0.000000,-0.485643)
setvertexdataposition(19+atvertex,-37.500000+offsetx#,-50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(19+atvertex,0.241425,0.938477,0.000000)
setvertexdatanormals(19+atvertex,-0.874157,0.000000,-0.485643)
setvertexdataposition(20+atvertex,-37.500000+offsetx#,50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(20+atvertex,0.195837,0.999023,0.000000)
setvertexdatanormals(20+atvertex,-0.485643,0.000000,-0.874157)
setvertexdataposition(21+atvertex,-15.000000+offsetx#,50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(21+atvertex,0.209609,0.999023,0.000000)
setvertexdatanormals(21+atvertex,-0.250841,0.000000,-0.968028)
setvertexdataposition(22+atvertex,-15.000000+offsetx#,-50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(22+atvertex,0.209609,0.938477,0.000000)
setvertexdatanormals(22+atvertex,-0.250841,0.000000,-0.968028)
setvertexdataposition(23+atvertex,-37.500000+offsetx#,-50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(23+atvertex,0.195837,0.938477,0.000000)
setvertexdatanormals(23+atvertex,-0.485643,0.000000,-0.874157)
setvertexdataposition(24+atvertex,15.000000+offsetx#,50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(24+atvertex,0.227654,0.999023,0.000000)
setvertexdatanormals(24+atvertex,0.250841,0.000000,-0.968028)
setvertexdataposition(25+atvertex,15.000000+offsetx#,-50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(25+atvertex,0.227654,0.938477,0.000000)
setvertexdatanormals(25+atvertex,0.250841,0.000000,-0.968028)
setvertexdataposition(26+atvertex,37.500000+offsetx#,50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(26+atvertex,0.241425,0.999023,0.000000)
setvertexdatanormals(26+atvertex,0.707107,0.000000,-0.707107)
setvertexdataposition(27+atvertex,37.500000+offsetx#,-50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(27+atvertex,0.241425,0.938477,0.000000)
setvertexdatanormals(27+atvertex,0.707107,0.000000,-0.707107)
setvertexdataposition(28+atvertex,37.500000+offsetx#,50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(28+atvertex,0.008337,0.946075,0.000000)
setvertexdatanormals(28+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(29+atvertex,15.000000+offsetx#,50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(29+atvertex,0.022109,0.938477,0.000000)
setvertexdatanormals(29+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(30+atvertex,-15.000000+offsetx#,50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(30+atvertex,0.040154,0.938477,0.000000)
setvertexdatanormals(30+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(31+atvertex,-37.500000+offsetx#,50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(31+atvertex,0.053925,0.946075,0.000000)
setvertexdatanormals(31+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(32+atvertex,-50.000000+offsetx#,50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(32+atvertex,0.061523,0.959846,0.000000)
setvertexdatanormals(32+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(33+atvertex,-50.000000+offsetx#,50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(33+atvertex,0.061523,0.977891,0.000000)
setvertexdatanormals(33+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(34+atvertex,-37.500000+offsetx#,50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(34+atvertex,0.053925,0.991663,0.000000)
setvertexdatanormals(34+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(35+atvertex,-15.000000+offsetx#,50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(35+atvertex,0.040154,0.999023,0.000000)
setvertexdatanormals(35+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(36+atvertex,15.000000+offsetx#,50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(36+atvertex,0.022109,0.999023,0.000000)
setvertexdatanormals(36+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(37+atvertex,37.500000+offsetx#,50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(37+atvertex,0.008337,0.991663,0.000000)
setvertexdatanormals(37+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(38+atvertex,50.000000+offsetx#,50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(38+atvertex,0.000977,0.977891,0.000000)
setvertexdatanormals(38+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(39+atvertex,50.000000+offsetx#,50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(39+atvertex,0.000977,0.959846,0.000000)
setvertexdatanormals(39+atvertex,0.000000,1.000000,0.000000)
setvertexdataposition(40+atvertex,50.000000+offsetx#,-50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(40+atvertex,0.125977,0.959846,0.000000)
setvertexdatanormals(40+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(41+atvertex,50.000000+offsetx#,-50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(41+atvertex,0.125977,0.977891,0.000000)
setvertexdatanormals(41+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(42+atvertex,37.500000+offsetx#,-50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(42+atvertex,0.133337,0.991663,0.000000)
setvertexdatanormals(42+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(43+atvertex,15.000000+offsetx#,-50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(43+atvertex,0.147109,0.999023,0.000000)
setvertexdatanormals(43+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(44+atvertex,-15.000000+offsetx#,-50.000000+offsety#,50.000000+offsetz#)
setvertexdatauv(44+atvertex,0.165154,0.999023,0.000000)
setvertexdatanormals(44+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(45+atvertex,-37.500000+offsetx#,-50.000000+offsety#,37.500000+offsetz#)
setvertexdatauv(45+atvertex,0.178925,0.991663,0.000000)
setvertexdatanormals(45+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(46+atvertex,-50.000000+offsetx#,-50.000000+offsety#,15.000000+offsetz#)
setvertexdatauv(46+atvertex,0.186523,0.977891,0.000000)
setvertexdatanormals(46+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(47+atvertex,-50.000000+offsetx#,-50.000000+offsety#,-15.000000+offsetz#)
setvertexdatauv(47+atvertex,0.186523,0.959846,0.000000)
setvertexdatanormals(47+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(48+atvertex,-37.500000+offsetx#,-50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(48+atvertex,0.178925,0.946075,0.000000)
setvertexdatanormals(48+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(49+atvertex,-15.000000+offsetx#,-50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(49+atvertex,0.165154,0.938477,0.000000)
setvertexdatanormals(49+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(50+atvertex,15.000000+offsetx#,-50.000000+offsety#,-50.000000+offsetz#)
setvertexdatauv(50+atvertex,0.147109,0.938477,0.000000)
setvertexdatanormals(50+atvertex,0.000000,-1.000000,0.000000)
setvertexdataposition(51+atvertex,37.500000+offsetx#,-50.000000+offsety#,-37.500000+offsetz#)
setvertexdatauv(51+atvertex,0.133337,0.946075,0.000000)
setvertexdatanormals(51+atvertex,0.000000,-1.000000,0.000000)
//
//ok faces next the we are done
setindexdata2(0+atindex,1+atvertex)
setindexdata2(1+atindex,2+atvertex)
setindexdata2(2+atindex,3+atvertex)
setindexdata2(3+atindex,0+atvertex)
setindexdata2(4+atindex,1+atvertex)
setindexdata2(5+atindex,3+atvertex)
setindexdata2(6+atindex,4+atvertex)
setindexdata2(7+atindex,5+atvertex)
setindexdata2(8+atindex,2+atvertex)
setindexdata2(9+atindex,1+atvertex)
setindexdata2(10+atindex,4+atvertex)
setindexdata2(11+atindex,2+atvertex)
setindexdata2(12+atindex,7+atvertex)
setindexdata2(13+atindex,8+atvertex)
setindexdata2(14+atindex,9+atvertex)
setindexdata2(15+atindex,6+atvertex)
setindexdata2(16+atindex,7+atvertex)
setindexdata2(17+atindex,9+atvertex)
setindexdata2(18+atindex,10+atvertex)
setindexdata2(19+atindex,11+atvertex)
setindexdata2(20+atindex,8+atvertex)
setindexdata2(21+atindex,7+atvertex)
setindexdata2(22+atindex,10+atvertex)
setindexdata2(23+atindex,8+atvertex)
setindexdata2(24+atindex,12+atvertex)
setindexdata2(25+atindex,13+atvertex)
setindexdata2(26+atindex,11+atvertex)
setindexdata2(27+atindex,10+atvertex)
setindexdata2(28+atindex,12+atvertex)
setindexdata2(29+atindex,11+atvertex)
setindexdata2(30+atindex,14+atvertex)
setindexdata2(31+atindex,15+atvertex)
setindexdata2(32+atindex,13+atvertex)
setindexdata2(33+atindex,12+atvertex)
setindexdata2(34+atindex,14+atvertex)
setindexdata2(35+atindex,13+atvertex)
setindexdata2(36+atindex,16+atvertex)
setindexdata2(37+atindex,17+atvertex)
setindexdata2(38+atindex,15+atvertex)
setindexdata2(39+atindex,14+atvertex)
setindexdata2(40+atindex,16+atvertex)
setindexdata2(41+atindex,15+atvertex)
setindexdata2(42+atindex,18+atvertex)
setindexdata2(43+atindex,19+atvertex)
setindexdata2(44+atindex,17+atvertex)
setindexdata2(45+atindex,16+atvertex)
setindexdata2(46+atindex,18+atvertex)
setindexdata2(47+atindex,17+atvertex)
setindexdata2(48+atindex,21+atvertex)
setindexdata2(49+atindex,22+atvertex)
setindexdata2(50+atindex,23+atvertex)
setindexdata2(51+atindex,20+atvertex)
setindexdata2(52+atindex,21+atvertex)
setindexdata2(53+atindex,23+atvertex)
setindexdata2(54+atindex,24+atvertex)
setindexdata2(55+atindex,25+atvertex)
setindexdata2(56+atindex,22+atvertex)
setindexdata2(57+atindex,21+atvertex)
setindexdata2(58+atindex,24+atvertex)
setindexdata2(59+atindex,22+atvertex)
setindexdata2(60+atindex,26+atvertex)
setindexdata2(61+atindex,27+atvertex)
setindexdata2(62+atindex,25+atvertex)
setindexdata2(63+atindex,24+atvertex)
setindexdata2(64+atindex,26+atvertex)
setindexdata2(65+atindex,25+atvertex)
setindexdata2(66+atindex,0+atvertex)
setindexdata2(67+atindex,3+atvertex)
setindexdata2(68+atindex,27+atvertex)
setindexdata2(69+atindex,26+atvertex)
setindexdata2(70+atindex,0+atvertex)
setindexdata2(71+atindex,27+atvertex)
setindexdata2(72+atindex,37+atvertex)
setindexdata2(73+atindex,38+atvertex)
setindexdata2(74+atindex,39+atvertex)
setindexdata2(75+atindex,36+atvertex)
setindexdata2(76+atindex,37+atvertex)
setindexdata2(77+atindex,39+atvertex)
setindexdata2(78+atindex,35+atvertex)
setindexdata2(79+atindex,36+atvertex)
setindexdata2(80+atindex,39+atvertex)
setindexdata2(81+atindex,34+atvertex)
setindexdata2(82+atindex,35+atvertex)
setindexdata2(83+atindex,39+atvertex)
setindexdata2(84+atindex,33+atvertex)
setindexdata2(85+atindex,34+atvertex)
setindexdata2(86+atindex,39+atvertex)
setindexdata2(87+atindex,32+atvertex)
setindexdata2(88+atindex,33+atvertex)
setindexdata2(89+atindex,39+atvertex)
setindexdata2(90+atindex,31+atvertex)
setindexdata2(91+atindex,32+atvertex)
setindexdata2(92+atindex,39+atvertex)
setindexdata2(93+atindex,30+atvertex)
setindexdata2(94+atindex,31+atvertex)
setindexdata2(95+atindex,39+atvertex)
setindexdata2(96+atindex,29+atvertex)
setindexdata2(97+atindex,30+atvertex)
setindexdata2(98+atindex,39+atvertex)
setindexdata2(99+atindex,28+atvertex)
setindexdata2(100+atindex,29+atvertex)
setindexdata2(101+atindex,39+atvertex)
setindexdata2(102+atindex,49+atvertex)
setindexdata2(103+atindex,50+atvertex)
setindexdata2(104+atindex,51+atvertex)
setindexdata2(105+atindex,48+atvertex)
setindexdata2(106+atindex,49+atvertex)
setindexdata2(107+atindex,51+atvertex)
setindexdata2(108+atindex,47+atvertex)
setindexdata2(109+atindex,48+atvertex)
setindexdata2(110+atindex,51+atvertex)
setindexdata2(111+atindex,46+atvertex)
setindexdata2(112+atindex,47+atvertex)
setindexdata2(113+atindex,51+atvertex)
setindexdata2(114+atindex,45+atvertex)
setindexdata2(115+atindex,46+atvertex)
setindexdata2(116+atindex,51+atvertex)
setindexdata2(117+atindex,44+atvertex)
setindexdata2(118+atindex,45+atvertex)
setindexdata2(119+atindex,51+atvertex)
setindexdata2(120+atindex,43+atvertex)
setindexdata2(121+atindex,44+atvertex)
setindexdata2(122+atindex,51+atvertex)
setindexdata2(123+atindex,42+atvertex)
setindexdata2(124+atindex,43+atvertex)
setindexdata2(125+atindex,51+atvertex)
setindexdata2(126+atindex,41+atvertex)
setindexdata2(127+atindex,42+atvertex)
setindexdata2(128+atindex,51+atvertex)
setindexdata2(129+atindex,40+atvertex)
setindexdata2(130+atindex,41+atvertex)
setindexdata2(131+atindex,51+atvertex)
//thats it
endfunction
so now you can make several obj files into agk code
this is the code here that makes the text file
//comment this next stuff out if your not creating a new function file
//*************************************************************
//loadobj(1,"testcylinder.obj")
//
//createobjectfunctionfile("mynewfunction.txt","add_dirtcylinder")
//end
// find this file in the appdata folder under media
//**************************************************************
uncomment that out to make your new function, locate the new text file generated and load it into notepad.
copy the data to your agk app your making.
i have included the cylinder function into the above code so you can see how it needs to be added in.
download attachment below
(please ignore my spelling errors.... it happens)