2
* Copyright (c) 2008-2009 Erin Catto http://www.box2d.org
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.
19
#ifndef SHAPE_EDITING_H
20
#define SHAPE_EDITING_H
22
class ShapeEditing : public Test
30
b2Body* ground = m_world->CreateBody(&bd);
33
shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
34
ground->CreateFixture(&shape, 0.0f);
38
bd.type = b2_dynamicBody;
39
bd.position.Set(0.0f, 10.0f);
40
m_body = m_world->CreateBody(&bd);
43
shape.SetAsBox(4.0f, 4.0f, b2Vec2(0.0f, 0.0f), 0.0f);
44
m_fixture1 = m_body->CreateFixture(&shape, 10.0f);
51
void Keyboard(unsigned char key)
56
if (m_fixture2 == NULL)
59
shape.m_radius = 3.0f;
60
shape.m_p.Set(0.5f, -4.0f);
61
m_fixture2 = m_body->CreateFixture(&shape, 10.0f);
62
m_body->SetAwake(true);
67
if (m_fixture2 != NULL)
69
m_body->DestroyFixture(m_fixture2);
71
m_body->SetAwake(true);
76
if (m_fixture2 != NULL)
79
m_fixture2->SetSensor(m_sensor);
85
void Step(Settings* settings)
88
m_debugDraw.DrawString(5, m_textLine, "Press: (c) create a shape, (d) destroy a shape.");
90
m_debugDraw.DrawString(5, m_textLine, "sensor = %d", m_sensor);
96
return new ShapeEditing;
100
b2Fixture* m_fixture1;
101
b2Fixture* m_fixture2;