25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

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