Possible bug:
i have a small sample to test how mush to gain from mesh batching.
for y = 0 to 64
terrainobject[0,y] = CreateObjectPlane(15.0,15.0)
SetObjectPosition(terrainobject[0,y],0,0,y*16)
rencolr = random(1,255)
rencolg = random(1,255)
rencolb = random(1,255)
SetObjectColor(terrainobject[0,y],rencolr,rencolg,rencolb,255)
for x = 1 to 64 step 2
if batching = 1
terrainmesh[x,y] = CreateMemblockFromObjectMesh( plane, 1 )
for a = 0 to 11
SetMeshMemblockVertexPosition( terrainmesh[x,y], a, GetMeshMemblockVertexX( terrainmesh[x,y], a )+(x*16) ,GetMeshMemblockVertexY( terrainmesh[x,y], a ), GetMeshMemblockVertexZ( terrainmesh[x,y], a )+y)
next a
for a = 6 to 11
SetMeshMemblockVertexPosition( terrainmesh[x,y], a, GetMeshMemblockVertexX( terrainmesh[x,y], a )+16 ,GetMeshMemblockVertexY( terrainmesh[x,y], a ), GetMeshMemblockVertexZ( terrainmesh[x,y], a ))
next a
AddObjectMeshFromMemblock( terrainobject[0,y], terrainmesh[x,y] )
SetObjectColor(terrainobject[0,y],rencolr,rencolg,rencolb,255)
SetObjectCollisionMode(terrainobject[0,y],0)
SetObjectTransparency(terrainobject[0,y],0)
SetObjectLightMode(terrainobject[0,y],0)
SetObjectCullMode(terrainobject[0,y],0)
DeleteMemblock(terrainmesh[x,y])
else
terrainmesh[x,y] = CreateMemblockFromObjectMesh( plane , 1 )
for a = 0 to 11
SetMeshMemblockVertexPosition( terrainmesh[x,y], a, GetMeshMemblockVertexX( terrainmesh[x,y], a )+(x*16) ,GetMeshMemblockVertexY( terrainmesh[x,y], a ), GetMeshMemblockVertexZ( terrainmesh[x,y], a )+y)
next a
for a = 6 to 11
SetMeshMemblockVertexPosition( terrainmesh[x,y], a, GetMeshMemblockVertexX( terrainmesh[x,y], a )+16 ,GetMeshMemblockVertexY( terrainmesh[x,y], a ), GetMeshMemblockVertexZ( terrainmesh[x,y], a ))
next a
terrainobject[x,y] = CreateObjectFromMeshMemblock( terrainmesh[x,y] )
SetObjectPosition(terrainobject[x,y],0,0,y*16)
SetObjectRotation(terrainobject[x,y],90,0,0)
SetObjectColor(terrainobject[x,y],rencolr,rencolg,rencolb,255)
SetObjectCollisionMode(terrainobject[x,y],0)
SetObjectTransparency(terrainobject[x,y],0)
SetObjectLightMode(terrainobject[x,y],0)
SetObjectCullMode(terrainobject[x,y],0)
DeleteMemblock(terrainmesh[x,y])
endif
next x
SetObjectRotation(terrainobject[0,y],90,0,0)
next y
DeleteObject(plane)
Tried to add +y to the SetMeshMemblockVertexPosition Z pos , and it looks like it change the Y , so perhaps SetMeshMemblockVertexPosition has swapped Y and Z , X look fine.
Please confirm by changing your sample by swapping Y,Z when using SetMeshMemblockVertexPosition.
BTW: if you batch meshes using AddObjectMeshFromMemblock , you gain a 100% increase in speed , yes 100%
, but i assume your making one large object , so you will not have this problem.
best regards Preben Eriksen,