home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / povsrc.sit / SOURCE / TEXTURE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-03  |  15.1 KB  |  533 lines

  1. /****************************************************************************
  2. *                texture.c
  3. *
  4. *  This module implements texturing functions such as noise, turbulence and
  5. *  texture transformation functions. The actual texture routines are in the
  6. *  files txtcolor.c, txtbump.c, txtmap.c, etc.
  7. *  The noise function used here is the one described by Ken Perlin in
  8. *  "Hypertexture", SIGGRAPH '89 Conference Proceedings page 253.
  9. *
  10. *  from Persistence of Vision Raytracer 
  11. *  Copyright 1992 Persistence of Vision Team
  12. *---------------------------------------------------------------------------
  13. *  Copying, distribution and legal info is in the file povlegal.doc which
  14. *  should be distributed with this file. If povlegal.doc is not available
  15. *  or for more info please contact:
  16. *
  17. *       Drew Wells [POV-Team Leader] 
  18. *       CIS: 73767,1244  Internet: 73767.1244@compuserve.com
  19. *       Phone: (213) 254-4041
  20. * This program is based on the popular DKB raytracer version 2.12.
  21. * DKBTrace was originally written by David K. Buck.
  22. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  23. *
  24. *****************************************************************************/
  25. /*
  26.    Some texture ideas garnered from SIGGRAPH '85 Volume 19 Number 3, 
  27.    "An Image Synthesizer" By Ken Perlin.
  28.    Further Ideas Garnered from "The RenderMan Companion" (Addison Wesley)
  29. */
  30.  
  31. #include "frame.h"
  32. #include "vector.h"
  33. #include "povproto.h"
  34. #include "texture.h"
  35.  
  36. DBL *sintab;
  37. DBL frequency[NUMBER_OF_WAVES];
  38. VECTOR Wave_Sources[NUMBER_OF_WAVES];
  39. DBL *RTable;
  40. short *hashTable;
  41.  
  42. unsigned short crctab[256] =
  43. {
  44.    0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
  45.    0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
  46.    0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
  47.    0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
  48.    0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
  49.    0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
  50.    0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
  51.    0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
  52.    0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
  53.    0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
  54.    0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
  55.    0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
  56.    0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
  57.    0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
  58.    0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
  59.    0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
  60.    0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
  61.    0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
  62.    0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
  63.    0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
  64.    0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
  65.    0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
  66.    0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
  67.    0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
  68.    0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
  69.    0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
  70.    0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
  71.    0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
  72.    0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
  73.    0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
  74.    0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
  75.    0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
  76. };
  77.  
  78.  
  79.  
  80. void Compute_Colour (Colour, Colour_Map, value)
  81. COLOUR *Colour;
  82. COLOUR_MAP *Colour_Map;
  83. DBL value;
  84. {
  85.    register int i;
  86.    COLOUR_MAP_ENTRY *Ent;
  87.    register DBL fraction;
  88.  
  89.    if (value > 1.0)
  90.       value = 1.0;
  91.  
  92.    if (value < 0.0)
  93.       value = 0.0;
  94.  
  95.    for (i = 0, Ent = &(Colour_Map->Colour_Map_Entries[0]) ; i < Colour_Map -> Number_Of_Entries ; i++, Ent++)
  96.       if ((value >= Ent->start) && (value <= Ent->end))
  97.       {
  98.          fraction = (value - Ent->start) / (Ent->end - Ent->start);
  99.          Colour -> Red = Ent->Start_Colour.Red + fraction * (Ent->End_Colour.Red - Ent->Start_Colour.Red);
  100.          Colour -> Green = Ent->Start_Colour.Green + fraction * (Ent->End_Colour.Green - Ent->Start_Colour.Green);
  101.          Colour -> Blue = Ent->Start_Colour.Blue + fraction * (Ent->End_Colour.Blue - Ent->Start_Colour.Blue);
  102.          Colour -> Alpha = Ent->Start_Colour.Alpha + fraction * (Ent->End_Colour.Alpha - Ent->Start_Colour.Alpha);
  103.          return;
  104.       }
  105.  
  106.    Colour -> Red = 0.0;
  107.    Colour -> Green = 0.0;
  108.    Colour -> Blue = 0.0;
  109.    Colour -> Alpha = 0.0;
  110.    printf ("No colour for value: %g\n", value);
  111.    return;
  112. }
  113.  
  114. void Initialize_Noise ()
  115. {
  116.    register int i = 0;
  117.    VECTOR point;
  118.  
  119.    InitRTable();
  120.  
  121.    if ((sintab = (DBL *)malloc(SINTABSIZE * sizeof(DBL))) == NULL) {
  122.       printf("Cannot allocate memory for sine table\n");
  123.       exit(1);
  124.    }
  125.  
  126.    for (i = 0 ; i < SINTABSIZE ; i++)
  127.       sintab[i] = sin(i/(DBL)SINTABSIZE * (3.14159265359 * 2.0));
  128.  
  129.    for (i = 0 ; i < NUMBER_OF_WAVES ; i++)
  130.    {
  131.       DNoise (&point, (DBL) i, 0.0, 0.0);
  132.       VNormalize (Wave_Sources[i], point);
  133.       frequency[i] = (rand() & RNDMASK) / RNDDIVISOR + 0.01;
  134.    }
  135. }
  136.  
  137. void InitTextureTable()
  138. {
  139.    int i, j, temp;
  140.  
  141.    srand(0);
  142.  
  143.    if ((hashTable = (short int *) malloc(4096*sizeof(short int))) == NULL) {
  144.       printf("Cannot allocate memory for hash table\n");
  145.       exit(1);
  146.    }
  147.    for (i = 0; i < 4096; i++)
  148.       hashTable[i] = i;
  149.    for (i = 4095; i >= 0; i--) {
  150.       j = rand() % 4096;
  151.       temp = hashTable[i];
  152.       hashTable[i] = hashTable[j];
  153.       hashTable[j] = temp;
  154.    }
  155. }
  156.  
  157.  
  158. /* modified by AAC to work properly with little bitty integers (16 bits) */
  159.  
  160. void InitRTable()
  161. {
  162.    int i;
  163.    VECTOR rp;
  164.  
  165.    InitTextureTable();
  166.  
  167.    if ((RTable = (DBL *)malloc(MAXSIZE * sizeof(DBL))) == NULL) {
  168.       printf("Cannot allocate memory for RTable\n");
  169.       exit(1);
  170.    }
  171.  
  172.    for (i = 0; i < MAXSIZE; i++)
  173.    {
  174.       rp.x = rp.y = rp.z = (DBL)i;
  175.       RTable[i] = (unsigned int) R(&rp) * REALSCALE - 1.0;
  176.    }
  177. }
  178.  
  179.  
  180. int R(v)
  181. VECTOR *v;
  182. {
  183.    v->x *= .12345;
  184.    v->y *= .12345;
  185.    v->z *= .12345;
  186.  
  187.    return (Crc16((char *) v, sizeof(VECTOR)));
  188. }
  189.  
  190. /*
  191.  * Note that passing a VECTOR array to Crc16 and interpreting it as
  192.  * an array of chars means that machines with different floating-point
  193.  * representation schemes will evaluate Noise(point) differently.
  194.  */
  195.  
  196. int Crc16(buf, count)
  197. register char *buf;
  198. register int  count;
  199. {
  200.    register unsigned short crc = 0;
  201.  
  202.    while (count--)
  203.       crc = (crc >> 8) ^ crctab[ (unsigned char) (crc ^ *buf++) ];
  204.  
  205.    return ((int) crc);
  206. }
  207.  
  208.  
  209. /*
  210.     Robert's Skinner's Perlin-style "Noise" function - modified by AAC
  211.     to ensure uniformly distributed clamped values between 0 and 1.0...
  212. */
  213.  
  214. void setup_lattice(x, y, z, ix, iy, iz, jx, jy, jz, sx, sy, sz, tx, ty, tz)
  215. DBL *x, *y, *z, *sx, *sy, *sz, *tx, *ty, *tz;
  216. long *ix, *iy, *iz, *jx, *jy, *jz;
  217. {
  218.    /* ensures the values are positive. */
  219.    *x -= MINX;
  220.    *y -= MINY;
  221.    *z -= MINZ;
  222.  
  223.    /* its equivalent integer lattice point. */
  224.    *ix = (long)*x; *iy = (long)*y; *iz = (long)*z;
  225.    *jx = *ix + 1; *jy = *iy + 1; *jz = *iz + 1;
  226.  
  227.    *sx = SCURVE(*x - *ix); *sy = SCURVE(*y - *iy); *sz = SCURVE(*z - *iz);
  228.  
  229.    /* the complement values of sx,sy,sz */
  230.    *tx = 1.0 - *sx; *ty = 1.0 - *sy; *tz = 1.0 - *sz;
  231.    return;
  232. }
  233.  
  234.  
  235. DBL Noise(x, y, z)
  236. DBL x, y, z;
  237. {
  238.    long ix, iy, iz, jx, jy, jz;
  239.    DBL sx, sy, sz, tx, ty, tz;
  240.    DBL sum;
  241.    short m;
  242.  
  243.  
  244.    Calls_To_Noise++;
  245.  
  246.    setup_lattice(&x, &y, &z, &ix, &iy, &iz, &jx, &jy, &jz, &sx, &sy, &sz, &tx, &ty, &tz);
  247.  
  248.    /*
  249.     *  interpolate!
  250.     */
  251.    m = Hash3d( ix, iy, iz ) & 0xFF;
  252.    sum = INCRSUM(m,(tx*ty*tz),(x-ix),(y-iy),(z-iz));
  253.  
  254.    m = Hash3d( jx, iy, iz ) & 0xFF;
  255.    sum += INCRSUM(m,(sx*ty*tz),(x-jx),(y-iy),(z-iz));
  256.  
  257.    m = Hash3d( ix, jy, iz ) & 0xFF;
  258.    sum += INCRSUM(m,(tx*sy*tz),(x-ix),(y-jy),(z-iz));
  259.  
  260.    m = Hash3d( jx, jy, iz ) & 0xFF;
  261.    sum += INCRSUM(m,(sx*sy*tz),(x-jx),(y-jy),(z-iz));
  262.  
  263.    m = Hash3d( ix, iy, jz ) & 0xFF;
  264.    sum += INCRSUM(m,(tx*ty*sz),(x-ix),(y-iy),(z-jz));
  265.  
  266.    m = Hash3d( jx, iy, jz ) & 0xFF;
  267.    sum += INCRSUM(m,(sx*ty*sz),(x-jx),(y-iy),(z-jz));
  268.  
  269.    m = Hash3d( ix, jy, jz ) & 0xFF;
  270.    sum += INCRSUM(m,(tx*sy*sz),(x-ix),(y-jy),(z-jz));
  271.  
  272.    m = Hash3d( jx, jy, jz ) & 0xFF;
  273.    sum += INCRSUM(m,(sx*sy*sz),(x-jx),(y-jy),(z-jz));
  274.  
  275.    sum = sum + 0.5;          /* range at this point -0.5 - 0.5... */
  276.  
  277.    if (sum < 0.0)
  278.       sum = 0.0;
  279.    if (sum > 1.0)
  280.       sum = 1.0;
  281.  
  282.    return (sum);
  283. }
  284.  
  285.  
  286. /*
  287.        Vector-valued version of "Noise"
  288. */
  289.  
  290. void DNoise(result, x, y, z)
  291. VECTOR *result;
  292. DBL x, y, z;
  293. {
  294.    long ix, iy, iz, jx, jy, jz;
  295.    DBL px, py, pz, s;
  296.    DBL sx, sy, sz, tx, ty, tz;
  297.    short m;
  298.  
  299.    Calls_To_DNoise++;
  300.  
  301.    setup_lattice(&x, &y, &z, &ix, &iy, &iz, &jx, &jy, &jz, &sx, &sy, &sz, &tx, &ty, &tz);
  302.  
  303.    /*
  304.     *  interpolate!
  305.     */
  306.    m = Hash3d( ix, iy, iz ) & 0xFF;
  307.    px = x-ix;  py = y-iy;  pz = z-iz;
  308.    s = tx*ty*tz;
  309.    result->x = INCRSUM(m,s,px,py,pz);
  310.    result->y = INCRSUM(m+4,s,px,py,pz);
  311.    result->z = INCRSUM(m+8,s,px,py,pz);
  312.  
  313.    m = Hash3d( jx, iy, iz ) & 0xFF;
  314.    px = x-jx;
  315.    s = sx*ty*tz;
  316.    result->x += INCRSUM(m,s,px,py,pz);
  317.    result->y += INCRSUM(m+4,s,px,py,pz);
  318.    result->z += INCRSUM(m+8,s,px,py,pz);
  319.  
  320.    m = Hash3d( jx, jy, iz ) & 0xFF;
  321.    py = y-jy;
  322.    s = sx*sy*tz;
  323.    result->x += INCRSUM(m,s,px,py,pz);
  324.    result->y += INCRSUM(m+4,s,px,py,pz);
  325.    result->z += INCRSUM(m+8,s,px,py,pz);
  326.  
  327.    m = Hash3d( ix, jy, iz ) & 0xFF;
  328.    px = x-ix;
  329.    s = tx*sy*tz;
  330.    result->x += INCRSUM(m,s,px,py,pz);
  331.    result->y += INCRSUM(m+4,s,px,py,pz);
  332.    result->z += INCRSUM(m+8,s,px,py,pz);
  333.  
  334.    m = Hash3d( ix, jy, jz ) & 0xFF;
  335.    pz = z-jz;
  336.    s = tx*sy*sz;
  337.    result->x += INCRSUM(m,s,px,py,pz);
  338.    result->y += INCRSUM(m+4,s,px,py,pz);
  339.    result->z += INCRSUM(m+8,s,px,py,pz);
  340.  
  341.    m = Hash3d( jx, jy, jz ) & 0xFF;
  342.    px = x-jx;
  343.    s = sx*sy*sz;
  344.    result->x += INCRSUM(m,s,px,py,pz);
  345.    result->y += INCRSUM(m+4,s,px,py,pz);
  346.    result->z += INCRSUM(m+8,s,px,py,pz);
  347.  
  348.    m = Hash3d( jx, iy, jz ) & 0xFF;
  349.    py = y-iy;
  350.    s = sx*ty*sz;
  351.    result->x += INCRSUM(m,s,px,py,pz);
  352.    result->y += INCRSUM(m+4,s,px,py,pz);
  353.    result->z += INCRSUM(m+8,s,px,py,pz);
  354.  
  355.    m = Hash3d( ix, iy, jz ) & 0xFF;
  356.    px = x-ix;
  357.    s = tx*ty*sz;
  358.    result->x += INCRSUM(m,s,px,py,pz);
  359.    result->y += INCRSUM(m+4,s,px,py,pz);
  360.    result->z += INCRSUM(m+8,s,px,py,pz);
  361. }
  362.  
  363. DBL Turbulence (x, y, z, octaves)
  364. DBL x, y, z;
  365. int octaves;
  366. {
  367.    int i;                               /* added -dmf */
  368.    register DBL t = 0.0;
  369.    register DBL scale, value;
  370.  
  371.    for (i=0, scale = 1; i < octaves; i++, scale *= 0.5) {
  372.       value = Noise (x/scale, y/scale, z/scale);
  373.       t += FABS (value) * scale;
  374.    }
  375.    return (t);
  376. }
  377.  
  378. void DTurbulence (result, x, y, z,octaves)
  379. VECTOR *result;
  380. DBL x, y, z;
  381. int octaves;
  382. {
  383.    int i;                               /* added -dmf */
  384.    register DBL scale;
  385.    VECTOR value;
  386.  
  387.    result -> x = 0.0;
  388.    result -> y = 0.0;
  389.    result -> z = 0.0;
  390.  
  391.    value.x = value.y = value.z = 0.0;
  392.  
  393.    for (i=0, scale = 1; i < octaves ; i++, scale *= 0.5) {
  394.       DNoise(&value, x/scale, y/scale, z/scale);
  395.       result -> x += value.x * scale;
  396.       result -> y += value.y * scale;
  397.       result -> z += value.z * scale;
  398.    }
  399. }
  400.  
  401. DBL cycloidal (value)
  402. DBL value;
  403. {
  404.    register int indx;
  405.  
  406.    if (value >= 0.0)
  407.    {
  408.       indx = (int)((value - floor (value)) * SINTABSIZE);
  409.       return (sintab [indx]);
  410.    }
  411.    else
  412.    {
  413.       indx = (int)((0.0 - (value + floor (0.0 - value))) * SINTABSIZE);
  414.       return (0.0 - sintab [indx]);
  415.    }
  416. }
  417.  
  418.  
  419. DBL Triangle_Wave (value)
  420. DBL value;
  421. {
  422.    register DBL offset,temp1;
  423.  
  424.    if (value >= 0.0) offset = value - floor(value);
  425.    else {
  426.       temp1 = -1.0 - floor(fabs(value));
  427.       offset = value - temp1;
  428.    }
  429.    if (offset >= 0.5) return (2.0 * (1.0 - offset));
  430.    else return (2.0 * offset);
  431. }
  432.  
  433.    void Translate_Texture (Texture_Ptr, Vector)
  434.       TEXTURE **Texture_Ptr;
  435. VECTOR *Vector;
  436. {
  437.    TEXTURE *Texture = *Texture_Ptr;
  438.    TRANSFORMATION Transformation;
  439.  
  440.    while (Texture != NULL) {
  441.       if (((Texture->Texture_Number != NO_TEXTURE)
  442.          && (Texture->Texture_Number != COLOUR_TEXTURE))
  443.          || (Texture->Bump_Number != NO_BUMPS)) {
  444.  
  445.          if (Texture->Constant_Flag) {
  446.             Texture = Copy_Texture (Texture);
  447.             *Texture_Ptr = Texture;
  448.             Texture->Constant_Flag = FALSE;
  449.          }
  450.  
  451.          if (!Texture -> Texture_Transformation)
  452.             Texture -> Texture_Transformation = Get_Transformation ();
  453.          Get_Translation_Transformation (&Transformation, Vector);
  454.          Compose_Transformations (Texture -> Texture_Transformation,
  455.             &Transformation);
  456.          if (Texture->Texture_Number == CHECKER_TEXTURE_TEXTURE) {
  457.             Translate_Texture ((TEXTURE **) &Texture->Colour1, Vector);
  458.             Translate_Texture ((TEXTURE **) &Texture->Colour2, Vector);
  459.          }
  460.       }
  461.       Texture_Ptr = &Texture->Next_Texture;
  462.       Texture = Texture->Next_Texture;
  463.    }
  464. }
  465.  
  466. void Rotate_Texture (Texture_Ptr, Vector)
  467. TEXTURE **Texture_Ptr;
  468. VECTOR *Vector;
  469. {
  470.    TEXTURE *Texture = *Texture_Ptr;
  471.    TRANSFORMATION Transformation;
  472.  
  473.    while (Texture != NULL) {
  474.       if (((Texture->Texture_Number != NO_TEXTURE)
  475.          && (Texture->Texture_Number != COLOUR_TEXTURE))
  476.          || (Texture->Bump_Number != NO_BUMPS)) {
  477.  
  478.          if (Texture->Constant_Flag) {
  479.             Texture = Copy_Texture (Texture);
  480.             *Texture_Ptr = Texture;
  481.             Texture->Constant_Flag = FALSE;
  482.          }
  483.  
  484.          if (!Texture -> Texture_Transformation)
  485.             Texture -> Texture_Transformation = Get_Transformation ();
  486.          Get_Rotation_Transformation (&Transformation, Vector);
  487.          Compose_Transformations (Texture -> Texture_Transformation,
  488.             &Transformation);
  489.          if (Texture->Texture_Number == CHECKER_TEXTURE_TEXTURE) {
  490.             Rotate_Texture ((TEXTURE **) &Texture->Colour1, Vector);
  491.             Rotate_Texture ((TEXTURE **) &Texture->Colour2, Vector);
  492.          }
  493.       }
  494.       Texture_Ptr = &Texture->Next_Texture;
  495.       Texture = Texture->Next_Texture;
  496.    }
  497. }
  498.  
  499. void Scale_Texture (Texture_Ptr, Vector)
  500. TEXTURE **Texture_Ptr;
  501. VECTOR *Vector;
  502. {
  503.    TEXTURE *Texture = *Texture_Ptr;
  504.    TRANSFORMATION Transformation;
  505.  
  506.    while (Texture != NULL) {
  507.       if (((Texture->Texture_Number != NO_TEXTURE)
  508.          && (Texture->Texture_Number != COLOUR_TEXTURE))
  509.          || (Texture->Bump_Number != NO_BUMPS)) {
  510.  
  511.          if (Texture->Constant_Flag) {
  512.             Texture = Copy_Texture (Texture);
  513.             *Texture_Ptr = Texture;
  514.             Texture->Constant_Flag = FALSE;
  515.          }
  516.  
  517.          if (!Texture -> Texture_Transformation)
  518.             Texture -> Texture_Transformation = Get_Transformation ();
  519.          Get_Scaling_Transformation (&Transformation, Vector);
  520.          Compose_Transformations (Texture -> Texture_Transformation,
  521.             &Transformation);
  522.  
  523.          if (Texture->Texture_Number == CHECKER_TEXTURE_TEXTURE) {
  524.             Scale_Texture ((TEXTURE **) &Texture->Colour1, Vector);
  525.             Scale_Texture ((TEXTURE **) &Texture->Colour2, Vector);
  526.          }
  527.       }
  528.       Texture_Ptr = &Texture->Next_Texture;
  529.       Texture = Texture->Next_Texture;
  530.    }
  531. }
  532.