![]() |
Box2D Joint Toy
Ian Parberry's "Introduction to Game Physics"
|
A system of interlocking gears. More...
#include <Gear.h>
Public Member Functions | |
CGear (float, float) | |
Constructor. More... | |
void | reverse () |
Reverse gears. More... | |
Private Member Functions | |
b2Body * | CreateBase (float, float) |
Create invisible base in Physics World. More... | |
void | CreateRoundGears (float, float) |
Create round gears in Physics World. More... | |
void | CreateSquareGears (float, float) |
Create square gears in Physics World. More... | |
b2Body * | CreateGear (float, float, eSprite) |
Create gear wheel in Physics World. More... | |
void | CreateGearJoint (UINT, UINT, float) |
Create gear joint in Physics World. More... | |
Private Attributes | |
std::vector< b2Body * > | m_stdGear |
Gear body pointers. | |
std::vector< b2RevoluteJoint * > | m_stdJoint |
Revolute joint pointers. | |
Additional Inherited Members | |
![]() | |
static b2World * | m_pPhysicsWorld = nullptr |
Pointer to Box2D Physics World. | |
static CRenderer * | m_pRenderer = nullptr |
Pointer to the renderer. | |
static CObjectManager * | m_pObjectManager = nullptr |
Pointer to the object manager. | |
static CWindmill * | m_pWindmill = nullptr |
Pointer to windmill. | |
static CGear * | m_pGear = nullptr |
Pointer to gear system. | |
static CNautilusGear * | m_pNautilusGear = nullptr |
Pointer to Nautilus gear system. | |
static CRackAndPinion * | m_pRackAndPinion = nullptr |
Pointer to rack-and-pinion. | |
static CCar * | m_pCar = nullptr |
Pointer to car. | |
static CRamp * | m_pRamp = nullptr |
Pointer to ramp. | |
static CNewtonsCradle * | m_pNewtonsCradle = nullptr |
Pointer to Newton's Cradle. | |
static CPulley * | m_pPulley = nullptr |
Pointer to pulley system. | |
static eLevel | m_eCurLevel = eLevel::Windmill |
Current level. | |
A system of interlocking gears.
The number and positions of the gears are hard-coded but there is enough storage for any number of them.
CGear::CGear | ( | float | x, |
float | y | ||
) |
Constructor.
x | X coordinate in Physics World units. |
y | Y coordinate in Physics World units. |
|
private |
Create invisible base in Physics World.
Create an invisible base to attach the largest gear wheel to. The base has no sprite and no shape in Physics World. The latter means it doesn't collide with anything.
x | X coordinate in Physics World units. |
y | Y coordinate in Physics World units. |
|
private |
Create gear wheel in Physics World.
Create a gear wheel at a given position in Physics World.
x | X coordinate in Physics World units. |
y | Y coordinate in Physics World units. |
t | Sprite type of the gear wheel. |
|
private |
Create gear joint in Physics World.
Create a gear joint between two of hthe revolute joints in m_pJoint.
i | Index of first revolute joint and body attached to it. |
j | Index of second revolute joint and body attached to it. |
r | Gear ratio. |
|
private |
Create round gears in Physics World.
Create the square gears and push them onto the gear list. It is assumed that this function is called first and that the driving gear (the one with the motor on its revolute joint) is to be the first one on the gear list.
x | X coordinate in Physics World units. |
y | Y coordinate in Physics World units. |
|
private |
Create square gears in Physics World.
Create the square gears and push them onto the gear list.
x | X coordinate in Physics World units. |
y | Y coordinate in Physics World units. |
void CGear::reverse | ( | ) |
Reverse gears.
Reverse the gears by setting the motor speed on the revolute joint for the first gear.