Пример #1
0
/**
 * Setup this camera such that it looks at the specified point with the specified view direction, up direction, and the distance from the point.
 *
 * @param p		the target point that this camera will look at
 * @param vd	the view direction
 * @param up	the up direction
 * @param d		the distance between the center of this camera and the target
 */
void PPC::LookAt(const V3 &p, const V3 &vd, const V3 &up, float d) {
	float f = GetFocalLength();

	C = p - vd.UnitVector() * d;
	a = (vd ^ up).UnitVector() * a.Length();
	b = (vd ^ a).UnitVector() * b.Length();
	c = vd.UnitVector() * f - a * ((float)w / 2.0f) - b * ((float)h / 2.0f);

	SetPMat();
}
Пример #2
0
/**
 * Setup this camera according to the specified center, vector a, and the view direction.
 *
 * @param C		the center of the camera
 * @param a		the vector a (The horizontal direction of the screen)
 * @param vd	the view direction of the camera
 */
void PPC::Set(const V3& C, const V3& a, const V3& vd) {
	this->C = C;
	this->a = a;

	b = (vd ^ a).UnitVector() * b.Length();

	c = vd.UnitVector() * GetFocalLength() - a * ((float)w/2.0f) - b * ((float)h/2.0f);

	SetPMat();
}