Re: [Plib-users] Help for code that is not documented and is confusing
Brought to you by:
sjbaker
|
From: Fay J. F Dr C. U. 46 S. <joh...@eg...> - 2007-07-24 19:41:40
|
Dimitris,
A few more answers:
The "PointPicker" demo program in PUI has a "point and
click" capability to select an object. You start the program, click
twice in the gray input box, and then right-click on one of the square
"points" in the main window. When you first start the program you have
to click twice in the input box before trying to select a point, but
after the first time you only need to click once; I do not know why this
is. The selected point turns red and its point number appears in the
input box.
In your code snippet, I do not know why the inverse
matrix is being used. I think the minus signs are related to the fact
that it is an inverse matrix; the red book on page 478 gives the matrix
in question. I also don't know whether "hot" is "height of terrain" or
"height over terrain". In the first case it would be the altitude of
the terrain above some zero point; in the second case it would be the
height of your point over the terrain. I do know that "hgt" is short
for "height". The "for ( int i" loop is stepping through all the hits
returned by the "ssgHOT" call and finding the one with the greatest
height. Again, I'm not sure why the code sets " hgt =3D - h->plane[3] /
h->plane[2]" since using the homogeneous coordinates (page 476 of the
red book) I would expect " hgt =3D - h->plane[2] / h->plane[3]".
John F. Fay
Technical Fellow
Jacobs Technology TEAS Group
850-883-1294=20
-----Original Message-----
From: pli...@li...
[mailto:pli...@li...] On Behalf Of Dimitris
Mexis
Sent: Monday, July 23, 2007 4:42 PM
To: pli...@li...
Subject: [Plib-users] Help for code that is not documented and is
confusing
Hello people, I am trying to study plib and do some tricks with it, I
found code for doing things. No dicent documentation though. So
everything I tried I did it blindly....
Can some one help me with the code snippets below ?
FIRST :
/* Look for the nearest polygon *beneath* my_position */
float HOT_TOLERANCE =3D 1.0f;
ssgHit *results;
int num_hits;
float hot; /* H.O.T =3D=3D Height Of Terrain */
sgVec3 HOTvec;
sgMat4 invmat;
sgMakeIdentMat4( invmat );
invmat[3][0] =3D - my_position[0];
invmat[3][1] =3D - my_position[1];
invmat[3][2] =3D 0.0f;
sgSetVec3( HOTvec, 0.0f, 0.0f, -my_position[2] + HOT_TOLERANCE
);//FIXME I don't know why I use minus here!!
num_hits =3D ssgHOT( scene, HOTvec, invmat, &results );
hot =3D DEEPEST_HELL;
for ( int i =3D 0; i < num_hits; i++ ) {
ssgHit *h =3D &results[i];
float hgt =3D - h->plane[3] / h->plane[2];
if ( hgt >=3D hot ) {
hot =3D hgt;
if ( normal !=3D NULL )
sgCopyVec3( normal, h->plane );
}
}
return hot;
}
Besides the fact that I took as "global constant" the code, I didn;t
understand why the inverse matrix! ?
What is supposed to do ?
lower You see a FIXME, it is mine, and yes what does this line do ?
If I have a 3000polygon coming against 5000 polygons of another surface,
the for loop, goes all this around to seek the collition?
What is, really ssgHit, and the division with float hgt ?
Next I want to ask about the code in PPE about picking...To tell you the
truth I read OpenGL book about glLoadName* but I don't see how that
would fit here when I load a model and not drawing vertices....
Has anyone tried to draw something in 3D from his mouse click? e.g. the
ray and try to intercect with the objects in the scenery?
OR has anyone achieved to point and click an object ? I haven't seen
code to do that from plib...apart ppe, which ppe neither compiles nor
has some remarks to understand it's stuff...
Crying for help...
Dimitris
Thank you
=20
________________________________________________________________________
____________
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/ =20
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
plib-users mailing list
pli...@li...
https://lists.sourceforge.net/lists/listinfo/plib-users
|