Question

As the title says, how do you rotate the plane but not the object. I'd like the car I have in my program to accelerate in the x direction when I turn. So I'd like to turn the plane. That way I can press forward and go in the direction the car is pointing after I rotate the car.

XMMATRIX carTranslation = XMMatrixTranslation(mCarTranslation.x, mCarTranslation.y, mCarTranslation.z);
XMMATRIX carScale = XMMatrixScaling(0.5f, 0.5f, 0.5f);
XMMATRIX carRotate = XMMatrixRotationY(carRotation.y);
XMStoreFloat4x4(&mCarWorld, carRotate*carTranslation*carScale);

I know that if you put the carRotate before everything else it rotates just the car. And if I put it after it rotates just the plane. I'd like to rotate the plane and not the object.

Was it helpful?

Solution

I ended up using cosine and sine to find a slope velocity. I didn't make another matrix and I just rotated the car normally.

mCarTranslation.x += (cos(carRotation.y)*v);
mCarTranslation.z += -(sin(carRotation.y)*v);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top