마우스 Press 함수
1 2 3 4 5 6 7 8 9 10 11 12 13 | POINT curCursorPos; GetCursorPos(&curCursorPos); float dx = math::ConvertToRadians(static_cast<float>(curCursorPos.x - m_pPlayer->preCursorPos.x)); float dy = math::ConvertToRadians(static_cast<float>(curCursorPos.y - m_pPlayer->preCursorPos.y)); math::Vec3 left = m_pPlayer->m_pComponent_Transform->Left; // { -1, 0, 0 } m_pPlayer->m_pComponent_Transform->Rotate(left, dy); math::Vec3 down = m_pPlayer->m_pComponent_Transform->Down; // { 0, -1, 0 } m_pPlayer->m_pComponent_Transform->Rotate(down, dx); m_pPlayer->preCursorPos = curCursorPos; | cs |
질문 쓰다가 나도 뭐라고 써야할지 몰라서 좆같다...
내가 이걸 왜 하고있지.
수정)
Rotate함수인데, Rotate 함수 자체에는 문제 없어보임?? Rotation은 쿼터니언임. 축, 각 입력받아서 쿼터니언 만들고, 현재 값에 만들어진 쿼터니언 더해주는거임.
위 코드에서 Rotate하는 함수가 2개인데, 하나 주석처리하면 문제 안생기는 것 같아서...
뭔가 x랑 y를 둘 다 처리하니까 이상하게 움직이는 것 같음...
그래서 일단 내가 사용하고있는 Rotate가 논리적으로 문제가 있는지 알고싶음.
1 2 3 4 5 | void Rotate(const math::Vec3& axis, const float& radian) { math::Quaternion addQuat = math::QuaternionAngleAxis(axis, radian); Rotation = addQuat * Rotation; } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 | math::Quaternion math::QuaternionAngleAxis(const math::Vec3& axis, const float& angle) { math::Quaternion quat; const float s = std::sin(angle * 0.5f); quat.w = std::cos(angle * 0.5f); quat.x = axis.x * s; quat.y = axis.y * s; quat.z = axis.z * s; return quat; } | cs |
이건 worldViewProj 구하는 부분인데 혹시 곱셈 순서 맞는지 봐줄 수 있음?
1 2 3 4 5 6 7 8 | math::Matrix world = math::MatrixIdentity(); math::Matrix translation = math::Translation(*m_Context.Translation); math::Matrix rotation = math::MatrixFromQuaternion(*m_Context.Rotation); math::Matrix scale = math::Scale(*m_Context.Scale); world = scale * rotation * translation; math::Matrix worldViewProj = world * viewMatrix * projMatrix; worldViewProj = math::Transpose(worldViewProj); | cs |
메트릭 보존 안되는것 같은데 회전 행렬 잘못 만들었나보지
앞으로 당길 땐 멀쩡한 거 같은데 뒤로 당길 때 이상해지네
오늘 너무 피곤해서 내일 다시 확인하고 정리해서 질문 올리겠음. 다들 감사요....
노말리제이션
ㄳㄳ 찾아보니까 방향은 단위 쿼터니언이네요. 그런데 문제는 해결 안됨... 그래도 감사요
Code block 이쁘네용 어떤 거 쓰신 거예요??
https://colorscripter.com/
디씨에 올릴땐 html복사 후 글쓸때 html 체크하고 복붙. 그리고 html 체크 풀기
오 감사합니다!
넹