Вот соответствующая часть моего кода:
Код: Выделить всё
GLfloat deg = 0;
GLfloat xWheel = 0, yWheel = -1.2, zWheel = 2;
GLfloat wheelColor[3] = { 0, 0, 0 };
// Function to rotate the wheel to the left
static void rotateWheelLeft() {
if (deg > -45) {
deg -= 2.0f;
}
}
// Function to rotate the wheel to the right
static void rotateWheelRight() {
if (deg < 45) {
deg += 2.0f;
}
}
// Function to move the wheel forward based on its rotation angle
static void moveForward() {
GLfloat radianAngle = deg * 3.14 / 180;
GLfloat forwardX = 0.1f * cos(radianAngle);
GLfloat forwardZ = 0.1f * sin(radianAngle);
xWheel -= forwardX;
zWheel += forwardZ;
}
Колесо движется вперед по прямой линии в зависимости от угла поворота, когда я вызываю moveForward().
Я могу вращать колесо влево и вправо используя функции RotateWheelLeft() и RotateWheelRight().
Желаемое поведение:
Я хочу, чтобы колесо двигалось по круговой траектории, сохраняя при этом угол поворота.
колесо должно двигаться по круговой траектории, а не по прямой.
Подробнее здесь: https://stackoverflow.com/questions/785 ... e-in-openg