Sign in to follow this  

ray tracer: shooting ray

Recommended Posts

Hello, I have implemented arcball into my raytracer. The arcball works perfectly.
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
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?

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);


Quaternion q=m_qNow;


Share this post

Link to post
Share on other sites
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