[Plib-users] Help for code that is not documented and is confusing
Brought to you by:
sjbaker
From: Dimitris M. <dm...@ya...> - 2007-07-23 21:41:53
|
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 tri= ed I did it blindly....=0ACan some one help me with the code snippets below= ?=0A=0AFIRST :=0A=0A /* Look for the nearest polygon *beneath* my_posit= ion */=0A float HOT_TOLERANCE =3D 1.0f;=0A ssgHit *results;=0A int= num_hits;=0A float hot; /* H.O.T =3D=3D Height Of Terrain */=0A sgV= ec3 HOTvec;=0A sgMat4 invmat;=0A sgMakeIdentMat4( invmat );=0A inv= mat[3][0] =3D - my_position[0];=0A invmat[3][1] =3D - my_position[1];=0A= invmat[3][2] =3D 0.0f;=0A=0A sgSetVec3( HOTvec, 0.0f, 0.0f, -my_posi= tion[2] + HOT_TOLERANCE );//FIXME I don't know why I use minus here!!=0A = num_hits =3D ssgHOT( scene, HOTvec, invmat, &results );=0A hot =3D DEEP= EST_HELL;=0A for ( int i =3D 0; i < num_hits; i++ ) {=0A ssgHit *= h =3D &results[i];=0A float hgt =3D - h->plane[3] / h->plane[2];=0A = if ( hgt >=3D hot ) {=0A hot =3D hgt;=0A if ( = normal !=3D NULL )=0A sgCopyVec3( normal, h->plane );=0A = }=0A }=0A return hot;=0A}=0A=0ABesides the fact that I took as "g= lobal constant" the code, I didn;t understand why the inverse matrix! ?=0AW= hat is supposed to do ?=0A=0Alower You see a FIXME, it is mine, and yes wha= t does this line do ?=0AIf I have a 3000polygon coming against 5000 polygon= s of another surface, the for loop, goes all this around to seek the collit= ion?=0AWhat is, really ssgHit, and the division with float hgt ?=0A=0ANext = 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....=0AHas anyone tried to dra= w something in 3D from his mouse click? e.g. the ray and try to intercect w= ith the objects in the scenery?=0AOR has anyone achieved to point and click= an object ? I haven't seen code to do that from plib...apart ppe, which pp= e neither compiles nor has some remarks to understand it's stuff...=0A=0ACr= ying for help...=0ADimitris=0A=0AThank you=0A=0A=0A=0A=0A =0A________= ___________________________________________________________________________= _=0AMoody friends. Drama queens. Your life? Nope! - their life, your story.= Play Sims Stories at Yahoo! Games.=0Ahttp://sims.yahoo.com/ |