home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 15 / MA_Cover_15.iso / source / winquake / d_part.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-03  |  3.6 KB  |  210 lines

  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  12.  
  13. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. */
  20. // d_part.c: software driver module for drawing particles
  21.  
  22. #include "quakedef.h"
  23. #include "d_local.h"
  24.  
  25.  
  26. /*
  27. ==============
  28. D_EndParticles
  29. ==============
  30. */
  31. void D_EndParticles (void)
  32. {
  33. // not used by software driver
  34. }
  35.  
  36.  
  37. /*
  38. ==============
  39. D_StartParticles
  40. ==============
  41. */
  42. void D_StartParticles (void)
  43. {
  44. // not used by software driver
  45. }
  46.  
  47.  
  48. #if    !id386
  49. #if !id68k
  50.  
  51. /*
  52. ==============
  53. D_DrawParticle
  54. ==============
  55. */
  56. void D_DrawParticle (particle_t *pparticle)
  57. {
  58.     vec3_t    local, transformed;
  59.     float    zi;
  60.     byte    *pdest;
  61.     short    *pz;
  62.     int        i, izi, pix, count, u, v;
  63.  
  64. // transform point
  65.     VectorSubtract (pparticle->org, r_origin, local);
  66.  
  67.     transformed[0] = DotProduct(local, r_pright);
  68.     transformed[1] = DotProduct(local, r_pup);
  69.     transformed[2] = DotProduct(local, r_ppn);        
  70.  
  71.     if (transformed[2] < PARTICLE_Z_CLIP)
  72.         return;
  73.  
  74. // project the point
  75. // FIXME: preadjust xcenter and ycenter
  76.     zi = 1.0 / transformed[2];
  77.     u = (int)(xcenter + zi * transformed[0] + 0.5);
  78.     v = (int)(ycenter - zi * transformed[1] + 0.5);
  79.  
  80.     if ((v > d_vrectbottom_particle) || 
  81.         (u > d_vrectright_particle) ||
  82.         (v < d_vrecty) ||
  83.         (u < d_vrectx))
  84.     {
  85.         return;
  86.     }
  87.  
  88.     pz = d_pzbuffer + (d_zwidth * v) + u;
  89.     pdest = d_viewbuffer + d_scantable[v] + u;
  90.     izi = (int)(zi * 0x8000);
  91.  
  92.     pix = izi >> d_pix_shift;
  93.  
  94.     if (pix < d_pix_min)
  95.         pix = d_pix_min;
  96.     else if (pix > d_pix_max)
  97.         pix = d_pix_max;
  98.  
  99.     switch (pix)
  100.     {
  101.     case 1:
  102.         count = 1 << d_y_aspect_shift;
  103.  
  104.         for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  105.         {
  106.             if (pz[0] <= izi)
  107.             {
  108.                 pz[0] = izi;
  109.                 pdest[0] = pparticle->color;
  110.             }
  111.         }
  112.         break;
  113.  
  114.     case 2:
  115.         count = 2 << d_y_aspect_shift;
  116.  
  117.         for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  118.         {
  119.             if (pz[0] <= izi)
  120.             {
  121.                 pz[0] = izi;
  122.                 pdest[0] = pparticle->color;
  123.             }
  124.  
  125.             if (pz[1] <= izi)
  126.             {
  127.                 pz[1] = izi;
  128.                 pdest[1] = pparticle->color;
  129.             }
  130.         }
  131.         break;
  132.  
  133.     case 3:
  134.         count = 3 << d_y_aspect_shift;
  135.  
  136.         for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  137.         {
  138.             if (pz[0] <= izi)
  139.             {
  140.                 pz[0] = izi;
  141.                 pdest[0] = pparticle->color;
  142.             }
  143.  
  144.             if (pz[1] <= izi)
  145.             {
  146.                 pz[1] = izi;
  147.                 pdest[1] = pparticle->color;
  148.             }
  149.  
  150.             if (pz[2] <= izi)
  151.             {
  152.                 pz[2] = izi;
  153.                 pdest[2] = pparticle->color;
  154.             }
  155.         }
  156.         break;
  157.  
  158.     case 4:
  159.         count = 4 << d_y_aspect_shift;
  160.  
  161.         for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  162.         {
  163.             if (pz[0] <= izi)
  164.             {
  165.                 pz[0] = izi;
  166.                 pdest[0] = pparticle->color;
  167.             }
  168.  
  169.             if (pz[1] <= izi)
  170.             {
  171.                 pz[1] = izi;
  172.                 pdest[1] = pparticle->color;
  173.             }
  174.  
  175.             if (pz[2] <= izi)
  176.             {
  177.                 pz[2] = izi;
  178.                 pdest[2] = pparticle->color;
  179.             }
  180.  
  181.             if (pz[3] <= izi)
  182.             {
  183.                 pz[3] = izi;
  184.                 pdest[3] = pparticle->color;
  185.             }
  186.         }
  187.         break;
  188.  
  189.     default:
  190.         count = pix << d_y_aspect_shift;
  191.  
  192.         for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  193.         {
  194.             for (i=0 ; i<pix ; i++)
  195.             {
  196.                 if (pz[i] <= izi)
  197.                 {
  198.                     pz[i] = izi;
  199.                     pdest[i] = pparticle->color;
  200.                 }
  201.             }
  202.         }
  203.         break;
  204.     }
  205. }
  206.  
  207. #endif
  208. #endif    // !id386
  209.  
  210.