/[libvob]/libvob/include/vob/vobs/Fillet.hxx
ViewVC logotype

Diff of /libvob/include/vob/vobs/Fillet.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.41 by jvk, Thu Jul 3 15:06:45 2003 UTC revision 1.42 by jvk, Thu Jul 3 19:13:15 2003 UTC
# Line 742  struct Fillet3DBlend { Line 742  struct Fillet3DBlend {
742              int n = rtbl.size() - 1;              int n = rtbl.size() - 1;
743              float a = v.atan();              float a = v.atan();
744              float t = sqrt(a / f.tangentAngle);              float t = sqrt(a / f.tangentAngle);
745              unsigned i = (unsigned)(t * n);              int i = (int)(t * n);
746              float fract = t * n - i;              float fract = t * n - i;
747              if (i >= n) return rtbl[n];              if (i >= n) return rtbl[n];
748              return (1 - fract) * rtbl[i] + fract * rtbl[i + 1];              return (1 - fract) * rtbl[i] + fract * rtbl[i + 1];
# Line 855  struct Fillet3DBlend { Line 855  struct Fillet3DBlend {
855                    
856      }      }
857    
858        void renderGrid(const std::vector<ZVec> &pt, int n, int m) const {
859            std::vector<ZVec> norm(n * m);
860            int i, j;
861    
862            for (i = 0; i < n; i++) {
863                for (j = 0; j < m; j++) {
864                    ZVec px0 = pt[(i==  0 ?   0 : i-1) * m + j];
865                    ZVec px1 = pt[(i==n-1 ? n-1 : i+1) * m + j];
866                    ZVec py0 = pt[i * m + (j==  0 ?   0 : j-1)];
867                    ZVec py1 = pt[i * m + (j==m-1 ? m-1 : j+1)];
868    
869                    norm[i * m + j] = (px1 - px0).crossp(py1 - py0).normalized();
870                }
871            }
872    
873            for (i = 0; i < n - 1; i++) {
874                glBegin(GL_QUAD_STRIP);
875                for (j = 0; j < m; j++) {
876                    glNormal(norm[i * m + j]);
877                    glVertex(pt[i * m + j]);
878    
879                    glNormal(norm[(i+1) * m + j]);
880                    glVertex(pt[(i+1) * m + j]);
881                }
882                glNormal(norm[i * m + 0]);
883                glVertex(pt[i * m + 0]);
884    
885                glNormal(norm[(i+1) * m + 0]);
886                glVertex(pt[(i+1) * m + 0]);
887                glEnd();
888            }
889        }
890    
891      void render(const Transform **t, int n) const {      void render(const Transform **t, int n) const {
892          const Transform &thick_t = *t[0];          const Transform &thick_t = *t[0];
893          const Transform &angle_t = *t[1];          const Transform &angle_t = *t[1];
# Line 886  struct Fillet3DBlend { Line 919  struct Fillet3DBlend {
919    
920  #if 1 // Old  version without Dicer  #if 1 // Old  version without Dicer
921    
922          ZVec pt[ndice + 1][ndice*2];          std::vector<ZVec> pt((ndice + 1) * (ndice * 2));
         ZVec norm[ndice + 1][ndice*2];  
923    
924          for (i = 0; i <= ndice; i++) {          for (i = 0; i <= ndice; i++) {
925              float a = i * M_PI / ndice;              float a = i * M_PI / ndice;
# Line 900  struct Fillet3DBlend { Line 932  struct Fillet3DBlend {
932                  float y = cos(b) * R;                  float y = cos(b) * R;
933                  float z = sin(b) * R;                  float z = sin(b) * R;
934    
935                  pt[i][j] = r * ZVec(x, y, z);                  pt[i * (ndice * 2) + j] = r * ZVec(x, y, z);
936              }              }
937          }          }
938    
939            for (i = 0; i < (ndice + 1) * (ndice * 2); i++)
940                pt[i] = blend(conns, N, r, pt[i]) + p0;
941    
942          for (i = 0; i <= ndice; i++)          renderGrid(pt, ndice + 1, ndice * 2);
             for (j = 0; j < ndice*2; j++)  
                 pt[i][j] = blend(conns, N, r, pt[i][j]) + p0;  
   
943                                    
         for (i = 0; i <= ndice; i++) {  
             for (j = 0; j < ndice*2; j++) {  
                 ZVec px0 = pt[i==0 ? 0 : i-1][j];  
                 ZVec px1 = pt[i==ndice ? ndice : i+1][j];  
                 ZVec py0 = pt[i][j==0 ? 0 : j-1];  
                 ZVec py1 = pt[i][j==ndice*2-1 ? ndice*2-1 : j+1];  
   
                 norm[i][j] = (px1 - px0).crossp(py1 - py0).normalized();  
             }  
         }  
   
         for (i = 0; i < ndice; i++) {  
             glBegin(GL_QUAD_STRIP);  
             for (j = 0; j < ndice*2-1; j++) {  
                 glNormal(norm[i][j]);  
                 glVertex(pt[i][j]);  
   
                 glNormal(norm[i+1][j]);  
                 glVertex(pt[i+1][j]);  
             }  
             glNormal(norm[i][0]);  
             glVertex(pt[i][0]);  
   
             glNormal(norm[i+1][0]);  
             glVertex(pt[i+1][0]);  
             glEnd();  
         }  
944    
945  #else // use Dicer  #else // use Dicer
946    

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26