@@ -103,12 +103,30 @@ void Camera::SetFOV(double _fov)
103103
104104Eigen::Vector3d Camera::GetPosition () const 
105105{
106- 	const  Eigen::Matrix3d r (rotation.toRotationMatrix ());
106+ 	const  Eigen::Matrix3d R (rotation.toRotationMatrix ());
107107	const  Eigen::Vector3d eye (0 , 0 , dist);
108- 	return  r  * eye + center;
108+ 	return  R  * eye + center;
109109}
110110
111- void  Camera::GetLookAt (Eigen::Vector3d& _eye, Eigen::Vector3d& _center, Eigen::Vector3d& _up)
111+ Eigen::Matrix4d Camera::GetLookAt () const 
112+ {
113+ 	const  Eigen::Matrix3d R (rotation.toRotationMatrix ());
114+ 	const  Eigen::Vector3d eye (R.col (2 ) * dist + center);
115+ 	const  Eigen::Vector3d up (R.col (1 ));
116+ 	
117+ 	const  Eigen::Vector3d n ((center-eye).normalized ());
118+ 	const  Eigen::Vector3d s (n.cross (up));
119+ 	const  Eigen::Vector3d v (s.cross (n));
120+ 	
121+ 	Eigen::Matrix4d m;
122+ 	m <<
123+ 	s (0 ),  s (1 ),  s (2 ), -eye.dot (s),
124+ 	v (0 ),  v (1 ),  v (2 ), -eye.dot (v),
125+ 	-n (0 ), -n (1 ), -n (2 ),  eye.dot (n),
126+ 	0.0 , 0.0 , 0.0 , 1.0 ;
127+ 	return  m;
128+ }
129+ void  Camera::GetLookAt (Eigen::Vector3d& _eye, Eigen::Vector3d& _center, Eigen::Vector3d& _up) const 
112130{
113131	const  Eigen::Matrix3d R (rotation.toRotationMatrix ());
114132	const  Eigen::Vector3d eye (0 , 0 , dist);
0 commit comments