[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: Debugging desaster
Gregor Mückl wrote:
The
getCameraRay function should produce a starting point and a ray direction for
a ray emerging at the camera position in 3d coordinates and going through the
point that the user selected in the 2d projection n screen. This function
fails as soon as the view gets rotated.
When you say 'fails' - does it core-dump or just produce bad results?
Assuming it just produces bad results - then in all likelyhood, it is
one of two things:
* You are concatenating matrices in the wrong order (this works just
fine when all you have are translations - but screws up badly when
you rotate).
* You are somehow creating your matrix from Euler rotation angles
and you are concatenating those rotations in the wrong order.
Once again, things would only go wrong when you rotated...but this
error tends to be more subtle because rotating around any ONE axis
would work - and rotation about two or more axes would produce
subtle errors for small angles of rotation that grow rapidly as
the angles get larger.
Have you looked at the source code for gluUnproject from (say) the
Mesa sources. It does something very close to what you describe and
might serve you better than writing your own code.
---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1@xxxxxxxxxxx> WorkEmail: <sjbaker@xxxxxxxx>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----