You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

122 lines
3.1 KiB

  1. //
  2. // BtPhysTest
  3. //
  4. // Copyright: (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
  5. // (c) 2012-2013 Sam Hocevar <sam@hocevar.net>
  6. //
  7. #if defined HAVE_CONFIG_H
  8. # include "config.h"
  9. #endif
  10. #include "core.h"
  11. #include "loldebug.h"
  12. using namespace lol;
  13. #ifndef HAVE_PHYS_USE_BULLET
  14. #define HAVE_PHYS_USE_BULLET
  15. #endif /* HAVE_PHYS_USE_BULLET */
  16. //#include "physics/lolphysics.h"
  17. //#include "physics/easyphysics.h"
  18. #include "nacl_phystest.h"
  19. //using namespace lol::phys;
  20. int gNumObjects = 64;
  21. Nacl_PhysTest::Nacl_PhysTest(bool editor)
  22. {
  23. /* Register an input controller for the keyboard */
  24. m_controller = new Controller(KEY_MAX, 0);
  25. m_controller->GetKey(KEY_MOVE_FORWARD).Bind("Keyboard", "Up");
  26. m_controller->GetKey(KEY_MOVE_BACK).Bind("Keyboard", "Down");
  27. m_controller->GetKey(KEY_MOVE_LEFT).Bind("Keyboard", "Left");
  28. m_controller->GetKey(KEY_MOVE_RIGHT).Bind("Keyboard", "Right");
  29. m_controller->GetKey(KEY_MOVE_JUMP).Bind("Keyboard", "Space");
  30. m_controller->GetKey(KEY_MOVE_UP).Bind("Keyboard", "PageUp");
  31. m_controller->GetKey(KEY_MOVE_DOWN).Bind("Keyboard", "PageDown");
  32. m_controller->GetKey(KEY_QUIT).Bind("Keyboard", "Escape");
  33. /* Create a camera that matches the settings of XNA BtPhysTest */
  34. m_camera = new Camera();
  35. m_camera->SetView(vec3(50.f, 50.f, 0.f),
  36. vec3(0.f, 0.f, 0.f),
  37. vec3(0, 1, 0));
  38. m_camera->SetProjection(45.f, .1f, 1000.f, (float)Video::GetSize().x, (float)Video::GetSize().y / (float)Video::GetSize().x);
  39. g_scene->PushCamera(m_camera);
  40. m_ready = false;
  41. /*
  42. m_simulation = new Simulation();
  43. m_simulation->SetWorldLimit(vec3(-1000.0f, -1000.0f, -1000.0f), vec3(1000.0f, 1000.0f, 1000.0f));
  44. m_simulation->Init();
  45. vec3 NewGravity = vec3(.0f, -10.0f, .0f);
  46. m_simulation->SetGravity(NewGravity);
  47. m_simulation->SetContinuousDetection(true);
  48. m_simulation->SetTimestep(1.f / 120.f);
  49. Ticker::Ref(m_simulation);
  50. */
  51. /* Add a white directional light */
  52. m_light1 = new Light();
  53. m_light1->SetPosition(vec4(0.2f, 0.2f, 0.f, 0.f));
  54. m_light1->SetColor(vec4(0.5f, 0.5f, 0.5f, 1.f));
  55. Ticker::Ref(m_light1);
  56. /* Add an orangeish point light */
  57. m_light2 = new Light();
  58. m_light2->SetPosition(vec4(-15.f, 15.f, 15.f, 1.f));
  59. m_light2->SetColor(vec4(0.4f, 0.3f, 0.2f, 1.f));
  60. Ticker::Ref(m_light2);
  61. }
  62. void Nacl_PhysTest::TickGame(float seconds)
  63. {
  64. WorldEntity::TickGame(seconds);
  65. if (m_controller->GetKey(KEY_QUIT).IsReleased())
  66. Ticker::Shutdown();
  67. }
  68. void Nacl_PhysTest::TickDraw(float seconds)
  69. {
  70. WorldEntity::TickDraw(seconds);
  71. if (!m_ready)
  72. {
  73. /* FIXME: this object never cleans up */
  74. m_ready = true;
  75. }
  76. else
  77. {
  78. }
  79. }
  80. Nacl_PhysTest::~Nacl_PhysTest()
  81. {
  82. g_scene->PopCamera(m_camera);
  83. Ticker::Unref(m_light1);
  84. Ticker::Unref(m_light2);
  85. //Ticker::Unref(m_simulation);
  86. }
  87. int main(int argc, char **argv)
  88. {
  89. System::Init(argc, argv);
  90. Application app("Nacl_PhysTest", ivec2(1280, 960), 60.0f);
  91. new Nacl_PhysTest(argc > 1);
  92. app.ShowPointer(false);
  93. app.Run();
  94. return EXIT_SUCCESS;
  95. }