I've been trying to create a quad using memblocks for a while. But i could only find information on how to build a triangle.

And couldn't find anything in the tier2 agk guide. Or on other places on the internet does anyone know how i could make a quad using this script?

I did try modifying things but the model always gets corrupted and disappears.

//first we will create a memblock to hold the mesh
auto memblock = agk::CreateMemblock(160);
//Now we need to fill it with mesh data
agk::SetMemblockInt(memblock, 0, 3); //3 vertices
agk::SetMemblockInt(memblock, 4, 3); //3 indices, not necissary for simple triangle, but we do it here for completeness
agk::SetMemblockInt(memblock, 8, 3); //Our mesh has 3 attributes, position, normal, color
agk::SetMemblockInt(memblock, 12, 28);//number of bytes each vertext takes up. x,y,z,nx,ny,nz,color * 4
agk::SetMemblockInt(memblock, 16, 64); //offset to vertex data
agk::SetMemblockInt(memblock, 20, 148); //offset to index data
// Attribute information, I'm combining all bytes into a single int.
// Little endiness means order is string length, normal flag, component count, data type (data will
// be written to the MemBlock in reverse order).
agk::SetMemblockInt(memblock, 24, 0x0C000300); //float, 3 components, no normalizing, position
agk::SetMemblockString(memblock, 28, "position");
agk::SetMemblockInt(memblock, 40, 0x08000300); //same as position, but for normals
agk::SetMemblockString(memblock, 44, "normal");
agk::SetMemblockInt(memblock, 52, 0x08010401); //For color we have byte, 4 components, normalize data
agk::SetMemblockString(memblock, 56, "color");
//Now we can enter vertex data
float Vertex[] = {
0.0, 20.0, 0.0, //X - Red
0.0, 20.0, 50.0, //Y - Green
50.0, 20.0, 0.0 //Z - Blue
};
int Color[3] = { agk::MakeColor(255, 0, 0), agk::MakeColor(0, 255, 0), agk::MakeColor(0, 0, 255) };
for (int i = 0; i < 3; i++) {
agk::SetMemblockFloat(memblock, 64 + i * 28, Vertex[i * 3]); //x
agk::SetMemblockFloat(memblock, 68 + i * 28, Vertex[(i * 3) + 1]); //y
agk::SetMemblockFloat(memblock, 72 + i * 28, Vertex[(i * 3) + 2]); //z
agk::SetMemblockFloat(memblock, 76 + i * 28, 0.0); //nx
agk::SetMemblockFloat(memblock, 80 + i * 28, 0.0); //ny
agk::SetMemblockFloat(memblock, 84 + i * 28, -1.0); //nz
agk::SetMemblockInt(memblock, 88 + i * 28, Color[i]); //color
}
// Now the index data
agk::SetMemblockInt(memblock, 148, 0);
agk::SetMemblockInt(memblock, 152, 2);
agk::SetMemblockInt(memblock, 156, 1);
//Now to create the object
auto triangle = agk::CreateObjectFromMeshMemblock(memblock);
agk::CreateFileFromMemblock("/test.mbl", memblock);
// Xnode
auto xSphere = agk::CreateObjectSphere(5, 5, 5);
agk::SetObjectPosition(xSphere, Vertex[0], Vertex[1], Vertex[2]);
agk::SetObjectColor(xSphere, 255, 0, 0, 1);
// Ynode
auto ySphere = agk::CreateObjectSphere(5, 5, 5);
agk::SetObjectPosition(ySphere, Vertex[3], Vertex[4], Vertex[5]);
agk::SetObjectColor(ySphere, 0, 255, 0, 1);
// Znode
auto zSphere = agk::CreateObjectSphere(5, 5, 5);
agk::SetObjectPosition(zSphere, Vertex[6], Vertex[7], Vertex[8]);
agk::SetObjectColor(zSphere, 0, 0, 255, 1);