Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GLuint amt = 1000;
- glm::mat4* asteroidMatrices;
- asteroidMatrices = new glm::mat4[amt];
- srand(glfwGetTime());
- GLfloat rad = 50.0f;
- GLfloat offset = 5.0f;
- for (GLuint i = 0; i < amt; i++) {
- glm::mat4 model;
- GLfloat angle = (GLfloat)i / (GLfloat)amt * 360.0f;
- GLfloat displacement = (rand() % (GLint)(2 * offset * 100)) / 100.0f - offset;
- GLfloat x = -sin(angle) * rad + displacement * 10;
- displacement = (rand() % (GLint)(2 * offset * 100)) / 100.0f - offset;
- GLfloat y = displacement * 0.4f; // Keep height of asteroid field smaller compared to width of x and z
- displacement = (rand() % (GLint)(2 * offset * 100)) / 100.0f - offset;
- GLfloat z = sin(angle) * rad + displacement * 25;
- model = glm::translate(model, glm::vec3(x, y, z));
- GLfloat scale = (rand() % 60) / 100.0f + 0.05;
- model = glm::scale(model, glm::vec3(scale));
- asteroidMatrices[i] = model;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement