2
* Copyright (c) 2007-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.
22
class Pulleys : public Test
32
b2Body* ground = NULL;
35
ground = m_world->CreateBody(&bd);
38
edge.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
39
//ground->CreateFixture(&shape, 0.0f);
42
circle.m_radius = 2.0f;
44
circle.m_p.Set(-10.0f, y + b + L);
45
ground->CreateFixture(&circle, 0.0f);
47
circle.m_p.Set(10.0f, y + b + L);
48
ground->CreateFixture(&circle, 0.0f);
57
bd.type = b2_dynamicBody;
59
//bd.fixedRotation = true;
60
bd.position.Set(-10.0f, y);
61
b2Body* body1 = m_world->CreateBody(&bd);
62
body1->CreateFixture(&shape, 5.0f);
64
bd.position.Set(10.0f, y);
65
b2Body* body2 = m_world->CreateBody(&bd);
66
body2->CreateFixture(&shape, 5.0f);
68
b2PulleyJointDef pulleyDef;
69
b2Vec2 anchor1(-10.0f, y + b);
70
b2Vec2 anchor2(10.0f, y + b);
71
b2Vec2 groundAnchor1(-10.0f, y + b + L);
72
b2Vec2 groundAnchor2(10.0f, y + b + L);
73
pulleyDef.Initialize(body1, body2, groundAnchor1, groundAnchor2, anchor1, anchor2, 1.5f);
75
m_joint1 = (b2PulleyJoint*)m_world->CreateJoint(&pulleyDef);
79
void Keyboard(unsigned char key)
88
void Step(Settings* settings)
92
float32 ratio = m_joint1->GetRatio();
93
float32 L = m_joint1->GetLengthA() + ratio * m_joint1->GetLengthB();
94
m_debugDraw.DrawString(5, m_textLine, "L1 + %4.2f * L2 = %4.2f", (float) ratio, (float) L);
103
b2PulleyJoint* m_joint1;