Parametric Ray Equation:
R(t) = e + (s-e).t
For this we require s and e
e = camera position
s = image plane pixel center
Given:
1. camera position
2. camera view direction
3. Distance between eye and image plane
4. Direction of camera or image plane center
Eye Coordinate System:
In Coding we can built it using following code: SbVec3f Camera::calculateN(){ n = direction * (-1); n.normalize(); return n; } SbVec3f Camera::calculateU(){ SbVec3f V = getViewUp(); SbVec3f normal = calculateN(); u = V.cross(normal); u.normalize(); return u; } SbVec3f Camera::calculateV(){ v = n.cross(u); v.normalize(); return v; }
In above code we know the direction in which camera is looking so for calculating n vector we just need to reverse the direction which can be done by multiplying it with -1.
SbVec3f is data type in coin3d which help you to define vectors.
To normalize a vector we have predefined method for vector algebra in C++ normalize()
Next thing we need to construct Image Plane which I explain in my next post
No comments:
Post a Comment