Sign in to follow this  
takis

ray tracer: shooting ray

Recommended Posts

takis    150
Hello, I have implemented arcball into my raytracer. The arcball works perfectly.
glPushMatrix();
glMultMatrixf(m_pArcBall->getrotationmatrix().ptr());
m_pDocument->draw();
glPopMatrix();
For my raytracer, do i have to recalculate my viewposition en viewdirection if i am using my arcball? Can i recalculate it like this: viewpos=m_pArcBall->getrotationmatrix()*viewpos; viewdir=m_pArcBall->getrotationmatrix()*viewdir; where eye=viewpos and center=viewpos+viewdir

Share this post


Link to post
Share on other sites
takis    150
I just want to know if i rotate an object with arcball. Do i have to change the eye of the camera in order to shoot rays to the object?

How can i extract the eye and the center from the model_view matrix?




[code]
void ArcBall::mouseMove(float mouseX, float mouseY, float viewW, float viewH)
{
// map [0, w] to [-1, 1] and [0, h] to [-1, 1]
float x=2*mouseX/viewW-1.0f;
float y=2*((viewH-mouseY)/viewH)-1.0f;

Vector3D vTo=mapToSphere(x,y);

m_qDrag.setFromPoints(m_vFrom,vTo);
m_qNow.product(m_qDrag,m_qDown);

Quaternion q=m_qNow;
q.conjugate();

m_mTrans=q.getRotationMatrix();
}
[\code]

Share this post


Link to post
Share on other sites
Max_Payne    757
I will try to answer, but I'm afraid you aren't being clear enough. Could you specify what you call an "arcball", and precisely what it is you're trying to do?

When you rotate the camera, you necessarily have to emit the rays in a different direction, because it rotates the image plane around the camera's origin. You just have to rotate the corners of this image rectangle around, and use that to interpolate the pixel positions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this