2014-10-15 3 views
1

WebGL 장면의 행렬 계산에 어려움을 겪고 있습니다. 내가 시도한 어떤 것도 올바르게 표시되지 않는 것 같습니다.3D 세계 벡터를 모델보기 행렬로 변환

제 3D 세계에서 나는 많은 모델을 가지고 있습니다. 각 모델에는 세계에서 위치, 회전 및 크기 조정을위한 XYZ 벡터가 있습니다. 카메라에는 위치 및 회전 벡터가 있습니다.

이러한 벡터를 각 모델이 쉐이더로 전달할 모델 - 뷰 매트릭스로 변환하는 가장 좋은 (그리고 명백하게 작동하는) 방법은 무엇입니까?

미리 감사드립니다. :)

답변

0

보통 모델 뷰 매트릭스를 생성하기위한 전체 제조법과 같이 진행한다 :

1. Set up view matrix V (inverse of camera) from camera orientation vectors 
2. Set up model translation matrix T from model position vector 
3. Set up model rotation matrix R from model orientation vectors 
4. Set up model scaling matrix S 
5. MV = V  // initialize model-view matrix MV with the view matrix V 
6. MV = V*T  // apply the model translation matrix T 
7. MV = V*T*R // apply the model rotation matrix R 
8. MV = V*T*R*S // apply the model scaling matrix S