Esempio n. 1
0
CameraOffAxis::CameraOffAxis(glm::dvec3 topLeft, glm::dvec3 topRight, glm::dvec3 botLeft, glm::dvec3 botRight,
	glm::dmat4 initialHeadFrame, double interOcularDistance, 
	double nearClipDist, double farClipDist, bool isCoreProfile) : AbstractCamera(), _isCoreProfile(isCoreProfile)
{
	_topLeft = topLeft;
	_topRight = topRight;
	_botLeft = botLeft;
	_botRight = botRight;
	_headFrame = initialHeadFrame;
	_iod = interOcularDistance;
	_nearClip = nearClipDist;
	_farClip = farClipDist;
	_halfWidth = glm::length(_topRight - _topLeft) / 2.0;
	_halfHeight = glm::length(_topRight - _botRight) / 2.0;

	glm::dvec3 center = (topLeft + topRight + botLeft + botRight);
	center.x = center.x / 4.0;
	center.y = center.y / 4.0;
	center.z = center.z / 4.0;
	glm::dvec3 x = glm::normalize(topRight - topLeft);
	glm::dvec3 y = glm::normalize(topLeft - botLeft);
	glm::dvec3 z = glm::normalize(glm::cross(x, y));
	glm::dmat4 tile2room(x.x, x.y, x.z, 0,
						y.x, y.y, y.z, 0,
						z.x, z.y, z.z, 0,
						center.x, center.y, center.z, 1);
	//glm::mat4 tile2room(x.x, y.x, z.x, center.x,
	//					x.y, y.y, z.y, center.y,
	//					x.z, y.z, z.z, center.z,
	//					0.0, 0.0, 0.0, 1);
	_room2tile = glm::inverse(tile2room);
}
Esempio n. 2
0
void
DisplayTile::calculateRoomToTile()
{
  Vector3 center = (topLeft + topRight + botLeft + botRight) / 4.0;
  Vector3 x = (topRight - topLeft).unit();
  Vector3 y = (topLeft - botLeft).unit();
  Vector3 z = x.cross(y).unit();
  Matrix3 rot(x[0],y[0],z[0],x[1],y[1],z[1],x[2],y[2],z[2]);
  CoordinateFrame tile2room(rot, center);
  room2tile = tile2room.inverse();
}