   Generating texture coords
  Im using opengl and want to generate dynamic texture coordinates as i move geometry around. by 'geometry' im talking about static things like walls or floors. I was using this:VECT vS(   0.0f, 0.0f, 0.0f ),    vT(   0.0f, 0.0f, 0.0f ),    vRef( 0.0f, 0.0f, 0.0f );    VECT vNormal;    int iY;    VECT vThing[ 3 ];    vThing[ 0 ] = V( 0 )->GetPos();    vThing[ 1 ] = V( 1 )->GetPos();    vThing[ 2 ] = V( 2 )->GetPos();    vNormal = Normal( vThing );    if( ( vNormal.x == 0.0f && vNormal.y ==  1.0f && vNormal.z == 0.0f ) ||   ( vNormal.x == 0.0f && vNormal.y == -1.0f && vNormal.z == 0.0f ) )    {   vRef.x = 1.0f;    }    else    {   vRef.y = -1.0f;    }    vS = Normalize( GetCrossProduct( vNormal, vRef ) ) / 2.0f;    vT = Normalize( GetCrossProduct( vNormal, vS   ) ) / 2.0f;    for( iY = 0; iY < 3; iY++ )    {   V( iY )->SetTexU( ( V( iY )->GetPos().x * vS.x ) + ( V( iY )->GetPos().y * vS.y ) + ( V( iY )->GetPos().z * vS.z ) );   V( iY )->SetTexV( ( V( iY )->GetPos().x * vT.x ) + ( V( iY )->GetPos().y * vT.y ) + ( V( iY )->GetPos().z * vT.z ) );    }which was generally what i wanted, just too buggy. What i know that im NOT looking for are the standatd opengl texture coord generation functions, ive looked at those and theyre not what im looking for.recently, its completely broken down as seen here:but what i want is to have an algo that generates texture coords to make this cube (composed of triangles) to display correctly. Should i move any individual vertex, the texture should not stretch, but the texture should begin tiling.I just need an algorithim that takes 3 vertex positions and is able to generate UV coordinates to each vertex.Anywho, if anyone has an algorithim that they use for this or know where i can find one, i'd very much like to try it (and credit you). Thanks.[edited by - Mulligan on February 2, 2004 9:51:57 PM]
  Mulligan,A technique that has worked well for me (you may have tried this already) is to work out which plane in the world (x-y, y-z, or x-z) is most closely aligned with the polygon you want to texture and then use world coordinates to compute your tiled texture coordinates. I don't have my code with me right now, but the process is as follows:(1) Compute the poly normal (you must use vertices transformed into the world coordinate system). Get rid of any negative values (* -1);(2) If the normal x value is greater than the normal y and normal z values, the poly is mostly aligned with the y-z plane - use that to compute the texture coordinates. If the normal y value is greater than the normal x and normal z values, the poly is mostly aligned with the x-z plane - use that etc...This method can let you down when the normal values become very similar (poly is very closely aligned to two planes at once), but it's mostly very effective.You compute the actual texture coordinates by taking the positions of the polygon vertices in the world and subtracting the centre position of the poly in the world in order to move the coordinates to local space. You may need to scale the coordinates accordingly if your world units are not the same as your texture units (eg. if the size of 1 tile in the world is 3000 units wide and your texture coordinates are in the range 0 - 1, you will need to divide your coordinates by 3000 before using them).Tell me if you need further details.Paulcoz.   [edited by - paulcoz on February 3, 2004 2:36:43 AM];  I like youre ideas, theyre going to give me something to think about during english class in 10 minutes... im going to try out a hybrid of the first idea you had plus something im already working on.If you have any more ideas, do share them, even if just experimental methods you havent tried out yet, im learning to think in more advanced ways about 3d math and such, and im liking it.(kind of)oh, and if you DO have source code, that wouldnt hurt. I''s like to see how effective your first solution is. Thanks! ;  UPDATE: ahha, i did it.turns out to be the most complicated mathmatical equation ive ever used, but it works under all conditions!woo for being a nerd!!! ;  Well done! Did you use the world coordinates, or calculate the values some other way?Paulcoz. 