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