나는 다음과 같이 첫 번째 사람이 카메라 컨트롤러가 구현 :방향에서 XY 오일러 각을 얻으려면 어떻게해야합니까?
float rotSpeed = 20.0f;
xRotation += deltaPos.y * rotSpeed * Time.deltaTime;
yRotation += deltaPos.x * -rotSpeed * Time.deltaTime;
while(xRotation > 360.0f) xRotation -= 360.0f;
while(xRotation < 0.0f) xRotation += 360.0f;
while(yRotation > 360.0f) yRotation -= 360.0f;
while(yRotation < 0.0f) yRotation += 360.0f;
cam.transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
내가 카메라가 3D 공간에서 어떤 대상에 스냅 할 수 있도록하고 싶습니다.
transform.LookAt (target)을 사용하면 카메라 컨트롤러는 LookAt() 호출 후 카메라 회전에서 xRotation 및 yRotation을 설정할 수 없습니다. 왜냐하면 LookAt()가 때때로 Z 로테이션을 가진 쿼터니온을 생성하기 때문입니다.
그렇다면 카메라를 어떤 대상으로 향하게하는 데 필요한 X 및 Y 회전을 어떻게 찾을 수 있습니까?
몇 년 전에 각도 변환을위한 몇 가지 C# 클래스를 작성했습니다. Spherical 좌표, 롤/피치/요, 장방형/세차/회전 또는 임의의 오일러 각 사이의 변환을 수행 할 수 있습니다. 내가 그것을 찾을 수 있는지 알게 될 것이다. 이 페이지는 매우 도움이되었습니다. http://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Conversion_formulae_between_formalisms –