main.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <iostream>
  2. #include "assert.h"
  3. #include <string.h>
  4. #include <math.h>
  5. #include <stdlib.h>
  6. #include <limits.h>
  7. #include <time.h>
  8. using namespace std;
  9. float UnitRandom (void)
  10. {
  11. return rand () / static_cast<float> (RAND_MAX);
  12. }
  13. int main (int argc, char** argv)
  14. {
  15. srand (static_cast<unsigned int> (time (0)));
  16. for (int i = 0; i < argc; i++)
  17. if (argv[i][0] == '-')
  18. if (strcmp (argv[i], "-count") == 0)
  19. if (argc > (i + 1))
  20. {
  21. int iCount = atoi (argv[i + 1]);
  22. // aspect ratio 5x5x1
  23. float fWidth = sqrtf (static_cast<float> (iCount));
  24. int iWidth = static_cast<int> (floorf (fWidth));
  25. int iHeight = iCount / iWidth;
  26. //cout << "Count: " << iCount << endl << "Width: " << iWidth << endl << "Height: " << iHeight << endl;
  27. // world size 10,000x10,000x2,000
  28. float fWidthMultiplier = 10000.0f / static_cast<float> (iWidth);
  29. float fHeightMultiplier = 10000.0f / static_cast<float> (iHeight);
  30. iCount = 0;
  31. for (int j = 0; j < iHeight; j++)
  32. {
  33. for (int k = 0; k < iWidth; k++)
  34. {
  35. float radius = (UnitRandom () * 200.0f) + 150.0f;
  36. float mass = radius * radius;
  37. float hitpoints = radius * 5.0f;
  38. float signature = radius / 10.0f;
  39. float rotation = 0.1 + (UnitRandom () * 0.15f);
  40. bool isHelium = (UnitRandom () < 0.1f) ? true : false;
  41. float ore = 1000.0f + (UnitRandom () * 10000.0f);
  42. float x = ((UnitRandom () + static_cast<float> (k)) * fWidthMultiplier) - 5000.0f;
  43. float y = ((UnitRandom () + static_cast<float> (j)) * fWidthMultiplier) - 5000.0f;
  44. float z = (UnitRandom () * 2000.0f) - 1000.0f;
  45. cout << "1024\t1\t" << iCount++ << "\t" << ore << "\t" << (isHelium ? 1 : 0) << "\t" << static_cast<int> (hitpoints) << "\t" << static_cast<int> (radius) << "\t" << (isHelium ? "bgrnd56" : "bgrnd03") << "\t\tmeteoricon\t" << mass << "\t" << signature << "\t" << x << "\t" << y << "\t" << z << " \t" << rotation << "\tName" << endl;
  46. }
  47. }
  48. return 0;
  49. }
  50. cout << "gimme a count (-count 10)" << endl;
  51. return 1;
  52. }