Hi NG!

i have a GUI Viewport on top of my scene. I use a passiveBackground and set up the camera like this:

   Matrix orthogonalMatrix;
Real32 nearClip=-0.001;
   Real32 farClip=1000.0;
   Real32 aspect = 1024.0/1450.0;

MatrixOrthogonal(orthogonalMatrix, 0.0, 1.0, 0.0, 1.0*aspect, nearClip, farClip);

   _camera = MatrixCamera::create();
   _camera->setProjectionMatrix( orthogonalMatrix);

//Now the viewport:
   PassiveBackgroundPtr passiveBackground = PassiveBackground::create();

   beginEditCP(_viewport);
           _viewport->setCamera( _camera);
           _viewport->setRoot( _orthoRoot);
           _viewport->setSize( 0.0, 0.0, 1.0, 1.0);
           _viewport->setBackground(passiveBackground);
   endEditCP(_viewport);

That works fine and i can see everything as expected.
However now i wanted to do picking but the Ray that camera->calcViewRay() returns does not do the job. Its Position is always at [0,0,0], whereas the Direction is some other value like [0.000234 0.000235 -1.00000] the third value is always -1.0 and the others are really small. I had expected that the position's (x,y) would reflect my mouse click's (x,y) and the z coordinate to be >=0;
This is how i call it:

bool OverlayViewport::mouseClick( int button, int state, int x, int y)
{
   Line ray;
   _camera->calcViewRay( ray, x, y );

printf("ray: [%f %f %f] to [%f %f %f]\n", ray.getPosition().x(), ray.getPosition().y(), ray.getPosition().z(), ray.getDirection().x(), ray.getDirection().y(), ray.getDirection().z());

   IntersectAction *iAct = IntersectAction::create(ray);
   iAct->apply( _orthoRoot);
   //react...
}

As I am not really sure about what is happening here, I would like to ask:

Is this the correct way to set up an orthografic camera?
Is calcViewRay the right choice for such an ortho Cam?
If Not, how do i pick my objects then?

Thanks in advance,
Tobias Kilian


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to