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 19 #ifndef EDGE_TEST_H 20 #define EDGE_TEST_H 21 22 class EdgeTest : public Test 23 { 24 public: 25 EdgeTest()26 EdgeTest() 27 { 28 { 29 b2BodyDef bd; 30 b2Body* ground = m_world->CreateBody(&bd); 31 32 b2Vec2 v1(-10.0f, 0.0f), v2(-7.0f, -2.0f), v3(-4.0f, 0.0f); 33 b2Vec2 v4(0.0f, 0.0f), v5(4.0f, 0.0f), v6(7.0f, 2.0f), v7(10.0f, 0.0f); 34 35 b2EdgeShape shape; 36 37 shape.Set(v1, v2); 38 shape.m_hasVertex3 = true; 39 shape.m_vertex3 = v3; 40 ground->CreateFixture(&shape, 0.0f); 41 42 shape.Set(v2, v3); 43 shape.m_hasVertex0 = true; 44 shape.m_hasVertex3 = true; 45 shape.m_vertex0 = v1; 46 shape.m_vertex3 = v4; 47 ground->CreateFixture(&shape, 0.0f); 48 49 shape.Set(v3, v4); 50 shape.m_hasVertex0 = true; 51 shape.m_hasVertex3 = true; 52 shape.m_vertex0 = v2; 53 shape.m_vertex3 = v5; 54 ground->CreateFixture(&shape, 0.0f); 55 56 shape.Set(v4, v5); 57 shape.m_hasVertex0 = true; 58 shape.m_hasVertex3 = true; 59 shape.m_vertex0 = v3; 60 shape.m_vertex3 = v6; 61 ground->CreateFixture(&shape, 0.0f); 62 63 shape.Set(v5, v6); 64 shape.m_hasVertex0 = true; 65 shape.m_hasVertex3 = true; 66 shape.m_vertex0 = v4; 67 shape.m_vertex3 = v7; 68 ground->CreateFixture(&shape, 0.0f); 69 70 shape.Set(v6, v7); 71 shape.m_hasVertex0 = true; 72 shape.m_vertex0 = v5; 73 ground->CreateFixture(&shape, 0.0f); 74 } 75 76 { 77 b2BodyDef bd; 78 bd.type = b2_dynamicBody; 79 bd.position.Set(-0.5f, 0.6f); 80 bd.allowSleep = false; 81 b2Body* body = m_world->CreateBody(&bd); 82 83 b2CircleShape shape; 84 shape.m_radius = 0.5f; 85 86 body->CreateFixture(&shape, 1.0f); 87 } 88 89 { 90 b2BodyDef bd; 91 bd.type = b2_dynamicBody; 92 bd.position.Set(1.0f, 0.6f); 93 bd.allowSleep = false; 94 b2Body* body = m_world->CreateBody(&bd); 95 96 b2PolygonShape shape; 97 shape.SetAsBox(0.5f, 0.5f); 98 99 body->CreateFixture(&shape, 1.0f); 100 } 101 } 102 Create()103 static Test* Create() 104 { 105 return new EdgeTest; 106 } 107 }; 108 109 #endif 110