2
* Copyright (c) 2011 Erin Catto http://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.
23
class Rope : public Test
32
for (int32 i = 0; i < N; ++i)
34
vertices[i].Set(0.0f, 20.0f - 0.25f * i);
41
def.vertices = vertices;
43
def.gravity.Set(0.0f, -10.0f);
49
m_rope.Initialize(&def);
52
m_rope.SetAngle(m_angle);
55
void Keyboard(unsigned char key)
60
m_angle = b2Max(-b2_pi, m_angle - 0.05f * b2_pi);
61
m_rope.SetAngle(m_angle);
65
m_angle = b2Min(b2_pi, m_angle + 0.05f * b2_pi);
66
m_rope.SetAngle(m_angle);
71
void Step(Settings* settings)
73
float32 dt = settings->hz > 0.0f ? 1.0f / settings->hz : 0.0f;
75
if (settings->pause == 1 && settings->singleStep == 0)
84
m_rope.Draw(&m_debugDraw);
86
m_debugDraw.DrawString(5, m_textLine, "Press (q,e) to adjust target angle");
88
m_debugDraw.DrawString(5, m_textLine, "Target angle = %g degrees", m_angle * 180.0f / b2_pi);