1 /* 2 * Copyright (c) 2011 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 DUMP_SHELL_H 20 #define DUMP_SHELL_H 21 22 // This test holds worlds dumped using b2World::Dump. 23 class DumpShell : public Test 24 { 25 public: 26 DumpShell()27 DumpShell() 28 { 29 30 b2Vec2 g(0.000000000000000e+00f, 0.000000000000000e+00f); 31 m_world->SetGravity(g); 32 b2Body** bodies = (b2Body**)b2Alloc(3 * sizeof(b2Body*)); 33 b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*)); 34 { 35 b2BodyDef bd; 36 bd.type = b2BodyType(2); 37 bd.position.Set(1.304347801208496e+01f, 2.500000000000000e+00f); 38 bd.angle = 0.000000000000000e+00f; 39 bd.linearVelocity.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 40 bd.angularVelocity = 0.000000000000000e+00f; 41 bd.linearDamping = 5.000000000000000e-01f; 42 bd.angularDamping = 5.000000000000000e-01f; 43 bd.allowSleep = bool(4); 44 bd.awake = bool(2); 45 bd.fixedRotation = bool(0); 46 bd.bullet = bool(0); 47 bd.active = bool(32); 48 bd.gravityScale = 1.000000000000000e+00f; 49 bodies[0] = m_world->CreateBody(&bd); 50 51 { 52 b2FixtureDef fd; 53 fd.friction = 1.000000000000000e+00f; 54 fd.restitution = 5.000000000000000e-01f; 55 fd.density = 1.000000000000000e+01f; 56 fd.isSensor = bool(0); 57 fd.filter.categoryBits = uint16(1); 58 fd.filter.maskBits = uint16(65535); 59 fd.filter.groupIndex = int16(0); 60 b2PolygonShape shape; 61 b2Vec2 vs[8]; 62 vs[0].Set(-6.900000095367432e+00f, -3.000000119209290e-01f); 63 vs[1].Set(2.000000029802322e-01f, -3.000000119209290e-01f); 64 vs[2].Set(2.000000029802322e-01f, 2.000000029802322e-01f); 65 vs[3].Set(-6.900000095367432e+00f, 2.000000029802322e-01f); 66 shape.Set(vs, 4); 67 68 fd.shape = &shape; 69 70 bodies[0]->CreateFixture(&fd); 71 } 72 } 73 { 74 b2BodyDef bd; 75 bd.type = b2BodyType(2); 76 bd.position.Set(8.478260636329651e-01f, 2.500000000000000e+00f); 77 bd.angle = 0.000000000000000e+00f; 78 bd.linearVelocity.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 79 bd.angularVelocity = 0.000000000000000e+00f; 80 bd.linearDamping = 5.000000000000000e-01f; 81 bd.angularDamping = 5.000000000000000e-01f; 82 bd.allowSleep = bool(4); 83 bd.awake = bool(2); 84 bd.fixedRotation = bool(0); 85 bd.bullet = bool(0); 86 bd.active = bool(32); 87 bd.gravityScale = 1.000000000000000e+00f; 88 bodies[1] = m_world->CreateBody(&bd); 89 90 { 91 b2FixtureDef fd; 92 fd.friction = 1.000000000000000e+00f; 93 fd.restitution = 5.000000000000000e-01f; 94 fd.density = 1.000000000000000e+01f; 95 fd.isSensor = bool(0); 96 fd.filter.categoryBits = uint16(1); 97 fd.filter.maskBits = uint16(65535); 98 fd.filter.groupIndex = int16(0); 99 b2PolygonShape shape; 100 b2Vec2 vs[8]; 101 vs[0].Set(-3.228000104427338e-01f, -2.957000136375427e-01f); 102 vs[1].Set(6.885900020599365e+00f, -3.641000092029572e-01f); 103 vs[2].Set(6.907599925994873e+00f, 3.271999955177307e-01f); 104 vs[3].Set(-3.228000104427338e-01f, 2.825999855995178e-01f); 105 shape.Set(vs, 4); 106 107 fd.shape = &shape; 108 109 bodies[1]->CreateFixture(&fd); 110 } 111 } 112 113 { 114 b2BodyDef bd; 115 bd.type = b2BodyType(0); 116 bd.position.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 117 bd.angle = 0.000000000000000e+00f; 118 bd.linearVelocity.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 119 bd.angularVelocity = 0.000000000000000e+00f; 120 bd.linearDamping = 0.000000000000000e+00f; 121 bd.angularDamping = 0.000000000000000e+00f; 122 bd.allowSleep = bool(4); 123 bd.awake = bool(2); 124 bd.fixedRotation = bool(0); 125 bd.bullet = bool(0); 126 bd.active = bool(32); 127 bd.gravityScale = 1.000000000000000e+00f; 128 bodies[2] = m_world->CreateBody(&bd); 129 130 { 131 b2FixtureDef fd; 132 fd.friction = 1.000000000000000e+01f; 133 fd.restitution = 0.000000000000000e+00f; 134 fd.density = 0.000000000000000e+00f; 135 fd.isSensor = bool(0); 136 fd.filter.categoryBits = uint16(1); 137 fd.filter.maskBits = uint16(65535); 138 fd.filter.groupIndex = int16(0); 139 b2EdgeShape shape; 140 shape.m_radius = 9.999999776482582e-03f; 141 shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 142 shape.m_vertex1.Set(4.452173995971680e+01f, 1.669565200805664e+01f); 143 shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f); 144 shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 145 shape.m_hasVertex0 = bool(0); 146 shape.m_hasVertex3 = bool(0); 147 148 fd.shape = &shape; 149 150 bodies[2]->CreateFixture(&fd); 151 } 152 { 153 b2FixtureDef fd; 154 fd.friction = 1.000000000000000e+01f; 155 fd.restitution = 0.000000000000000e+00f; 156 fd.density = 0.000000000000000e+00f; 157 fd.isSensor = bool(0); 158 fd.filter.categoryBits = uint16(1); 159 fd.filter.maskBits = uint16(65535); 160 fd.filter.groupIndex = int16(0); 161 b2EdgeShape shape; 162 shape.m_radius = 9.999999776482582e-03f; 163 shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 164 shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f); 165 shape.m_vertex2.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 166 shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 167 shape.m_hasVertex0 = bool(0); 168 shape.m_hasVertex3 = bool(0); 169 170 fd.shape = &shape; 171 172 bodies[2]->CreateFixture(&fd); 173 } 174 { 175 b2FixtureDef fd; 176 fd.friction = 1.000000000000000e+01f; 177 fd.restitution = 0.000000000000000e+00f; 178 fd.density = 0.000000000000000e+00f; 179 fd.isSensor = bool(0); 180 fd.filter.categoryBits = uint16(1); 181 fd.filter.maskBits = uint16(65535); 182 fd.filter.groupIndex = int16(0); 183 b2EdgeShape shape; 184 shape.m_radius = 9.999999776482582e-03f; 185 shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 186 shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f); 187 shape.m_vertex2.Set(4.452173995971680e+01f, 1.669565200805664e+01f); 188 shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 189 shape.m_hasVertex0 = bool(0); 190 shape.m_hasVertex3 = bool(0); 191 192 fd.shape = &shape; 193 194 bodies[2]->CreateFixture(&fd); 195 } 196 { 197 b2FixtureDef fd; 198 fd.friction = 1.000000000000000e+01f; 199 fd.restitution = 0.000000000000000e+00f; 200 fd.density = 0.000000000000000e+00f; 201 fd.isSensor = bool(0); 202 fd.filter.categoryBits = uint16(1); 203 fd.filter.maskBits = uint16(65535); 204 fd.filter.groupIndex = int16(0); 205 b2EdgeShape shape; 206 shape.m_radius = 9.999999776482582e-03f; 207 shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 208 shape.m_vertex1.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 209 shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f); 210 shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 211 shape.m_hasVertex0 = bool(0); 212 shape.m_hasVertex3 = bool(0); 213 214 fd.shape = &shape; 215 216 bodies[2]->CreateFixture(&fd); 217 } 218 } 219 220 { 221 b2PrismaticJointDef jd; 222 jd.bodyA = bodies[1]; 223 jd.bodyB = bodies[0]; 224 jd.collideConnected = bool(0); 225 jd.localAnchorA.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 226 jd.localAnchorB.Set(-1.219565200805664e+01f, 0.000000000000000e+00f); 227 jd.localAxisA.Set(-1.219565200805664e+01f, 0.000000000000000e+00f); 228 jd.referenceAngle = 0.000000000000000e+00f; 229 jd.enableLimit = bool(1); 230 jd.lowerTranslation = -2.000000000000000e+01f; 231 jd.upperTranslation = 0.000000000000000e+00f; 232 jd.enableMotor = bool(1); 233 jd.motorSpeed = 0.000000000000000e+00f; 234 jd.maxMotorForce = 1.000000000000000e+01f; 235 joints[0] = m_world->CreateJoint(&jd); 236 } 237 { 238 b2RevoluteJointDef jd; 239 jd.bodyA = bodies[1]; 240 jd.bodyB = bodies[2]; 241 jd.collideConnected = bool(0); 242 jd.localAnchorA.Set(0.000000000000000e+00f, 0.000000000000000e+00f); 243 jd.localAnchorB.Set(8.478260636329651e-01f, 2.500000000000000e+00f); 244 jd.referenceAngle = 0.000000000000000e+00f; 245 jd.enableLimit = bool(0); 246 jd.lowerAngle = 0.000000000000000e+00f; 247 jd.upperAngle = 0.000000000000000e+00f; 248 jd.enableMotor = bool(0); 249 jd.motorSpeed = 0.000000000000000e+00f; 250 jd.maxMotorTorque = 0.000000000000000e+00f; 251 joints[1] = m_world->CreateJoint(&jd); 252 } 253 b2Free(joints); 254 b2Free(bodies); 255 joints = NULL; 256 bodies = NULL; 257 258 259 } 260 Create()261 static Test* Create() 262 { 263 return new DumpShell; 264 } 265 }; 266 267 #endif 268