Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

tex_coord_gen.C

Go to the documentation of this file.
00001 //base functionality needed by most 
00002 //automatic texture coordinate generators
00003 // by Karol Szerszen
00004 
00005 
00006 #include "tex_coord_gen.H"
00007 
00008 
00009 UVpt 
00010 TexCoordGen :: fix_seems(CUVpt& fix_this_coord, CUVpt& coord2, CUVpt& coord3)
00011 {
00012 
00013 
00014    UVpt tex_coord = fix_this_coord;
00015    UVpt ts1 = coord2;
00016    UVpt ts2 = coord3;
00017    
00018  
00019    //get both deltas 
00020    double delta1U, delta2U; 
00021    double deltaU = 0.0;
00022    double delta1V, delta2V;
00023    double deltaV = 0.0;
00024 
00025    delta1U = ts1[0] - tex_coord[0]; delta2U = ts2[0] - tex_coord[0];
00026    delta1V = ts1[1] - tex_coord[1]; delta2V = ts2[1] - tex_coord[1];
00027 
00028    //check if they are both outside the bounds
00029    if ( ((delta1U > 0.5) && (delta2U > 0.5)) ||((delta1U < -0.5) && (delta2U < -0.5)))
00030       deltaU = delta1U;
00031    
00032    if ( ((delta1V > 0.5) && (delta2V > 0.5)) ||((delta1V < -0.5) && (delta2V < -0.5)))
00033       deltaV = delta1V;
00034    
00035    
00036   
00037   //tweak the texture coordinate to match the others 
00038   
00039    if (deltaU >  0.5) 
00040       tex_coord[0]+= 1.0;
00041    if (deltaU < -0.5) 
00042       tex_coord[0]+= -1.0;
00043 
00044    if (deltaV >  0.5) 
00045       tex_coord[1]+= 1.0;
00046    if (deltaV < -0.5) 
00047       tex_coord[1]+= -1.0;
00048 
00049  
00050    return tex_coord;
00051 
00052 
00053 }

Generated on Mon Sep 18 11:39:33 2006 for jot by  doxygen 1.4.4