Where TileSize is the size of each square (say 64 quants * 64 quants)
function SnapIt()
{
if (my.x < 0)
{
my.x = TileSize * (int(my.x / TileSize)) - (TileSize / 2);
}
if (my.x >= 0)
{
my.x = TileSize * (int(my.x / TileSize)) + (TileSize / 2);
}
if (my.y < 0)
{
my.y = TileSize * (int(my.y / TileSize)) - (TileSize / 2);
}
if (my.y >= 0)
{
my.y = TileSize * (int(my.y / TileSize)) + (TileSize / 2);
}
}
As you can see it is pretty simple, what I would suggest is go to the acknex
resources pages (to the tutorials section) and download a tutorial called "3d tile-based game programming", this will help you set up you mouse and constrain the grid to whatever sides of the cube you want.