Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Types | Public Member Functions | List of all members
jop::WheelJoint Class Reference

#include <WheelJoint.hpp>

Inheritance diagram for jop::WheelJoint:
jop::Joint

Public Types

enum  Axis {
  Axis::T_X, Axis::T_Y, Axis::T_Z, Axis::R_X,
  Axis::R_Y, Axis::R_Z
}
 

Public Member Functions

 WheelJoint (World &worldRef, RigidBody &bodyA, RigidBody &bodyB, const bool collide, const float maxSteering=0.7f, const glm::quat &jRot=glm::quat(0.f, 0.f, 0.f, 0.f), const glm::vec3 &anchor=glm::vec3(0.f, 0.f, FLT_MAX))
 WheelJoint constructor. More...
 
float getAngle (const Axis axis=Axis::T_Y) const
 
float getStiffness (const Axis axis=Axis::T_Y)
 
WheelJointsetAngle (const float steeringAngle, const Axis axis=Axis::T_Y)
 Set new angle for the joint in an axis. More...
 
WheelJointsetStiffness (const float stiffness, const Axis axis=Axis::T_Y)
 
- Public Member Functions inherited from jop::Joint
 Joint (World &worldRef, RigidBody &bodyA, RigidBody &bodyB, const bool collide)
 Joint constructor. More...
 
virtual ~Joint ()=0
 
unsigned int getID () const
 Get joint ID. More...
 
JointsetID (const unsigned int id)
 Set new ID for the joint. More...
 

Additional Inherited Members

- Public Attributes inherited from jop::Joint
Worldm_worldRef
 Pointer to the world. More...
 
RigidBodym_bodyA
 Pointer to bodyA. More...
 
RigidBodym_bodyB
 Pointer to bodyB. More...
 
- Protected Member Functions inherited from jop::Joint
btRigidBody * getBody (RigidBody &body) const
 Return engine internal pointer to body. More...
 
btDiscreteDynamicsWorld & getWorld (World &world) const
 Return engine internal pointer to world. More...
 
glm::vec3 defaultCenter (const glm::vec3 &jPos) const
 
glm::vec3 computeCenter () const
 Calculates the point in the middle between this' m_bodies. More...
 
- Protected Attributes inherited from jop::Joint
bool m_collide
 
std::unique_ptr< btTypedConstraint > m_joint
 < Should the linked bodies collide. More...
 
unsigned int m_ID
 Joint ID. More...
 

Detailed Description

Definition at line 37 of file WheelJoint.hpp.

Member Enumeration Documentation

enum jop::WheelJoint::Axis
strong

T_ : Translation R_ : Rotation

Enumerator
T_X 
T_Y 
T_Z 
R_X 
R_Y 
R_Z 

Definition at line 44 of file WheelJoint.hpp.

Constructor & Destructor Documentation

jop::WheelJoint::WheelJoint ( World worldRef,
RigidBody bodyA,
RigidBody bodyB,
const bool  collide,
const float  maxSteering = 0.7f,
const glm::quat &  jRot = glm::quat(0.f, 0.f, 0.f, 0.f),
const glm::vec3 &  anchor = glm::vec3(0.f, 0.f, FLT_MAX) 
)

WheelJoint constructor.

When creating WheelJoints, always call the link from the chassis and pass the wheel in as the first argument.

Note
When creating a vehicle, it is best to create it in the following manner: The vehicle is parallel to global Z-axis (by length). The vehicle wheels are then +/- of the chassis in X-axis.
Parameters
maxSteeringMaximum steering angle of the wheel in radians. Function setAngle can not override this. Same value is set for both +/- rotations. Default is 0.7f ~ 40 degrees.
jRotRotation of the joint in a quaternion. By default aligns the wheel by X- or Z-axis, depending on the global positions of the wheel and chassis.
anchorPosition of the joint in world coordinates. Default is in the middle of the wheel.

Member Function Documentation

float jop::WheelJoint::getAngle ( const Axis  axis = Axis::T_Y) const
Returns
Returns angle of the joint in an axis in radians. Default Y-axis.
float jop::WheelJoint::getStiffness ( const Axis  axis = Axis::T_Y)
Returns
Returns currently used stiffness in desired axis. Default Y-axis.
WheelJoint& jop::WheelJoint::setAngle ( const float  steeringAngle,
const Axis  axis = Axis::T_Y 
)

Set new angle for the joint in an axis.

This can not override the maxSteering of the joint.

Parameters
steeringAngleNew steering angle to be set to the wheel. Negative value turns the wheel in the other direction.
axisAxis to change. Default Y-axis.
Returns
Returns reference to self.
WheelJoint& jop::WheelJoint::setStiffness ( const float  stiffness,
const Axis  axis = Axis::T_Y 
)

Set spring stiffness.

Parameters
stiffnessNew stiffness to apply. Please use values between 0.f - 1.f.
axisAxis to apply the stiffness to. Default Y.
Returns
Returns reference to self.

The documentation for this class was generated from the following file: