Jump to content
  • Advertisement
Sign in to follow this  
takis

ray tracer: shooting ray

This topic is 4819 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.
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
Advertisement
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);

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
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!