From: Damien Gerhardy (damien.gerhardy++at++sydac.com.au)
Date: 04/25/2005 17:34:19
Still having problems with the raycasting of objects
to the terrain. I applied the check below but it doesn't
help. The check returns true but when I get the hit point
it is still (NaN, NaN, NaN).
Do I have to "wait" for the scene graph to stabalize for
a few frames? or something else like that?
This bug is a showstopper!!! and it needs to be fixed asap!!!!!!!
If anyone has any ideas please help me out.
Thanks.
-Damien
-----Original Message-----
From: Tony Horrobin [mailto:a.j.horrobin++at++its.leeds.ac.uk]
Sent: Friday, 22 April 2005 10:41 PM
To: damien.gerhardy++at++sydac.com.au
Subject: Re: [info-performer] RayCast bug in Performer 2.2 and 3.1.1 on
IRIX
Hello,
What happens if you do:
char buf[4];
hit.query( PFQHIT_FLAGS, buf );
unsigned int flags = *((unsigned int*)buf);
if ( flags & PFHIT_POINT )
{
// get the point
}
to check that the point is indeed valid before getting it?
-Tony
>I've run in to a problem with some ray casting code on
>Irix that works fine on Windows.
>
>After pfNode->isect returns a hit I call ->query(PFQHIT_POINT, pnt.vec)
>on the hit and get pnt.vec set to (nan, nan, nan).
>
>Many other points *near* the point I am testing seem to work but the
>same points seem to fail the raycast each time.
>
>Here is the code I am using below. If anyone knows of a workaround, or
>how to fix this it would be of great help.
>
>*Just to reiterate, this code works fine on several projects on the Windows
>platform but does not work on Irix (tested with performer 2.2 and 3.1.1).
>
>
> int PerformerEngine::RayCast(const Vision::Ray &ray, Vision::RayHit
&rayhit)
> {
> // Make a performer line segment for testing
> // Need a segment set to do the testing
> ::pfSegSet segset;
>
> // set up intersection segment, pointing down
> // for "terrain" following
> segset.activeMask = 1;
> segset.isectMask = 0x0000FFFF; // Set high masks on m_objects to
skip isector hit
> segset.discFunc = NULL;
> segset.bound = NULL;
> segset.mode = PFTRAV_IS_PRIM;
> segset.segs[0].pos.set(ray.x, ray.y, ray.z);
> segset.segs[0].dir.set(ray.dx, ray.dy, ray.dz);
> segset.segs[0].length = (ray.distance <= 0.0 ? 999.0 :
ray.distance);
>
> // Cast from the scene node - we are testing against the whole
scene!
>
> // Prepare a list for hits - but we only realy care about the first
one.
> // All the examples on the web use [32] here. Not sure why.
> ::pfHit **hits[32];
> int numhits;
> numhits = g_scene->m_pnode->isect(&segset, hits);
> if (numhits <= 0)
> {
> return 0;
> }
>
> // get the hit point
> ::pfVec3 pnt;
> (*hits[0])->query(PFQHIT_POINT, pnt.vec);
>
>#ifdef IRIX
> // we need to sanity check the hit point on IRIX
> if (isnan(pnt.vec[PF_Z]))
> {
> LOG_ERROR << "RayCast point is invalid" << ENDLOG; // THIS
ERROR COMES UP OFTEN!!
> return 0;
> }
>#endif
>
> // transform object point into scene coordinates
> ::pfMatrix xmat;
> (*hits[0])->query(PFQHIT_XFORM, (float*)xmat.mat);
>
> ::pfVec3 xpnt;
> xpnt.xformPt(pnt, xmat);
>
> // copy into rayhits
> rayhit.x = xpnt[PF_X];
> rayhit.y = xpnt[PF_Y];
> rayhit.z = xpnt[PF_Z];
>
> return 1;
> }
>
>
>
>Thanks.
>-Damien
>
>
>Damien Gerhardy
>SYDAC Pty Ltd
>Simulating a Better Reality
>113-115 King William Street
>Adelaide, SA, 5000
>Australia
>tel: +61 8 8239 3600
>fax: +61 8 8212 0334
>damien.gerhardy++at++sydac.com.au
Caution - This e-mail and its contents contain privileged information that
is intended solely for the recipient. If you are not the intended recipient
you are hereby notified that any use, dissemination, distribution or
reproduction of this e-mail is prohibited. If you have received this e-mail
in error please notify the Postmaster at sydac++at++sydac.com.au immediately. Any
views expressed in this e-mail are of the sender and may not necessarily
reflect the views of Sydac Pty Ltd.
This archive was generated by hypermail 2b29 : Mon Apr 25 2005 - 17:30:50 PDT