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

116 lines
3.8 KiB

  1. //
  2. // Lol Engine — Bullet physics test
  3. //
  4. // Copyright © 2012—2019 Sam Hocevar <sam@hocevar.net>
  5. // © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
  6. //
  7. // Lol Engine is free software. It comes without any warranty, to
  8. // the extent permitted by applicable law. You can redistribute it
  9. // and/or modify it under the terms of the Do What the Fuck You Want
  10. // to Public License, Version 2, as published by the WTFPL Task Force.
  11. // See http://www.wtfpl.net/ for more details.
  12. //
  13. #pragma once
  14. #include <memory>
  15. #include <string>
  16. #include <map>
  17. class CatShaderData : public GpuShaderData
  18. {
  19. friend class CRenderer;
  20. public:
  21. //---
  22. CatShaderData(uint32_t vert_decl_flags, std::shared_ptr<Shader> shader);
  23. //---
  24. void SetupDefaultData();
  25. virtual void SetupShaderDatas(mat4 const &model);
  26. //--
  27. virtual std::string GetInVertexName() { return "in_vertex"; }
  28. virtual std::string GetInNormalName() { return "in_normal"; }
  29. virtual std::string GetInColorName() { return "in_color"; }
  30. virtual std::string GetInTexCoordName() { return "in_texcoord"; }
  31. TextureUniform m_tex_uniform;
  32. float m_sprite_orientation;
  33. float m_sprite_flip;
  34. };
  35. class BtPhysTest : public WorldEntity
  36. {
  37. public:
  38. BtPhysTest(bool editor = false);
  39. virtual ~BtPhysTest();
  40. std::string GetName() const { return "<BtPhysTest>"; }
  41. protected:
  42. virtual void tick_game(float seconds);
  43. virtual void tick_draw(float seconds, Scene &scene);
  44. void InitApp();
  45. private:
  46. //MeshViewerInput ---------------------------------------------------------
  47. struct BtPhysTestKeyInputBase : public StructSafeEnum
  48. {
  49. enum Type
  50. {
  51. KEY_START = 0,
  52. KEY_MOVE_FORWARD = KEY_START,
  53. KEY_MOVE_BACK,
  54. KEY_MOVE_LEFT,
  55. KEY_MOVE_RIGHT,
  56. KEY_MOVE_UP,
  57. KEY_MOVE_DOWN,
  58. KEY_MOVE_JUMP,
  59. KEY_QUIT,
  60. KEY_MAX
  61. };
  62. protected:
  63. virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map)
  64. {
  65. enum_map[KEY_MOVE_FORWARD] = input::key_to_name(input::key::SC_Up);
  66. enum_map[KEY_MOVE_BACK] = input::key_to_name(input::key::SC_Down);
  67. enum_map[KEY_MOVE_LEFT] = input::key_to_name(input::key::SC_Left);
  68. enum_map[KEY_MOVE_RIGHT] = input::key_to_name(input::key::SC_Right);
  69. enum_map[KEY_MOVE_UP] = input::key_to_name(input::key::SC_PageUp);
  70. enum_map[KEY_MOVE_DOWN] = input::key_to_name(input::key::SC_PageDown);
  71. enum_map[KEY_MOVE_JUMP] = input::key_to_name(input::key::SC_Space);
  72. enum_map[KEY_QUIT] = input::key_to_name(input::key::SC_Escape);
  73. return true;
  74. }
  75. };
  76. typedef SafeEnum<BtPhysTestKeyInputBase> BtPhysTestKeyInput;
  77. TileSet* m_cat_texture;
  78. std::shared_ptr<Shader> m_cat_shader;
  79. CatShaderData* m_cat_sdata;
  80. Camera* m_camera;
  81. Light* m_light1;
  82. Light* m_light2;
  83. int m_init_status;
  84. bool m_ready;
  85. lol::phys::Simulation* m_simulation;
  86. array<EasyConstraint*> m_constraint_list;
  87. array<PhysicsObject*, float> m_physobj_list;
  88. array<PhysicsObject*> m_ground_list;
  89. array<PhysicsObject*> m_platform_list;
  90. array<PhysicsObject*> m_character_list;
  91. array<PhysicsObject*> m_stairs_list;
  92. float m_loop_value;
  93. float m_target_timer;
  94. int m_cam_target;
  95. float m_fov_dp;
  96. float m_loc_dp;
  97. };