Skip to content

Instantly share code, notes, and snippets.

@alexesDev
Created September 1, 2012 19:36
Show Gist options
  • Select an option

  • Save alexesDev/3584731 to your computer and use it in GitHub Desktop.

Select an option

Save alexesDev/3584731 to your computer and use it in GitHub Desktop.
Make 3D lines from root
int centerX = size / 2;
int centerZ = size / 2;
data[idx(centerX, size - 1, centerZ)] = 1;
for(int i = 0; i < 128; ++i)
{
int endX = std::rand() % (size - 1);
int endZ = std::rand() % (size - 1);
data[idx(endX, 0, endZ)] = 1;
int deltaX = centerX - endX;
int deltaY = size - 1;
int deltaZ = centerZ - endZ;
float factorX = deltaX / (float)deltaY;
float factorZ = deltaZ / (float)deltaY;
for(int y = 1; y < size - 1; ++y)
{
int x = factorX * y;
int z = factorZ * y;
data[idx(x + endX, y, z +endZ)] = 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment