The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

110 lines
3.3KB

  1. /*
  2. * Copyright (c) 2006-2010 Erin Catto http://www.box2d.org
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. * Permission is granted to anyone to use this software for any purpose,
  8. * including commercial applications, and to alter it and redistribute it
  9. * freely, subject to the following restrictions:
  10. * 1. The origin of this software must not be misrepresented; you must not
  11. * claim that you wrote the original software. If you use this software
  12. * in a product, an acknowledgment in the product documentation would be
  13. * appreciated but is not required.
  14. * 2. Altered source versions must be plainly marked as such, and must not be
  15. * misrepresented as being the original software.
  16. * 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifndef EDGE_TEST_H
  19. #define EDGE_TEST_H
  20. class EdgeTest : public Test
  21. {
  22. public:
  23. EdgeTest()
  24. {
  25. {
  26. b2BodyDef bd;
  27. b2Body* ground = m_world->CreateBody(&bd);
  28. b2Vec2 v1(-10.0f, 0.0f), v2(-7.0f, -2.0f), v3(-4.0f, 0.0f);
  29. b2Vec2 v4(0.0f, 0.0f), v5(4.0f, 0.0f), v6(7.0f, 2.0f), v7(10.0f, 0.0f);
  30. b2EdgeShape shape;
  31. shape.Set(v1, v2);
  32. shape.m_hasVertex3 = true;
  33. shape.m_vertex3 = v3;
  34. ground->CreateFixture(&shape, 0.0f);
  35. shape.Set(v2, v3);
  36. shape.m_hasVertex0 = true;
  37. shape.m_hasVertex3 = true;
  38. shape.m_vertex0 = v1;
  39. shape.m_vertex3 = v4;
  40. ground->CreateFixture(&shape, 0.0f);
  41. shape.Set(v3, v4);
  42. shape.m_hasVertex0 = true;
  43. shape.m_hasVertex3 = true;
  44. shape.m_vertex0 = v2;
  45. shape.m_vertex3 = v5;
  46. ground->CreateFixture(&shape, 0.0f);
  47. shape.Set(v4, v5);
  48. shape.m_hasVertex0 = true;
  49. shape.m_hasVertex3 = true;
  50. shape.m_vertex0 = v3;
  51. shape.m_vertex3 = v6;
  52. ground->CreateFixture(&shape, 0.0f);
  53. shape.Set(v5, v6);
  54. shape.m_hasVertex0 = true;
  55. shape.m_hasVertex3 = true;
  56. shape.m_vertex0 = v4;
  57. shape.m_vertex3 = v7;
  58. ground->CreateFixture(&shape, 0.0f);
  59. shape.Set(v6, v7);
  60. shape.m_hasVertex0 = true;
  61. shape.m_vertex0 = v5;
  62. ground->CreateFixture(&shape, 0.0f);
  63. }
  64. {
  65. b2BodyDef bd;
  66. bd.type = b2_dynamicBody;
  67. bd.position.Set(-0.5f, 0.6f);
  68. bd.allowSleep = false;
  69. b2Body* body = m_world->CreateBody(&bd);
  70. b2CircleShape shape;
  71. shape.m_radius = 0.5f;
  72. body->CreateFixture(&shape, 1.0f);
  73. }
  74. {
  75. b2BodyDef bd;
  76. bd.type = b2_dynamicBody;
  77. bd.position.Set(1.0f, 0.6f);
  78. bd.allowSleep = false;
  79. b2Body* body = m_world->CreateBody(&bd);
  80. b2PolygonShape shape;
  81. shape.SetAsBox(0.5f, 0.5f);
  82. body->CreateFixture(&shape, 1.0f);
  83. }
  84. }
  85. static Test* Create()
  86. {
  87. return new EdgeTest;
  88. }
  89. };
  90. #endif