Here is what I have at moment
// Project: Mesh Objects
// Created: 2018-08-04
// show all errors
SetErrorMode(2)
#constant PI# = 3.14159265359
// set window properties
SetWindowTitle( "Mesh Objects" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
global ang#, angx#, angy#, fDiffY#, fDiffX#,newX#,startx#, starty#
Type Vertex
x as float
y as float
z as float
nx as float
ny as float
nz as float
u as float
v as float
color as integer
endtype
Type Triangle
v1 as integer
v2 as integer
v3 as integer
endtype
Type Mesh
VertexList as Vertex[]
TriangleList as Triangle[]
endtype
global MeshID as Mesh
type _vector
x#
y#
z#
vindex
nindex
tindex
endtype
global vertex as _vector[] // eg v 1.276477 0.200934 -0.387665
global normals as _vector[] // eg vn vn -0.5346 0.3304 -0.7779
global faces as _vector[] // eg f 5//9 21//9 29//9
global textures as _vector[] // eg vt 0.500 1 [0]
global pieces as _vector[]
global peices as integer[]
Global cubed
cubed = loadimage("\media\cube.png")
// Memblock Version
LoadObjectIntoMesh(0,0,0,"\media\ico.obj", 0,0)
object = CreateObjectFromMeshWithColor(meshid)
SetObjectPosition(object,10,0,0)
// AGKs
AGK = LoadObject("\media\ico.obj")
SetObjectPosition(AGK,10,0,0)
/*
color=MakeColor(255,255,255)
AddVertex(MeshID, 0, 0, 0, 0,1,0, 0,0,Color) // point 1
AddVertex(MeshID, -10, 0, 10, 0,1,0, 0,0,Color) // point 2
AddVertex(MeshID, -10, 0, 0, 0,1,0, 0,0,Color) // point 3
AddVertex(MeshID, 0,0,0, 0,1,0, 0,0,Color)
AddVertex(MeshID, 10,0,10, 0,1,0, 0,0,Color)
AddVertex(MeshID, -10, 0, -10, 0,1,0, 0,0,Color) // point 4
*/
text1 = CreateText("Mesh Version") : SetTextSize(text1,40)
text2 = CreateText("AGKs Version") : SetTextSize(text2,40)
do
SetTextPosition(text1,100,50)
SetTextPosition(text2,700,50)
RotateObjectLocalX(object,.05)
RotateObjectLocalY(object,.05)
RotateObjectLocalZ(object,.05)
RotateObjectLocalX(AGK,.05)
RotateObjectLocalY(AGK,.05)
RotateObjectLocalZ(AGK,.05)
print(ScreenFPS())
Sync()
loop
// LoadObjectIntoMeshfunction
// x#,y#,z# - Where on the mesh you like it to be positioned at
// filename$ - What is the model name
// debug - 0 to not have any - 1 to have all the info displayed
// save - 0 to not save any Vs/VNs/VTs/Fs in global memory or 1 to keep those in memory to change at a later time in the app if so wish
function LoadObjectIntoMesh(x#, y#, z#, filename$, debug, save)
v as _vector // create an empty type so can inert data
// with face elements these are index references of the above array indexes
//
// f v1 v2 v3 // This will be the indexes of the Vertex 1 2 and 3 in the vertex array
// f v1/vt1 v2/vt2 v3/vt3 // This one has texture / UV assigned to the object and the first is the index in the vertex array and the 2nd is the texture array
// f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 // This one has texture / UV assigned and Normals to the object and the first is the index in the vertex array and the 2nd is the texture array and the index in normals arra
//
// The f data is normally at the end of the OBJ file, so
// What we would have to do first is grab the V into the Vertex array
// then the VNs into the Normal array
// then the VTs into the texture array
// then use the F(aces) data to pick out which vertex to work with the AddVertex command
color=MakeColor(255,255,255)
f = OpenToRead(filename$)
vindex=0
while not FileEOF(f)
line$=ReadLine(f)
if (mid(line$,1,2) = "v ")
line$=mid(line$,3,len(line$))
v.x# = ValFloat(GetStringToken(line$," ",1))
v.y#= ValFloat(GetStringToken(line$," ",2))
v.z#= ValFloat(GetStringToken(line$," ",3))
vertex.insert(v)
endif
if (mid(line$,1,3) = "vn ")
line$=mid(line$,4,len(line$))
v.x# = ValFloat(GetStringToken(line$," ",1))
v.y#= ValFloat(GetStringToken(line$," ",2))
v.z#= ValFloat(GetStringToken(line$," ",3))
normals.insert(v)
endif
if (mid(line$,1,2) = "f ")
line$=mid(line$,3,len(line$))
face1$ = GetStringToken(line$," ",1)
face2$ = GetStringToken(line$," ",2)
face3$ = GetStringToken(line$," ",3)
// v.tindex = Val(GetStringToken(line$,"//",3))-1
// eg constucted F 1//1 14//1 13//1 = Vertex // Normal VertexIndex//NormalIndex VertexIndex//NormalIndex
// X#
for a=1 to len(face1$)
if mid(face1$,a,1)="/"
v.vindex=val(mid(face1$,1,a))-1
v.nindex=val(mid(face1$,a+2,len(face1$)))-1
faces.insert(v)
a=len(face1$) // get out of the loop
endif
next
// Y#
for a=1 to len(face2$)
if mid(face2$,a,1)="/"
v.vindex=val(mid(face2$,1,a))-1
v.nindex=val(mid(face2$,a+2,len(face2$)))-1
faces.insert(v)
a=len(face2$) // et out of the loop
endif
next
// Z#
for a=1 to len(face3$)
if mid(face3$,a,1)="/"
v.vindex=val(mid(face3$,1,a))-1
v.nindex=val(mid(face3$,a+2,len(face3$)))-1
faces.insert(v)
a=len(face3$)
endif
next
// 4 faces = polygon so needs a polygon - 4 vertices command rather than a addvertex (3 points)
// a polygon will require 6xvertices. 1st/2nd/3rd points is indeed makes the first triangle
// then the other 3 needs to be - 2 x shared vertices from the 2 of the previous and an extra one making the
// final outcome of 4 vertices polygon object
/* for a=1 to len(face4$)
if mid(face4$,a,1)="/"
v.vindex=val(mid(face4$,1,a))-1
v.nindex=val(mid(face4$,a+2,len(face4$)))-1
faces.insert(v)
a=len(face4$)
endif
next
*/
endif
endwhile
if debug=1
print(Vertex.length)
for a=0 to vertex.length
print("V " + str(vertex[a].x#) + " " + str(vertex[a].y#) + " " + str(vertex[a].z#))
next
sync()
sleep(2000)
print(Normals.length)
for a=0 to normals.length
print("VN " + str(normals[a].x#) + " " + str(normals[a].y#) + " " + str(normals[a].z#))
next
sync()
sleep(2000)
print(Faces.length)
for a=0 to faces.length
print("F " + str(faces[a].x#) + " " + str(faces[a].y#) + " " + str(faces[a].z#))
next
sync()
sleep(2000)
endif
for a=0 to faces.length
nx# = normals[faces[a].nindex].x#
ny# = normals[faces[a].nindex].y#
nz# = normals[faces[a].nindex].z# * -1
length# = sqrt(nx#*nx# + ny#*ny# + nz#*nz#)
if ( length# > 0x000001f )
length# = 1 / length#
else
ny#=1
length#=1
endif
nx#= (nx# * length#)
ny#= (ny# * length#)
nz#= (nz# * length#)
AddVertex(MeshID, vertex[faces[a].vindex].x#, vertex[faces[a].vindex].y#, vertex[faces[a].vindex].z# ,nx#,ny#,nz#, 0,0,Color)
next
if debug=1
sync()
sleep(1000)
endif
if save=0
vertex.length=-1
normals.length=-1
faces.length=-1
textures.length=-1
endif
CloseFile(f)
endfunction
// X#,Y#,Z# location of where you want it
// First vetex always in centre 0 of x,y,z
// X2# is the 2nd vertex
// X3# is the 3rd
// X4# is the 4th
function createMeshObjectTriangleChunk(x#,y#,z#,x2#,y2#,z2#,x3#,y3#,z3#, x4#,y4#,z4#)
Color=MakeColor(255,255,255)
// bottom
AddVertex(MeshID, x#, y#, z# , 0 ,1, 0, .5,.5,Color)
AddVertex(MeshID, x4#, y4#, z4# , 0 ,1, 0, 0, 1,Color)
AddVertex(MeshID, x2#, y2#, z2# , 0 ,1, 0, 0, 0,Color)
AddVertex(MeshID, x2#, y2#, z2# , 0 ,1, 0, .5,.5,Color)
AddVertex(MeshID, x4#, y4#, z4# , 0 ,1, 0, 0, 1,Color)
AddVertex(MeshID, x3#, y3#, z3# , 0 ,1, 0, 0, 0,Color)
AddVertex(MeshID, x#, y#, z# , 0 ,1, 0, .5,.5,Color)
AddVertex(MeshID, x3#, y3#, z3# , 0 ,1, 0, 0, 0,Color)
AddVertex(MeshID, x4#, y4#, z4# , 0 ,1, 0, 0, 1,Color)
AddVertex(MeshID, x#, y#, z# , 0 ,1, 0, .5,.5,Color)
AddVertex(MeshID, x2#, y2#, z2# , 0 ,1, 0, 0, 0,Color)
AddVertex(MeshID, x3#, y3#, z3# , 0 ,1, 0, 0, 1,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
endfunction
function movecamerawithmouse()
fDiffX# = (GetPointerX() - startx#)/1.0
fDiffY# = (GetPointerY() - starty#)/1.0
newX# = angx# + fDiffY#
// if ( newX# > 360 ) then newX# = 360
// if ( newX# < -360 ) then newX# = -360
// if we keep hold of the left mouse button then rotate the view otherwise the camera stays put
// so can concentrate on adding/removing blocks at that positon
SetCameraRotation( 1, newX#, angy# + fDiffX#, 0 )
endfunction
// X#,Y#,Z# location of where you want it
// First vetex always in centre 0 of x,y,z
// X2# is the 2nd vertex
// X3# is the 3rd
function createMeshObjectTriangleBlock(x#,y#,z#,x2#,z2#,x3#,z3#,height#)
Color=MakeColor(255,255,255)
// bottom
AddVertex(MeshID, x#, y#, z# , 0 ,1, 0, .5,.5,Color)
AddVertex(MeshID, x3#, y#, z3# , 0 ,1, 0, 0, 0,Color)
AddVertex(MeshID, x2#, y#, z2# , 0 ,1, 0, 0, 1,Color)
// top
AddVertex(MeshID, x#, y#+height#, z# , 0 ,1,0, .5, .5,Color)
AddVertex(MeshID, x2#, y#+height#, z2# , 0 ,1,0, 0, 0,Color)
AddVertex(MeshID, x3#, y#+height#, z3# , 0 ,1,0, 0, 1,Color)
// side 1
AddVertex(MeshID, x#, y#, z# , 0 ,1,0, 0, 1,Color)
AddVertex(MeshID, x2#, y#+height#, z2# , 0 ,1,0, 1, 0,Color)
AddVertex(MeshID, x#, y#+height#, z# , 0 ,1,0, 0, 0,Color)
AddVertex(MeshID, x#, y#, z# , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x2#, y#, z2# , 0 ,1,0, 1,1,Color)
AddVertex(MeshID, x2#, y#+height#, z2# , 0 ,1,0, 1,0,Color)
// side 2
AddVertex(MeshID, x2#, y#, z2# , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x3#, y#+height#, z3# , 0 ,1,0, 1,0,Color)
AddVertex(MeshID, x2#, y#+height#, z2# , 0 ,1,0, 0,0,Color)
AddVertex(MeshID, x2#, y#, z2# , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x3#, y#, z3# , 0 ,1,0, 1,1,Color)
AddVertex(MeshID, x3#, y#+height#, z3# , 0 ,1,0, 1,0,Color)
// side 3
AddVertex(MeshID, x3#, y#, z3# , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x#, y#+height#, z# , 0 ,1,0, 1,0,Color)
AddVertex(MeshID, x3#, y#+height#, z3# , 0 ,1,0, 0,0,Color)
AddVertex(MeshID, x3#, y#, z3# , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x#, y#, z# , 0 ,1,0, 1,1,Color)
AddVertex(MeshID, x#, y#+height#, z# , 0 ,1,0, 1,0,Color)
// AddVertex(MeshID, x#, y#+height#, z3# , 0 ,1,0, .5,.5,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
endfunction
function createmeshobjectlighthouse(x#, y#, z#, basewidth#, height#)
CreateMeshObjectConeWithTexture(height#,50,basewidth#,0)
endfunction
function emptymesh()
MeshID.VertexList.Length=-1
MeshID.TriangleList.Length=-1
endfunction
Function CreateMeshObjectPlayWithTexture_Shatter(x#,y#,z#,width#,depth#)
color=MakeColor(random(0,255),random(0,255),random(0,255))
pos#=8 // location of the shatter point
AddVertex(MeshID, x#-width#/2 , y#+depth#/2-depth#/2 ,z# , 0 ,1,0, 0,0.5,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#-width#/2 , y#+depth#/2 ,z# , 0 ,1,0, 0,0,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
AddVertex(MeshID, x#-width#/2 , y#+depth#/2 ,z# , 0 ,1,0, 0,0,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#-width#/2+(depth#/2) , y#+depth#/2 ,z# , 0 ,1,0, .5,0,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
AddVertex(MeshID, x#-width#/2+(depth#/2) , y#+depth#/2 ,z# , 0 ,1,0, .5,0,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#+width#/2 , y#+depth#/2 ,z# , 0 ,1,0, 1,0,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
AddVertex(MeshID, x#+width#/2 , y#+depth#/2 ,z# , 0 ,1,0, 1,0,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#+width#/2 , y#+depth#/2-depth#/2 ,z# , 0 ,1,0, 1,.5,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
AddVertex(MeshID, x#+width#/2 , y#+depth#/2-depth#/2 ,z# , 0 ,1,0, 1,.5,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#+width#/2 , y#-depth#/2 ,z# , 0 ,1,0, 1,1,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
AddVertex(MeshID, x#+width#/2 , y#-depth#/2 ,z# , 0 ,1,0, 1,1,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#+width#/2-depth#/2 , y#-depth#/2 ,z# , 0 ,1,0, .5,1,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
AddVertex(MeshID, x#+width#/2-depth#/2 , y#-depth#/2 ,z#, 0 ,1,0, .5,1,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#-width#/2 , y#-depth#/2 ,z#, 0 ,1,0, 0,1,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
AddVertex(MeshID, x#-width#/2 , y#-depth#/2 ,z# , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x#+(width#/2)-depth#/pos# , y#+(depth#/2)-depth#/pos# ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#-width#/2 , y#+depth#/2-depth#/2 ,z# , 0 ,1,0, 0,.5,Color)
peices.insert(CreateObjectFromMeshWithUVTexturing(MeshID,CubeD))
emptymesh()
endfunction
function splitmesh(splitamount#)
length=meshid.VertexList.length
for a=0 to 5
randomvertex = a
oldx# = MeshID.VertexList[randomvertex].x = MeshID.VertexList[randomvertex].x
oldy# = MeshID.VertexList[randomvertex].y = MeshID.VertexList[randomvertex].y
oldz# = MeshID.VertexList[randomvertex].z = MeshID.VertexList[randomvertex].z
randomsplit#=random2(1,splitamount#)/100.0
MeshID.VertexList[randomvertex].x = MeshID.VertexList[randomvertex].x+randomsplit#
randomsplit#=random2(1,splitamount#)/100.0
MeshID.VertexList[randomvertex].y = MeshID.VertexList[randomvertex].y-randomsplit#
randomsplit#=random2(1,splitamount#)/100.0
MeshID.VertexList[randomvertex].z = MeshID.VertexList[randomvertex].z+randomsplit#
// endif
next
deleteobject(object)
object = CreateObjectFromMeshWithUVTexturing(MeshID,CubeD)
endfunction
function createMeshObjectPlaneWithTexture(x#,y#,z#,width#,depth#)
color=MakeColor(255,255,255)
AddVertex(MeshID, x#-width#/2 , y# ,z#+depth#/2 , 0 ,1,0, 0,0,Color)
AddVertex(MeshID, x#-width#/2 , y# ,z#-depth#/2 , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x#+width#/2 , y# ,z#+depth#/2 , 0 ,1,0, 1,0,Color)
AddVertex(MeshID, x#+width#/2 , y# ,z#+depth#/2 , 0 ,1,0, 1,0,Color)
AddVertex(MeshID, x#-width#/2 , y# ,z#-depth#/2 , 0 ,1,0, 0,1,Color)
AddVertex(MeshID, x#+width#/2 , y# ,z#-depth#/2 , 0 ,1,0, 1,1,Color)
endfunction
function createMeshObjectCylinderWithTexture(x#, y#, z#,height#, baseradius#, topradius#,segments#, top, bottom, color)
if (segments#<3) then segments#=3
if (baseradius#<0) then baseradius#=-baseradius#
radius#=baseradius#/2.0
SegX# = 2*PI# /segments#
SegU# = 1.0 / segments#
if top=1
for i=0 to segments#
nxt = i+1
if ( nxt >= segments# ) then nxt = 0
AddVertex(MeshID, x# , y#+height#/2.0 ,z# , 0 ,1,0, .5,.5,Color)
AddVertex(MeshID, x#+Sinrad(-SegX#*i) * (radius#-topradius#) , y#+height#/2.0 ,z#+CosRad(-SegX#*i) * (radius#-topradius#) , 0 ,1,0, SinRad(-SegX#*i)/2.0+.5,CosRad(SegX#*i)/2.0+.5,Color)
AddVertex(MeshID, x#+Sinrad(-SegX#*nxt) * (radius#-topradius#) , y#+height#/2.0 ,z#+CosRad(-SegX#*nxt) * (radius#-topradius#) , 0 ,1,0, SinRad(-SegX#*(i+1))/2.0+.5,CosRad(SegX#*(i+1))/2.0+.5,Color)
next
endif
for i=0 to segments#
nxt = i+1
if ( nxt >= segments# ) then nxt = 0
AddVertex(MeshID, x#+SinRad(-SegX#*i) * (radius#-topradius#) , y#+height#/2.0 ,z#+CosRad(-SegX#*i) * (radius#-topradius#), SinRad (-SegX#*i) ,0,CosRad(-SegX#*i), SegU#*i,0,Color)
AddVertex(MeshID, x#+Sinrad(-SegX#*i) * (radius#+0) , y#-height#/2.0 ,z#+CosRad(-SegX#*i) * (radius#-0) , SinRad(-SegX#*i) ,0,CosRad(-SegX#*i), SegU#*i,1,Color)
AddVertex(MeshID, x#+Sinrad(-SegX#*nxt) * (radius#+0) , y#-height#/2.0 ,z#+CosRad(-SegX#*nxt) * (radius#-0) , SinRad(-SegX#*nxt) ,0,CosRad(-SegX#*nxt), SegU#*(i+1),1,Color)
AddVertex(MeshID, x#+SinRad(-SegX#*i) * (radius#-topradius#) , y#+height#/2.0 ,z#+CosRad(-SegX#*i) * (radius#-topradius#), SinRad (-SegX#*i) ,0,CosRad(-SegX#*i), SegU#*i,0,Color)
AddVertex(MeshID, x#+Sinrad(-SegX#*nxt) * (radius#-0) , y#-height#/2.0 ,z#+CosRad(-SegX#*nxt) * (radius#-0) , SinRad(-SegX#*nxt) ,0,CosRad(-SegX#*nxt), SegU#*(i+1),1,Color)
AddVertex(MeshID, x#+Sinrad(-SegX#*nxt) * (radius#-topradius#) , y#+height#/2.0 ,z#+CosRad(-SegX#*nxt) * (radius#-topradius#) , SinRad(-SegX#*nxt) ,0,CosRad(-SegX#*nxt), SegU#*(i+1),0,Color)
next
if bottom=1
for i=0 to segments#
nxt = i+1
if ( nxt >= segments# ) then nxt = 0
AddVertex(MeshID, x#+Sinrad(-SegX#*i) * radius# , y#-height#/2.0 ,z#+CosRad(-SegX#*i) * radius# , 0 ,-1,0, SinRad(-SegX#*i)/2.0+.5,CosRad(SegX#*i)/2.0+.5,Color)
AddVertex(MeshID, x# , y#-height#/2.0 ,z# , 0 ,-1,0, .5,.5,Color)
AddVertex(MeshID, x#+Sinrad(-SegX#*nxt) * radius# , y#-height#/2.0 ,z#+CosRad(-SegX#*nxt) * radius# , 0 ,-1,0, SinRad(-SegX#*(i+1))/2.0+.5,CosRad(SegX#*(i+1))/2.0+.5,Color)
next
endif
endfunction
function CreateMeshObjectConeWithTexture(height#, segments#, Radius#, Bottom)
color=MakeColor(255,255,255) // doesnt use color but the AddVertex requires it
SegX# = 2 * PI# / segments#
for i = 0 to segments#
nxt = i+1
if (nxt >= segments#) then nxt=0
AddVertex(MeshID, 0 , height# ,0 , 0,1,0, .5,.5,Color)
AddVertex(MeshID, SinRad(-SegX#*i)*radius# ,-height# ,CosRad(-SegX#*i) * radius#, sinrad( -SegX#*i),abs(radius#)/height#,cosRad(-SegX#*i),SinRad( -SegX# * i ) /2.0 +.5, CosRad(-SegX# * i)/2.0 + .5,Color)
AddVertex(MeshID, SinRad(-SegX#*nxt)*radius# ,-height# ,CosRad(-SegX#*nxt) * radius#, SinRad(-SegX#*nxt),abs(radius#)/height#,CosRad(-SegX# * nxt),SinRad(-SegX# * (i+1) )/2.0 + .5, CosRad(-SegX#*(i+1)) /2.0+.5,Color)
next
if bottom=1
for i = 0 to segments#
nxt = i+1
if (nxt >= segments#) then nxt=0
AddVertex(MeshID, SinRad(-SegX#*i)*radius# ,-height#/2.0 ,CosRad(-SegX#*i) * radius#, 0,-height#,0,SinRad( -SegX#*i) /2.0+.5,CosRad(-SegX#*i)/2.0+.5,Color)
AddVertex(MeshID, 0 , -height#/2.0 ,0 , 0,-height#,0, .5,.5,Color)
AddVertex(MeshID, SinRad(-SegX#*nxt)*radius# ,-height#/2.0 ,CosRad(-SegX#*nxt) * radius#, 0,-height#,0,SinRad(-SegX#*(i+1))/2.0+.5,CosRad(-SegX#*(i+1))/2.0+.5,Color)
next
endif
endfunction MeshID
// creates a full cube with all the same texture all way round it
function CreateMeshObjectBoxWithTexture(X#, Y#, Z#, Width#, Height#, Depth#)
Color= MakeColor(255,255,255) // This doesnt use color but AddVertex requires it
//Front Face
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2), 0,1,0, 0,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2), 0,1,0, 1,0,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2), 0,1,0, 0,0,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2), 0,1,0, 0,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2) ,(Z#-depth#/2), 0,1,0, 1,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2), 0,1,0, 1,0,Color)
// Left
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2) , 0,1,0, 1,1,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2) , 0,1,0, 1,0,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2)+depth# , 0,1,0, 0,1,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2) , 0,1,0, 1,0,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth# , 0,1,0, 0,0,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2)+depth# , 0,1,0, 0,1,Color)
// Right
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2) ,(Z#-depth#/2) , 0,1,0 , 0,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2) ,(Z#-depth#/2)+depth# , 0,1,0 , 1,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2) , 0,1,0 , 0,0,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2) , 0,1,0 , 0,0,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2) ,(Z#-depth#/2)+depth#, 0,1,0 , 1,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth# , 0,1,0 , 1,0,Color)
//back
AddVertex(MeshID, (X#-width#/2) ,(y# -height#/2) ,(Z#-depth#/2)+depth#, 0,1,0, 1,1,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth#, 0,1,0, 1,0,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth#, 0,1,0, 0,0,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2)+depth#, 0,1,0, 1,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth#, 0,1,0, 0,0,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2) ,(Z#-depth#/2)+depth#, 0,1,0, 0,1,Color)
// top
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2) , 0,1,0, 0,0,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2) , 0,1,0, 0,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth# , 0,1,0, 1,1,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2) , 0,1,0, 0,0,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth# , 0,1,0, 1,1,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2)+height# ,(Z#-depth#/2)+depth# , 0,1,0, 1,0,Color)
//bottom
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2) , 0,1,0, 0,1,Color)
AddVertex(MeshID, (X#-width#/2)+width# ,(y#-height#/2) ,(Z#-depth#/2)+depth# , 0,1,0, 1,0,Color)
AddVertex(MeshID, (X#+width#/2) ,(y#-height#/2) ,(Z#-depth#/2) , 0,1,0, 0,0,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2) , 0,1,0, 0,1,Color)
AddVertex(MeshID, (X#-width#/2) ,(y#-height#/2) ,(Z#-depth#/2)+depth# , 0,1,0, 1,1,Color)
AddVertex(MeshID, (X#+width#/2) ,(y#-height#/2) ,(Z#-depth#/2)+depth# , 0,1,0, 1,0,Color)
endfunction MeshID
// This uses an Atlas tilemap image
function addcube(meshID ref as mesh, cubesize#, tilenumberx, tilenumbery, normx#,normy#,normz#,x#,y#,z#)
// calculate the UVs - YIKES here we go
cubex#=((tilenumberx-1) * .5) + tilenumberx //
cubey#=(tilenumbery * 0.5)+ 0.5
maxx# = ((100/15.00)/100) * cubex# // the 15.00 is the amount of textures left to right in the Atlas image
minx# = (maxx#-(100/15.00)/100) // the 15.00 is the amount of textures left to right in the Atlas image
halfx# = (maxx#/2 + minx# / 2)
bottommaxx# = ((100/15.00)/100) * (cubex#+.5) // the 15.00 is the amount of textures left to right in the Atlas image
bottomminx# = (bottommaxx#-((100/15.00)/100)) // the 15.00 is the amount of textures left to right in the Atlas image
bottomhalfx# = (bottommaxx#/2 + bottomminx# / 2)
maxy# = ((100/11.00)/100) * cubey# // the 11.00 is the amount of textures top to bottom in the Atlas image
miny# = (maxy#-(100/11.00)/100) // the 11.00 is the amount of textures top to bottom in the Atlas image
halfy# = (maxy#/2 + miny# / 2)
// create the cube
AddVertex(meshID,x# ,y#,z# ,0,1,0, maxx#,halfy#,MakeColor(255,0,0))
AddVertex(meshID,x#,y#+cubesize#,z# ,0,1,0, maxx#,miny#,MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#,z# ,0,1,0, halfx#,halfy#,MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z# ,0,1,0, halfx#,halfy#,MakeColor(255,0,0))
AddVertex(meshID,x# ,y#+cubesize#,z# ,0,1,0, maxx#,miny#,MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize#,z# ,0,1,0, halfx#,miny#,MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize#,z# ,0,1,0 ,maxx# ,miny#, MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize# ,0,1,0 ,halfx#,miny#,MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z# ,0,1,0 ,maxx#,halfy#, MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z# ,0,1,0 ,maxx# ,halfy#, MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize# ,0,1,0 ,halfx# ,miny#,MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z#+-cubesize# ,0,1,0 ,halfx# ,halfy#, MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z#+-cubesize# ,0,1,0 ,bottommaxx#,miny# , MakeColor(255,0,0))
AddVertex(meshID,x# ,y# ,z# ,0,1,0 ,bottomhalfx#,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z# ,0,1,0 ,bottommaxx#,halfy#, MakeColor(255,0,0))
AddVertex(meshID,x# ,y# ,z# ,0,1,0 ,bottomhalfx#,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z#+-cubesize# ,0,1,0 ,bottommaxx#,miny# , MakeColor(255,0,0))
AddVertex(meshID,x# ,y# ,z#+-cubesize# ,0,1,0 ,bottomhalfx# ,miny# , MakeColor(255,0,0))
AddVertex(meshID,x# ,y# ,z#+-cubesize# ,0,1,0 ,halfx# ,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z#+-cubesize# ,0,1,0 ,maxx# ,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x# ,y#+cubesize#,z#+-cubesize# ,0,1,0 ,halfx#,miny# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize# ,0,1,0 ,maxx#,miny# , MakeColor(255,0,0))
AddVertex(meshID,x# ,y#+cubesize#,z#+-cubesize# ,0,1,0 ,halfx# ,miny# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y# ,z#+-cubesize# ,0,1,0 ,maxx# ,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#,y# ,z#+-cubesize# ,0,1,0 ,maxx# ,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#,y#+cubesize# ,z# ,0,1,0 ,halfx# ,miny# , MakeColor(255,0,0))
AddVertex(meshID,x#,y# ,z# ,0,1,0 ,halfx#,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#,y#+cubesize# ,z# ,0,1,0 ,halfx# ,miny# , MakeColor(255,0,0))
AddVertex(meshID,x#,y# ,z#+-cubesize# ,0,1,0 ,maxx# , halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#,y#+cubesize# ,z#+-cubesize# ,0,1,0 ,maxx# , miny# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize# ,z#+-cubesize# ,0,1,0 ,halfx#,miny# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize# ,z# ,0,1,0 ,minx#,miny#, MakeColor(255,0,0))
AddVertex(meshID,x# ,y#+cubesize# ,z# ,0,1,0 ,minx#,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x# ,y#+cubesize# ,z#+-cubesize# ,0,1,0 ,halfx# ,halfy# , MakeColor(255,0,0))
AddVertex(meshID,x#+cubesize#,y#+cubesize# ,z#+-cubesize# ,0,1,0 ,halfx#,miny# , MakeColor(255,0,0))
AddVertex(meshID,x# ,y#+cubesize# ,z# ,0,1,0 ,minx#,halfy# , MakeColor(255,0,0))
endfunction
Function AddVertex(m ref as Mesh, x as float, y as float, z as float, nx as float, ny as float, nz as float, u as float, v as float, color as integer)
vert as vertex
vert.x = x
vert.y = y
vert.z = z
vert.nx = nx
vert.ny = ny
vert.nz = nz
vert.u = u
vert.v = v
vert.color = color
m.VertexList.Insert(vert)
endfunction
Function AddTriangle(m ref as Mesh, v1 as integer, v2 as integer, v3 as integer)
t as Triangle
t.v1 = v1
t.v2 = v2
t.v3 = v3
m.TriangleList.Insert(t)
endfunction
Function CreateObjectFromMeshWithColor(m ref as mesh)
VertexCount = m.VertexList.Length + 1
IndexCount = (m.TriangleList.Length + 1) * 2
IndexOffset = 72 + VertexCount*36
memblock = CreateMemblock(IndexOffset+IndexCount*4)
SetMemblockInt(memblock,0,VertexCount)
SetMemblockInt(memblock,4,IndexCount)
SetMemblockInt(Memblock,8,4)
SetMemblockInt(memblock,12,32) // no color - 36 if color
SetmemblockInt(memblock,16,72)
SetMemblockInt(memblock,20,IndexOffset)
SetMemblockInt(memblock,24,0x0c000300)
SetMemblockString(Memblock,28,"position")
SetMemblockInt(memblock,40,0x08000300)
SetMemblockString(memblock,44,"normal")
SetMemblockInt(memblock,52,0x04000200)
SetMemblockString(memblock,56,"uv")
SetMemblockInt(memblock,60,0x08010401) // maybe one day or year in 2019 lol
SetMemblockString(memblock,64,"color") // maybe one day or year in 2019 lol
for i = 0 to m.VertexList.Length
SetMemblockFloat(memblock,72+i*36,m.VertexList[i].x)
SetMemblockFloat(memblock,76+i*36,m.VertexList[i].y)
SetMemblockFloat(memblock,80+i*36,m.VertexList[i].z)
SetMemblockFloat(memblock,84+i*36,m.VertexList[i].nx)
SetMemblockFloat(memblock,88+i*36,m.VertexList[i].ny)
SetMemblockFloat(memblock,92+i*36,m.VertexList[i].nz)
SetMemblockFloat(memblock,96+i*36,m.VertexList[i].u)
SetMemblockFloat(memblock,100+i*36,m.VertexList[i].v)
SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
// SetMemblockFloat(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
// SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
next
for i = 0 to m.TriangleList.Length
SetMemblockInt(memblock,IndexOffset+i*12,m.TriangleList[i].v1)
SetMemblockInt(memblock,IndexOffset+i*12+4,m.TriangleList[i].v2)
SetMemblockInt(memblock,IndexOffset+i*12+8,m.TriangleList[i].v3)
next
id = CreateObjectFromMeshMemblock(memblock)
// DeleteMemblock(memblock)
endfunction id
Function CreateObjectFromMeshWithUVTexturing(m ref as mesh, texture)
DeleteMemblock(memblock)
VertexCount = m.VertexList.Length + 1
IndexCount = (m.TriangleList.Length + 1) * 2
IndexOffset = 60 + VertexCount*36
memblock = CreateMemblock(IndexOffset+IndexCount*4)
SetMemblockInt(memblock,0,VertexCount)
SetMemblockInt(memblock,4,IndexCount)
SetMemblockInt(Memblock,8,3)
SetMemblockInt(memblock,12,32) // no color - 36 if color
SetmemblockInt(memblock,16,60)
SetMemblockInt(memblock,20,IndexOffset)
SetMemblockInt(memblock,24,0x0c000300)
SetMemblockString(Memblock,28,"position")
SetMemblockInt(memblock,40,0x08000300)
SetMemblockString(memblock,44,"normal")
SetMemblockInt(memblock,52,0x04000200)
SetMemblockString(memblock,56,"uv")
//SetMemblockInt(memblock,60,0x08010401) // maybe one day or year in 2019 lol
//SetMemblockString(memblock,64,"color") // maybe one day or year in 2019 lol
for i = 0 to m.VertexList.Length
SetMemblockFloat(memblock,60+i*32,m.VertexList[i].x)
SetMemblockFloat(memblock,64+i*32,m.VertexList[i].y)
SetMemblockFloat(memblock,68+i*32,m.VertexList[i].z)
SetMemblockFloat(memblock,72+i*32,m.VertexList[i].nx)
SetMemblockFloat(memblock,76+i*32,m.VertexList[i].ny)
SetMemblockFloat(memblock,80+i*32,m.VertexList[i].nz)
SetMemblockFloat(memblock,84+i*32,m.VertexList[i].u)
SetMemblockFloat(memblock,88+i*32,m.VertexList[i].v)
//SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
next
// for i = 0 to m.TriangleList.Length
// SetMemblockInt(memblock,IndexOffset+i*12,m.TriangleList[i].v1)
// SetMemblockInt(memblock,IndexOffset+i*12+4,m.TriangleList[i].v2)
// SetMemblockInt(memblock,IndexOffset+i*12+8,m.TriangleList[i].v3)
// next
DeleteObject(id)
id = CreateObjectFromMeshMemblock(memblock)
SetObjectImage(id,texture,0)
// if mode=1 // creates the world or it creates for other small things - like explosion blocks
// we need to keep the world chunk in memory so we can keep updating the vertices
meshmemory = memblock
// endif
// DeleteMemblock(memblock)
endfunction id
/*createMeshObjectTriangleBlock( 0, 0, 0, 10, -10, 10, 0,10)
createMeshObjectTriangleBlock( 0, 0, 0, 10, 0, 10, 10,10)
createMeshObjectTriangleBlock( 0, 0, 0, 10, 10, 0, 10,10)
createMeshObjectTriangleBlock( 0, 0, 0, 0, 10, -10, 10,10)
createMeshObjectTriangleBlock( 0, 0, 0, -10, 10, -10, 0,10)
createMeshObjectTriangleBlock( 0, 0, 0, -10, 0, -10, -10,10)
createMeshObjectTriangleBlock( 0, 0, 0, -10, -10, 0, -10,10)
/*createMeshObjectTriangleBlock( 0, 0, 0, -size#/2,-size#/2, size#/2, -size#/2 ,size#)
createMeshObjectTriangleBlock( 0, 0, 0, size#/2,-size#/2, size#/2, size#/2 ,size#)
createMeshObjectTriangleBlock( 0, 0, 0, size#/2, size#/2, -size#/2, size#/2 ,size#)
*/
//createMeshObjectTriangleBlock(10, 0, -10, 10, 0, 0, 0 , 10)
//CreateMeshObjectPlayWithTexture_Shatter(0,0,0,100,100)
//SetObjectPosition(faces[0],0,0,0) // front
//SetObjectRotation(faces[1],90,0,0) // top
//SetObjectPosition(faces[2],0,0,0)
//createmeshobjectlighthouse(0,0,0,20,10)
//function createMeshObjectCylinderWithTexture(x#, y#, z#,height#, baseradius#, topradius#,segments#, top, bottom, color)
//lighgthouse
//createMeshObjectCylinderWithTexture(0,0,0,30,10,3,10,1,0,MakeColor(255,255,255))
//goblet
/*createMeshObjectTriangleChunk( 0, 0, 0, -20, 20, 0, 0, 20, 0, 0,20,-20)
createMeshObjectTriangleChunk( 0, 0, 0, 20, 20, 0, 0, 20, -20, 0,20,0)
// Cube full of 24 segments
// first layer
createMeshObjectTriangleChunk( 0, 0, 0, -size#, size# , 0, 0, size#, size# , 0,size#,0)
createMeshObjectTriangleChunk( 0, 0, 0, size#, size# , 0, 0, size#, 0 , 0,size#,size#)
createMeshObjectTriangleChunk( 0, 0, 0, size#, size# , 0, size#, 0, size# , size#,0,0)
createMeshObjectTriangleChunk( 0, 0, 0, size#, -size# , 0, size#, 0, 0 , size#,0,size#)
createMeshObjectTriangleChunk( 0, 0, 0, size#, -size# , 0, 0, -size#, size# , 0,-size#,0)
createMeshObjectTriangleChunk( 0, 0, 0, -size#, -size# , 0, 0, -size#, 0 , 0,-size#,size#)
createMeshObjectTriangleChunk( 0, 0, 0, -size#, -size# , 0, -size#,0, size# , -size#,0,0)
createMeshObjectTriangleChunk( 0, 0, 0, -size#, 0 , 0, -size#,0, size# , -size#,size#,0)
// 2nd later
createMeshObjectTriangleChunk( 0, -size#, size#, -size#, -size#, 0, -size#,-size#, size#, -size#, 0, size#)
createMeshObjectTriangleChunk( 0, -size#, size#, size#, -size#, 0, size#, 0, size# ,size#,-size#, size#)
createMeshObjectTriangleChunk( 0, size#, size#, size#, size#, 0, size#, size#, size# ,size#, 0, size#)
createMeshObjectTriangleChunk( 0, size#, size#, -size#, size#, 0, -size#, 0, size#, -size#, size#, size#)
// 3rd later
createMeshObjectTriangleChunk( 0, size#, size#, -size#, size#, size#, -size#, 0, size#, -size#,size#,size#*2)
createMeshObjectTriangleChunk( 0, size#, size#, size#, size#, size#, size# , size#,size#*2, size#,0, size# )
createMeshObjectTriangleChunk( 0, -size#, size#, size#, -size#, size#, size# , 0, size#, size#,-size#, size#*2 )
createMeshObjectTriangleChunk( 0, -size#, size#, -size#, -size#, size#, -size#, -size#,size#*2, -size#,0,size#)
// final layer
createMeshObjectTriangleChunk( 0, 0, size#*2, -size#,size#, size#*2, 0, size#, size#*2, 0,size#,size#)
createMeshObjectTriangleChunk( 0, 0, size#*2, size#, size#, size#*2, 0, size#, size#, 0,size#,size#*2)
createMeshObjectTriangleChunk( 0, 0, size#*2, size#, size#, size#*2, size#, 0, size#*2, size#,0,size#)
createMeshObjectTriangleChunk( 0, 0, size#*2, size#, -size#, size#*2, size#, 0, size#, size#,0,size#*2)
createMeshObjectTriangleChunk( 0, 0, size#*2, size#, -size#, size#*2, 0, -size#, size#*2, 0,-size#,size#)
createMeshObjectTriangleChunk( 0, 0, size#*2, -size#,-size#, size#*2, 0, -size#, size#, 0,-size#,size#*2)
createMeshObjectTriangleChunk( 0, 0, size#*2, -size#,-size#, size#*2, -size#,0, size#*2, -size#,0,size#)
createMeshObjectTriangleChunk( 0, 0, size#*2, -size#,-size#, size#*2, -size#,0, size#*2, -size#,0,size#)
createMeshObjectTriangleChunk( 0, 0, size#*2, -size#, 0, size#*2, -size#,size#, size#*2, -size#,0,size#)
*/
Normals needs figuring out im not happy with it