home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / quakeworld_src / client / d_part.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-17  |  3.9 KB  |  207 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 && !defined(M68KASM)
  49. /*
  50. ==============
  51. D_DrawParticle
  52. ==============
  53. */
  54. void D_DrawParticle (particle_t *pparticle)
  55. {
  56.   vec3_t  local, transformed;
  57.   float zi;
  58.   byte  *pdest;
  59.   short *pz;
  60.   int   i, izi, pix, count, u, v;
  61.  
  62. // transform point
  63.   VectorSubtract (pparticle->org, r_origin, local);
  64.  
  65.   transformed[0] = DotProduct(local, r_pright);
  66.   transformed[1] = DotProduct(local, r_pup);
  67.   transformed[2] = DotProduct(local, r_ppn);    
  68.  
  69.   if (transformed[2] < PARTICLE_Z_CLIP)
  70.     return;
  71.  
  72. // project the point
  73. // FIXME: preadjust xcenter and ycenter
  74.   zi = 1.0 / transformed[2];
  75.   u = (int)(xcenter + zi * transformed[0] + 0.5);
  76.   v = (int)(ycenter - zi * transformed[1] + 0.5);
  77.  
  78.   if ((v > d_vrectbottom_particle) || 
  79.     (u > d_vrectright_particle) ||
  80.     (v < d_vrecty) ||
  81.     (u < d_vrectx))
  82.   {
  83.     return;
  84.   }
  85.  
  86.   pz = d_pzbuffer + (d_zwidth * v) + u;
  87.   pdest = d_viewbuffer + d_scantable[v] + u;
  88.   izi = (int)(zi * 0x8000);
  89.  
  90.   pix = izi >> d_pix_shift;
  91.  
  92.   if (pix < d_pix_min)
  93.     pix = d_pix_min;
  94.   else if (pix > d_pix_max)
  95.     pix = d_pix_max;
  96.  
  97.   switch (pix)
  98.   {
  99.   case 1:
  100.     count = 1 << d_y_aspect_shift;
  101.  
  102.     for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  103.     {
  104.       if (pz[0] <= izi)
  105.       {
  106.         pz[0] = izi;
  107.         pdest[0] = pparticle->color;
  108.       }
  109.     }
  110.     break;
  111.  
  112.   case 2:
  113.     count = 2 << d_y_aspect_shift;
  114.  
  115.     for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  116.     {
  117.       if (pz[0] <= izi)
  118.       {
  119.         pz[0] = izi;
  120.         pdest[0] = pparticle->color;
  121.       }
  122.  
  123.       if (pz[1] <= izi)
  124.       {
  125.         pz[1] = izi;
  126.         pdest[1] = pparticle->color;
  127.       }
  128.     }
  129.     break;
  130.  
  131.   case 3:
  132.     count = 3 << d_y_aspect_shift;
  133.  
  134.     for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  135.     {
  136.       if (pz[0] <= izi)
  137.       {
  138.         pz[0] = izi;
  139.         pdest[0] = pparticle->color;
  140.       }
  141.  
  142.       if (pz[1] <= izi)
  143.       {
  144.         pz[1] = izi;
  145.         pdest[1] = pparticle->color;
  146.       }
  147.  
  148.       if (pz[2] <= izi)
  149.       {
  150.         pz[2] = izi;
  151.         pdest[2] = pparticle->color;
  152.       }
  153.     }
  154.     break;
  155.  
  156.   case 4:
  157.     count = 4 << d_y_aspect_shift;
  158.  
  159.     for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  160.     {
  161.       if (pz[0] <= izi)
  162.       {
  163.         pz[0] = izi;
  164.         pdest[0] = pparticle->color;
  165.       }
  166.  
  167.       if (pz[1] <= izi)
  168.       {
  169.         pz[1] = izi;
  170.         pdest[1] = pparticle->color;
  171.       }
  172.  
  173.       if (pz[2] <= izi)
  174.       {
  175.         pz[2] = izi;
  176.         pdest[2] = pparticle->color;
  177.       }
  178.  
  179.       if (pz[3] <= izi)
  180.       {
  181.         pz[3] = izi;
  182.         pdest[3] = pparticle->color;
  183.       }
  184.     }
  185.     break;
  186.  
  187.   default:
  188.     count = pix << d_y_aspect_shift;
  189.  
  190.     for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
  191.     {
  192.       for (i=0 ; i<pix ; i++)
  193.       {
  194.         if (pz[i] <= izi)
  195.         {
  196.           pz[i] = izi;
  197.           pdest[i] = pparticle->color;
  198.         }
  199.       }
  200.     }
  201.     break;
  202.   }
  203. }
  204.  
  205. #endif  // !id386/!M68KASM
  206.  
  207.