home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / sphsrc / sph_cano.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  1.2 KB  |  50 lines

  1. #include "HEADERS.h"
  2.    /**********************
  3.     *
  4.     File                 * map_to_canon.c
  5.     * calculates npc vertices from uvn vertices
  6.     *
  7.     * changes npc points
  8.     *
  9.     *********************************************************/
  10.    
  11.    /**********************
  12.     *
  13.     Includes          *
  14.     *
  15.     *********************************************************/
  16.    
  17. #include <stdio.h>
  18. #include "sphigslocal.h"
  19. #include <assert.h>
  20.    
  21.    
  22.    /**********************
  23.     *
  24.     Function          * map_to_canon
  25.     *
  26.     * calculates the npc vertices from the uvn vertices
  27.     * negates the z coordinate to keep the same handedness
  28.     *    as the uvn space
  29.     *
  30.     *********************************************************/
  31.    void SPH__map_to_canon (view_spec *vs)
  32. {
  33.    int        count;
  34.    
  35.    /* Allocate space for the npc coords to be generated in */
  36.    
  37.    if (vs->npcVertices)
  38.       free (vs->npcVertices);
  39.    ALLOC_RECORDS (vs->npcVertices, MAT3hvec, vs->vertexArraySize);
  40.    
  41.    /* Map using the view-mapping matrix to get NDC coords */
  42.    
  43.    for (count = 0; count < vs->vertexCount; count++) {
  44.       MAT3mult_hvec
  45.      (vs->npcVertices[count], vs->uvnVertices[count], 
  46.       vs->vm_matrix, 1);
  47.       (vs->npcVertices[count])[Z] *= -1;
  48.    }
  49. }
  50.