Advertisement Jump to content
Sign in to follow this  

ray tracer: shooting ray

This topic is 4970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!