Sign in to follow this  
vraim

Inverted point transformations.

Recommended Posts

Hi, I got very quick question. Does anyone know how to do such a thing: 1. I got cloud of points with it's weight other then the 0,0,0. 2. I'm moving it to 0,0,0 then rotate and scale. 3. After that I'm getting the MODELVIEW_MATRIX: glGetFloatv(GL_MODELVIEW_MATRIX ,mr); 4. After that I'm drawing the box with corners (X0,Y0,Z0) -> (X1,Y1,Z1) 5. What I would like to do is to check are any of points from the cloud are in this box. What's more to make it work faster I would like to do it while I'm creating the lists ;-) I made it this way (by invertinf the MODELVIEW_MATRIX), but it works only when the object is not rotated and it's weight is in 0,0,0. int i,j, ti, tj, idst, jdst; // inverting the matrices for ( ti = 0; ti < 4; ti++ ) { if ( ti < i ) idst = ti; else if ( ti > i ) idst = ti-1; for ( tj = 0; tj < 4; tj++ ) { if ( tj < j ) jdst = tj; else if ( tj > j ) jdst = tj-1; if ( ti != i && tj != j ) mb[idst*3 + jdst] = mr[ti*4 + tj ]; } } // counting the new points selX0 = ((mb[0]*selX0)+(mb[4]*selX0)+(mb[8]*selX0)+(mb[12]*selX0)); selY0 = ((mb[1]*selY0)+(mb[5]*selY0)+(mb[9]*selY0)+(mb[13]*selY0)); selZ0 = ((mb[2]*selZ0)+(mb[6]*selZ0)+(mb[10]*selZ0)+(mb[14]*selZ0)); selX1 = ((mb[0]*selX1)+(mb[4]*selX1)+(mb[8]*selX1)+(mb[12]*selX1)); selY1 = ((mb[1]*selY1)+(mb[5]*selY1)+(mb[9]*selY1)+(mb[13]*selY1)); selZ1 = ((mb[2]*selZ1)+(mb[6]*selZ1)+(mb[10]*selZ1)+(mb[14]*selZ1)); // after that I'm just checking is the point from the cloud between those points. // I'm using PROJECTION MATRIX only in the beginning or while window changes. Any ideas how can I make it work? Jacek

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this