Re: [Plib-users] Help for code that is not documented and is confusing
Brought to you by:
sjbaker
From: Dimitris M. <dm...@ya...> - 2007-07-24 19:58:39
|
Yes you are right, about the division, and the assumptions you made have a = meaning.=0AThe PointPicker? I don;t have this tutorial!!! Can you send it t= o me plz?=0AI tried also to inverse the elements of this matrix inv[..], on= ly those apart from [2]. Because if you touch the [2] dimension=0Athe resul= t is awful...=0A=0AWhat to say, I am very thankfull for your help, John.=0A= =0A----- Original Message ----=0AFrom: Fay John F Dr CTR USAF 46 SK <john.f= ay...@eg...>=0ATo: PLIB Users <pli...@li...>=0A= Sent: Tuesday, July 24, 2007 10:41:34 PM=0ASubject: Re: [Plib-users] Help f= or code that is not documented and is confusing=0A=0ADimitris,=0A=0A A f= ew more answers:=0A=0A The "PointPicker" demo program in PUI has a "= point and=0Aclick" capability to select an object. You start the program, = click=0Atwice in the gray input box, and then right-click on one of the squ= are=0A"points" in the main window. When you first start the program you ha= ve=0Ato click twice in the input box before trying to select a point, but= =0Aafter the first time you only need to click once; I do not know why this= =0Ais. The selected point turns red and its point number appears in the=0A= input box.=0A=0A In your code snippet, I do not know why the inverse= =0Amatrix is being used. I think the minus signs are related to the fact= =0Athat it is an inverse matrix; the red book on page 478 gives the matrix= =0Ain question. I also don't know whether "hot" is "height of terrain" or= =0A"height over terrain". In the first case it would be the altitude of=0A= the terrain above some zero point; in the second case it would be the=0Ahei= ght of your point over the terrain. I do know that "hgt" is short=0Afor "h= eight". The "for ( int i" loop is stepping through all the hits=0Areturned= by the "ssgHOT" call and finding the one with the greatest=0Aheight. Agai= n, I'm not sure why the code sets " hgt =3D - h->plane[3] /=0Ah->plane[2]" = since using the homogeneous coordinates (page 476 of the=0Ared book) I woul= d expect " hgt =3D - h->plane[2] / h->plane[3]".=0A=0AJohn F. Fay=0ATechnic= al Fellow=0AJacobs Technology TEAS Group=0A850-883-1294 =0A=0A-----Original= Message-----=0AFrom: pli...@li...=0A[mailto:pl= ib-...@li...] On Behalf Of Dimitris=0AMexis=0ASen= t: Monday, July 23, 2007 4:42 PM=0ATo: pli...@li...=0AS= ubject: [Plib-users] Help for code that is not documented and is=0Aconfusin= g=0A=0AHello people, I am trying to study plib and do some tricks with it, = I=0Afound code for doing things. No dicent documentation though. So=0Aevery= thing I tried I did it blindly....=0ACan some one help me with the code sni= ppets below ?=0A=0AFIRST :=0A=0A /* Look for the nearest polygon *beneat= h* my_position */=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 sgVec3 HOTvec;=0A sgMat4 invmat;=0A sgMakeIdentMat4( invmat )= ;=0A invmat[3][0] =3D - my_position[0];=0A invmat[3][1] =3D - my_posi= tion[1];=0A invmat[3][2] =3D 0.0f;=0A=0A sgSetVec3( HOTvec, 0.0f, 0.0= f, -my_position[2] + HOT_TOLERANCE=0A);//FIXME I don't know why I use minus= here!!=0A num_hits =3D ssgHOT( scene, HOTvec, invmat, &results );=0A = hot =3D DEEPEST_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->pl= ane );=0A }=0A }=0A return hot;=0A}=0A=0ABesides the fact that= I took as "global constant" the code, I didn;t=0Aunderstand why the invers= e matrix! ?=0AWhat is supposed to do ?=0A=0Alower You see a FIXME, it is mi= ne, and yes what does this line do ?=0AIf I have a 3000polygon coming again= st 5000 polygons of another surface,=0Athe for loop, goes all this around t= o seek the collition?=0AWhat is, really ssgHit, and the division with float= hgt ?=0A=0ANext I want to ask about the code in PPE about picking...To tel= l you the=0Atruth I read OpenGL book about glLoadName* but I don't see how = that=0Awould fit here when I load a model and not drawing vertices....=0AHa= s anyone tried to draw something in 3D from his mouse click? e.g. the=0Aray= and try to intercect with the objects in the scenery?=0AOR has anyone achi= eved to point and click an object ? I haven't seen=0Acode to do that from p= lib...apart ppe, which ppe neither compiles nor=0Ahas some remarks to under= stand it's stuff...=0A=0ACrying for help...=0ADimitris=0A=0AThank you=0A=0A= =0A=0A=0A =0A________________________________________________________= ________________=0A____________=0AMoody friends. Drama queens. Your life? N= ope! - their life, your story.=0APlay Sims Stories at Yahoo! Games.=0Ahttp:= //sims.yahoo.com/ =0A=0A--------------------------------------------------= ----------------------=0A-=0AThis SF.net email is sponsored by: Splunk Inc.= =0AStill grepping through log files to find problems? Stop.=0ANow Search l= og events and configuration files using AJAX and a browser.=0ADownload your= FREE copy of Splunk now >> http://get.splunk.com/=0A_____________________= __________________________=0Aplib-users mailing list=0Ap...@li...u= rceforge.net=0Ahttps://lists.sourceforge.net/lists/listinfo/plib-users=0A= =0A------------------------------------------------------------------------= -=0AThis SF.net email is sponsored by: Splunk Inc.=0AStill grepping through= log files to find problems? Stop.=0ANow Search log events and configurati= on files using AJAX and a browser.=0ADownload your FREE copy of Splunk now = >> http://get.splunk.com/=0A______________________________________________= _=0Aplib-users mailing list=0Ap...@li...=0Ahttps://li= sts.sourceforge.net/lists/listinfo/plib-users=0A=0A=0A=0A=0A=0A =0A__= ___________________________________________________________________________= _______=0ANeed a vacation? Get great deals=0Ato amazing places on Yahoo! Tr= avel.=0Ahttp://travel.yahoo.com/ |