![]() |
Box2D Joint Toy
Game Physics with a 2D Physics Engine
|
Rack and pinion. More...
#include <RackAndPinion.h>


Public Member Functions | |
| CRackAndPinion () | |
| Constructor. | |
| ~CRackAndPinion () | |
| Destructor. | |
| void | Move () |
| Reverse the rack when it hits the limits. | |
| void | Action () |
| Reverse the motor. | |
Public Member Functions inherited from CLevel | |
| CLevel (eSprite) | |
| virtual | ~CLevel () |
| Default constructor. | |
| virtual void | Draw () |
| Draw objects in level. | |
Private Member Functions | |
| b2Body * | CreateRack (float, float) |
| Create a rack. | |
| b2Body * | CreatePinion (float, float) |
| Create a pinion. | |
| b2Body * | CreateBase (float, float) |
| Create an invisible gantry. | |
Additional Inherited Members | |
Protected Member Functions inherited from CLevel | |
| CLineObject * | CreateLine (b2Body *, const b2Vec2 &, bool, b2Body *, const b2Vec2 &, bool) |
| Create new line object. | |
Protected Attributes inherited from CLevel | |
| std::vector< CObject * > | m_stdObject |
| Object pointers. | |
| std::vector< CLineObject * > | m_stdLine |
| Line list. | |
| eSprite | m_eBgSprite |
| Type of background sprite. | |
Static Protected Attributes inherited from CCommon | |
| static b2World * | m_pPhysicsWorld = nullptr |
| Pointer to Box2D Physics World. | |
| static CBox2DRenderer * | m_pRenderer = nullptr |
| Pointer to the renderer. | |
| static CLevel * | m_pLevel = nullptr |
| Pointer to current level. | |
| static eLevel | m_eCurLevel = eLevel::Windmill |
| Current level. | |
| static eDrawMode | m_eDrawMode = eDrawMode::Sprites |
| Draw mode. | |
A rack and pinion connected by a prismatic joint in Physics World. A rack and pinion is a type of linear actuator that comprises a pair of gears which convert rotational motion into linear motion. A circular gear called the pinion engages teeth on a linear gear bar called the rack. Rotational motion applied to the pinion causes the rack to move relative to the pinion, thereby translating the rotational motion of the pinion into linear motion.
| CRackAndPinion::CRackAndPinion | ( | ) |
Create a rack and a pinion at a given position in Physics World, with a revolute joint for the pinion and a prismatic joint for the rack. The revolute joint has a motor.

|
virtual |
Reverse the pinion by setting the motor speed on the revolute joint.
Reimplemented from CLevel.
|
private |
Create an invisible base to attach the pinion 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 a pinion at a given position in Physics World.
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |


|
private |
Create a rack object at a given position in Physics World.
| x | X coordinate in Physics World units. |
| y | Y coordinate in Physics World units. |


|
virtual |
Monitor the pinion offset, and if it is p against the stops, then reverse the direction of the motor on the revolute joint.
Reimplemented from CLevel.
