No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

nacl_phystest.cpp 3.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 HAVE_CONFIG_H
  8. # include "config.h"
  9. #endif
  10. #include <lol/engine.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");
  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(vec3(0.2f, 0.2f, 0.f));
  51. m_light1->SetColor(vec4(0.5f, 0.5f, 0.5f, 1.f));
  52. m_light1->SetType(LightType::Directional);
  53. Ticker::Ref(m_light1);
  54. /* Add an orangeish point light */
  55. m_light2 = new Light();
  56. m_light2->SetPosition(vec3(-15.f, 15.f, 15.f));
  57. m_light2->SetColor(vec4(0.4f, 0.3f, 0.2f, 1.f));
  58. m_light2->SetType(LightType::Point);
  59. Ticker::Ref(m_light2);
  60. }
  61. void Nacl_PhysTest::TickGame(float seconds)
  62. {
  63. WorldEntity::TickGame(seconds);
  64. if (m_controller->IsKeyReleased(KEY_QUIT))
  65. Ticker::Shutdown();
  66. }
  67. void Nacl_PhysTest::TickDraw(float seconds, Scene &scene)
  68. {
  69. WorldEntity::TickDraw(seconds, scene);
  70. if (!m_ready)
  71. {
  72. /* FIXME: this object never cleans up */
  73. m_ready = true;
  74. }
  75. else
  76. {
  77. }
  78. }
  79. Nacl_PhysTest::~Nacl_PhysTest()
  80. {
  81. g_scene->PopCamera(m_camera);
  82. Ticker::Unref(m_light1);
  83. Ticker::Unref(m_light2);
  84. //Ticker::Unref(m_simulation);
  85. }
  86. int main(int argc, char **argv)
  87. {
  88. System::Init(argc, argv);
  89. Application app("Nacl_PhysTest", ivec2(1280, 960), 60.0f);
  90. new Nacl_PhysTest(argc > 1);
  91. app.ShowPointer(false);
  92. app.Run();
  93. return EXIT_SUCCESS;
  94. }