示例#1
0
 vec3 camera_t::screen_to_world_coord(vec2 const& screen_coord) const
 {
     vec4 vp;
     vp.xy = viewport.bottom_left;
     vp.zw = viewport.size_d2 * 2.0f;
     return unProject(vec3(screen_coord, 0.0f), view_matrix(), projection_ortho(), vp).xyz;
 }
示例#2
0
void Camera::projection_oblique(PV3D* d){
	projection_ortho();
	if ((d->z > EPSILON || d->z < -EPSILON) && //|d->z| > 0
		 !(
			d->x < EPSILON && d->x > -EPSILON &&
			d->y < EPSILON && d->y > -EPSILON &&
			d->z < 1-EPSILON && d->z > 1-EPSILON
		 )//d != new PV3D(0,0,1))
		){
		GLdouble m[16];

		m[0] = 1; m[4] = 0;	m[8] = -d->x/d->z; m[12] = -vv_near*d->x/d->z;
		m[1] = 0; m[5] = 1;	m[9] = -d->y/d->z; m[13] = -vv_near*d->y/d->z;
		m[2] = 0; m[6] = 0;	m[10] = 1; m[14] = 0;
		m[3] = 0; m[7] = 0; m[11] = 0; m[15] = 1;

		glMultMatrixd(m);
	}
}
示例#3
0
 glm::mat4 camera_t::projection_ortho() const
 {
     return projection_ortho(viewport.size_d2 / zoom());
 }