I've been looking around the forums for some answers to the question I have. I've found some answer that seem to help but nothing that answers my specific question. That question being how to rotate an object in world space around a non origin point.
I have a grappling hook that I am trying to implement inside of a game I am making for a final college project. This grappling hook collides with another object in world space and I then want the player to rotate around this point as if a rope were present.
I have the point at which the grapple collides the point at which the player is located and the origin. I tried the standard translate to the origin rotate and translate back and that did not work.
This is being done in DirectX 9 and it is a C++ game. Any help you could offer would be greatly appreciated. If you need anymore info please ask.
Edit: I should also add that we are doing a vector based storage for this setup. So I store the matrices in vectors(i.e Forward,Direction,Right,Position) and build the matrices on the fly
void CSpatialFrame::RotateAbout(D3DXVECTOR3 _Point, float _fDegPitch, float _fDegYaw, float _fDegRoll)
{
D3DXMATRIX RotationMatrix;
D3DXMatrixRotationYawPitchRoll(&RotationMatrix, D3DXToRadian( _fDegYaw ), D3DXToRadian( _fDegPitch ), D3DXToRadian( _fDegRoll ));
D3DXVECTOR3 playerPos = m_Position;
m_Position = _Point;
D3DXMATRIX PlayerMatrix;
PlayerMatrix._11 = m_RightVector.x;
PlayerMatrix._21 = m_RightVector.y;
PlayerMatrix._31 = m_RightVector.z;
PlayerMatrix._12 = m_UpVector.x;
PlayerMatrix._22 = m_UpVector.y;
PlayerMatrix._32 = m_UpVector.z;
PlayerMatrix._13 = m_DirectionVector.x;
PlayerMatrix._23 = m_DirectionVector.y;
PlayerMatrix._33 = m_DirectionVector.z;
PlayerMatrix._14 = m_Position.x;
PlayerMatrix._24 = m_Position.y;
PlayerMatrix._34 = m_Position.z;
D3DXMatrixTranslation(&PlayerMatrix, _Point.x, _Point.y, _Point.z);
//D3DXMatrixTranslation(&PlayerMatrix, m_Position.x, m_Position.y, m_Position.z);
D3DXMatrixMultiply(&PlayerMatrix, &RotationMatrix, &PlayerMatrix);
//D3DXMatrixTranslation(&PlayerMatrix, _Point.x, _Point.y, _Point.z);
m_RightVector.x = PlayerMatrix._11;
m_RightVector.y = PlayerMatrix._21;
m_RightVector.z = PlayerMatrix._31;
m_UpVector.x = PlayerMatrix._12;
m_UpVector.y = PlayerMatrix._22;
m_UpVector.z = PlayerMatrix._32;
m_DirectionVector.x = PlayerMatrix._13;
m_DirectionVector.y = PlayerMatrix._23;
m_DirectionVector.z = PlayerMatrix._33;
m_Position.x = PlayerMatrix._14;
m_Position.x = PlayerMatrix._24;
m_Position.x = PlayerMatrix._34;
}