Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
pointgr.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** 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, see <http://www.gnu.org/licenses/>.
17*/
18
19/***************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***************************************************************************
22 * *
23 * Project Name : G *
24 * *
25 * $Archive:: /VSS_Sync/ww3d2/pointgr.cpp $*
26 * *
27 * Org Author:: Greg Hjelstrom *
28 * *
29 * $Author:: Kenny Mitchell *
30 * *
31 * $Modtime:: 06/26/02 4:04p $*
32 * *
33 * $Revision:: 38 $*
34 * *
35 * 06/26/02 KM Matrix name change to avoid MAX conflicts *
36 *-------------------------------------------------------------------------*
37 * Functions: *
38 * PointGroupClass::PointGroupClass -- PointGroupClass CTor. *
39 * PointGroupClass::~PointGroupClass -- PointGroupClass DTor. *
40 * PointGroupClass::operator = -- PointGroupClass assignment operator. *
41 * PointGroupClass::Set_Arrays -- Set point location/color/enable arrays.*
42 * PointGroupClass::Set_Point_Size -- Set default point size. *
43 * PointGroupClass::Get_Point_Size -- Get default point size. *
44 * PointGroupClass::Set_Point_Color -- Set default point color. *
45 * PointGroupClass::Get_Point_Color -- Get default point color. *
46 * PointGroupClass::Set_Point_Alpha -- Set default point alpha. *
47 * PointGroupClass::Get_Point_Alpha -- Get default point alpha. *
48 * PointGroupClass::Set_Point_Orientation -- Set default point orientatio*
49 * PointGroupClass::Get_Point_Orientation -- Get default point orientatio*
50 * PointGroupClass::Set_Point_Frame -- Set default point frame. *
51 * PointGroupClass::Get_Point_Frame -- Get default point frame. *
52 * PointGroupClass::Set_Point_Mode -- Set point rendering method. *
53 * PointGroupClass::Get_Point_Mode -- Get point rendering method. *
54 * PointGroupClass::Set_Flag -- Set given flag to on or off. *
55 * PointGroupClass::Get_Flag -- Get current value (on/off) of given flag.*
56 * PointGroupClass::Set_Texture -- Set texture used. *
57 * PointGroupClass::Get_Texture -- Get texture used. *
58 * PointGroupClass::Set_Shader -- Set shader used. *
59 * PointGroupClass::Get_Shader -- Get shader used. *
60 * PointGroupClass::Set_Billboard -- Set whether to billboard. *
61 * PointGroupClass::Get_Billboard -- Get whether to billboard. *
62 * PointGroupClass::Get_Discrete_Orientation_Count_Log2 -- what it says *
63 * PointGroupClass::Set_Discrete_Orientation_Count_Log2 -- what it says. *
64 * PointGroupClass::Get_Frame_Row_Column_Count_Log2 -- what it says *
65 * PointGroupClass::Set_Frame_Row_Column_Count_Log2 -- what it says. *
66 * PointGroupClass::Get_Polygon_Count -- Get estimated polygon count. *
67 * PointGroupClass::Render -- draw point group. *
68 * PointGroupClass::vInstance -- Create instance of class. *
69 * PointGroupClass::sGetClassName -- Get name of class. *
70 * PointGroupClass::Update_Arrays -- Update all arrays used in rendering *
71 * PointGroupClass::Peek_Texture -- Peeks texture *
72 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
73#include "pointgr.h"
74#include "vertmaterial.h"
75#include "ww3d.h"
76#include "aabox.h"
77#include "statistics.h"
78#include "simplevec.h"
79#include "texture.h"
80#include "vector.h"
81#include "vp.h"
82#include "matrix4.h"
83#include "dx8wrapper.h"
84#include "dx8vertexbuffer.h"
85#include "dx8indexbuffer.h"
86#include "rinfo.h"
87#include "camera.h"
88#include "dx8fvf.h"
89#include "D3DXMath.h"
90#include "sortingrenderer.h"
91
92// Upgraded to DX8 2/2/01 HY
93
94// static data members
95Vector3 PointGroupClass::_TriVertexLocationOrientationTable[256][3];
96Vector3 PointGroupClass::_QuadVertexLocationOrientationTable[256][4];
97Vector2 *PointGroupClass::_TriVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL};
98Vector2 *PointGroupClass::_QuadVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL};
99VertexMaterialClass *PointGroupClass::PointMaterial=NULL;
100
101// Static arrays for intermediate calcs (never resized down, just up):
102VectorClass<Vector3> PointGroupClass::compressed_loc; // point locations 'compressed' by APT
103VectorClass<Vector4> PointGroupClass::compressed_diffuse; // point colors 'compressed' by APT
104VectorClass<float> PointGroupClass::compressed_size; // point sizes 'compressed' by APT
105VectorClass<unsigned char> PointGroupClass::compressed_orient; // point orientations 'compressed' by APT
106VectorClass<unsigned char> PointGroupClass::compressed_frame; // point frames 'compressed' by APT
107VectorClass<Vector3> PointGroupClass::transformed_loc; // transformed point locations
108
109// This array has vertex locations for screenspace mode - calculated to cover exactly 1x1 and 2x2 pixels.
110Vector3 PointGroupClass::_ScreenspaceVertexLocationSizeTable[2][3] =
111{
112 Vector3(0.5f, 0.0f, -1.0f),
113 Vector3(1.0f, 1.0f, -1.0f),
114 Vector3(0.0f, 1.0f, -1.0f),
115 Vector3(1.0f, -0.5f, -1.0f),
116 Vector3(2.7f, 2.0f, -1.0f),
117 Vector3(-0.7f, 2.0f, -1.0f)
118};
119
120// useful for particles that aren't aligned with the screen.
121static Vector3 GroundMultiplierX(1.0f, 0.0f, 0.0f);
122static Vector3 GroundMultiplierY(0.0f, 1.0f, 0.0f);
123
124// Some internal variables
125VectorClass<Vector3> VertexLoc; // camera-space vertex locations
126VectorClass<Vector4> VertexDiffuse; // vertex diffuse/alpha colors
127VectorClass<Vector2> VertexUV; // vertex texture coords
128
129// Some DX 8 variables
130#define MAX_VB_SIZE 2048
131#define MAX_TRI_POINTS MAX_VB_SIZE/3
132#define MAX_TRI_IB_SIZE 3*MAX_TRI_POINTS
133#define MAX_QUAD_POINTS MAX_VB_SIZE/4
134#define MAX_QUAD_IB_SIZE 6*MAX_QUAD_POINTS
135
136DX8IndexBufferClass *Tris, *Quads; // Index buffers.
138
139/**************************************************************************
140 * PointGroupClass::PointGroupClass -- PointGroupClass CTor. *
141 * *
142 * INPUT: *
143 * *
144 * OUTPUT: *
145 * *
146 * WARNINGS: *
147 * *
148 * HISTORY: *
149 * 11/17/1998 NH : Created. *
150 *========================================================================*/
152 PointLoc(NULL),
154 APT(NULL),
158 PointCount(0),
160 Texture(NULL),
161 Flags(0),
162 Shader(ShaderClass::_PresetAdditiveSpriteShader),
164 DefaultPointSize(0.0f),
165 DefaultPointColor(1.0f, 1.0f, 1.0f),
166 DefaultPointAlpha(1.0f),
169 VPXMin(0.0f),
170 VPYMin(0.0f),
171 VPXMax(0.0f),
172 VPYMax(0.0f)
173{
174}
175
176/**************************************************************************
177 * PointGroupClass::~PointGroupClass -- PointGroupClass DTor. *
178 * *
179 * INPUT: *
180 * *
181 * OUTPUT: *
182 * *
183 * WARNINGS: *
184 * *
185 * HISTORY: *
186 * 11/17/1998 NH : Created. *
187 *========================================================================*/
189{
190 if (PointLoc) {
191 PointLoc->Release_Ref();
192 PointLoc = NULL;
193 }
194 if (PointDiffuse) {
195 PointDiffuse->Release_Ref();
197 }
198 if (APT) {
199 APT->Release_Ref();
200 APT = NULL;
201 }
202 if (PointSize) {
203 PointSize->Release_Ref();
204 PointSize = NULL;
205 }
206 if (PointOrientation) {
207 PointOrientation->Release_Ref();
209 }
210 if (PointFrame) {
211 PointFrame->Release_Ref();
213 }
214 if (Texture) {
216 Texture = NULL;
217 }
218}
219
220/**************************************************************************
221 * PointGroupClass::operator = -- PointGroupClass assignment operator. *
222 * *
223 * INPUT: *
224 * *
225 * OUTPUT: *
226 * *
227 * WARNINGS: *
228 * *
229 * HISTORY: *
230 * 11/17/1998 NH : Created. *
231 *========================================================================*/
233{
234 if (this != &that) {
235 WWASSERT(0); // If you hit this assert implement the function!
236 }
237 return *this;
238}
239
240
241/**************************************************************************
242 * PointGroupClass::Set_Arrays -- Set point location/color/enable arrays. *
243 * *
244 * INPUT: *
245 * *
246 * OUTPUT: *
247 * *
248 * WARNINGS: *
249 * *
250 * NOTES: colors, alphas, APT, sizes, orientations and frames are *
251 * optional. active_point_count can also be used with a NULL apt.*
252 * In this case active_point_count is ignored if it is -1 *
253 * (default value) and otherwise it indicates the first N active *
254 * points in the arrays. *
255 * The view plane rectangle may optionally be passed as well - *
256 * this is only used in SCREENSPACE mode. *
257 * *
258 * HISTORY: *
259 * 11/17/1998 NH : Created. *
260 * 08/25/1999 NH : Alphas added. *
261 * 06/28/2000 NH : Orientations and frames added. *
262 * 02/08/2001 HY : Upgraded to DX8 *
263 *========================================================================*/
271 int active_point_count,
272 float vpxmin,
273 float vpymin,
274 float vpxmax,
275 float vpymax)
276{
277 // The point locations array is NOT optional!
278 WWASSERT(locs);
279
280 // Ensure lengths of all arrays are the same:
281 WWASSERT(!diffuse || locs->Get_Count() == diffuse->Get_Count());
282 WWASSERT(!apt || locs->Get_Count() == apt->Get_Count());
283 WWASSERT(!sizes || locs->Get_Count() == sizes->Get_Count());
284 WWASSERT(!orientations || locs->Get_Count() == orientations->Get_Count());
285 WWASSERT(!frames || locs->Get_Count() == frames->Get_Count());
286
287 REF_PTR_SET(PointLoc,locs);
288 REF_PTR_SET(PointDiffuse,diffuse);
289 REF_PTR_SET(APT,apt);
290 REF_PTR_SET(PointSize,sizes);
291 REF_PTR_SET(PointOrientation,orientations);
292 REF_PTR_SET(PointFrame,frames);
293
294 if (APT) {
295 PointCount = active_point_count;
296 } else {
297 PointCount = (active_point_count >= 0) ? active_point_count : PointLoc->Get_Count();
298 }
299
300 // Store view plane rectangle (only used in SCREENSPACE mode)
301 VPXMin = vpxmin;
302 VPYMin = vpymin;
303 VPXMax = vpxmax;
304 VPYMax = vpymax;
305}
306
307/**************************************************************************
308 * PointGroupClass::Set_Point_Size -- Set default point size. *
309 * *
310 * INPUT: *
311 * *
312 * OUTPUT: *
313 * *
314 * WARNINGS: This size is ignored if a size array is present. *
315 * *
316 * HISTORY: *
317 * 11/17/1998 NH : Created. *
318 *========================================================================*/
320{
321 DefaultPointSize = size;
322}
323
324
325/**************************************************************************
326 * PointGroupClass::Get_Point_Size -- Get default point size. *
327 * *
328 * INPUT: *
329 * *
330 * OUTPUT: *
331 * *
332 * WARNINGS: This size is ignored if a size array is present. *
333 * *
334 * HISTORY: *
335 * 11/17/1998 NH : Created. *
336 *========================================================================*/
338{
339 return DefaultPointSize;
340}
341
342
343/**************************************************************************
344 * PointGroupClass::Set_Point_Color -- Set default point color. *
345 * *
346 * INPUT: *
347 * *
348 * OUTPUT: *
349 * *
350 * WARNINGS: This color is ignored if a color array is present. *
351 * *
352 * HISTORY: *
353 * 04/20/1999 NH : Created. *
354 *========================================================================*/
359
360/**************************************************************************
361 * PointGroupClass::Get_Point_Color -- Get default point color. *
362 * *
363 * INPUT: *
364 * *
365 * OUTPUT: *
366 * *
367 * WARNINGS: This color is ignored if a color array is present. *
368 * *
369 * HISTORY: *
370 * 04/20/1999 NH : Created. *
371 *========================================================================*/
376
377/**************************************************************************
378 * PointGroupClass::Set_Point_Alpha -- Set default point alpha. *
379 * *
380 * INPUT: *
381 * *
382 * OUTPUT: *
383 * *
384 * WARNINGS: This alpha is ignored if an alpha array is present. *
385 * *
386 * HISTORY: *
387 * 08/25/1999 NH : Created. *
388 *========================================================================*/
390{
391 DefaultPointAlpha = alpha;
392}
393
394
395/**************************************************************************
396 * PointGroupClass::Get_Point_Alpha -- Get default point alpha. *
397 * *
398 * INPUT: *
399 * *
400 * OUTPUT: *
401 * *
402 * WARNINGS: This alpha is ignored if an alpha array is present. *
403 * *
404 * HISTORY: *
405 * 08/25/1999 NH : Created. *
406 *========================================================================*/
408{
409 return DefaultPointAlpha;
410}
411
412
413/**************************************************************************
414 * PointGroupClass::Set_Point_Orientation -- Set default point orientation*
415 * *
416 * INPUT: *
417 * *
418 * OUTPUT: *
419 * *
420 * WARNINGS: This is ignored if an orientation array is present. *
421 * *
422 * NOTE: No need to ensure value in valid range - it will be masked later.*
423 * *
424 * HISTORY: *
425 * 06/28/2000 NH : Created. *
426 *========================================================================*/
427void PointGroupClass::Set_Point_Orientation(unsigned char orientation)
428{
429 DefaultPointOrientation = orientation;
430}
431
432
433/**************************************************************************
434 * PointGroupClass::Get_Point_Orientation -- Get default point orientation*
435 * *
436 * INPUT: *
437 * *
438 * OUTPUT: *
439 * *
440 * WARNINGS: This is ignored if an orientation array is present. *
441 * *
442 * HISTORY: *
443 * 06/28/2000 NH : Created. *
444 *========================================================================*/
446{
448}
449
450
451/**************************************************************************
452 * PointGroupClass::Set_Point_Frame -- Set default point frame. *
453 * *
454 * INPUT: *
455 * *
456 * OUTPUT: *
457 * *
458 * WARNINGS: This frame is ignored if an frame array is present. *
459 * *
460 * NOTE: No need to ensure value in valid range - it will be masked later.*
461 * *
462 * HISTORY: *
463 * 06/28/2000 NH : Created. *
464 *========================================================================*/
465void PointGroupClass::Set_Point_Frame(unsigned char frame)
466{
467 DefaultPointFrame = frame;
468}
469
470
471/**************************************************************************
472 * PointGroupClass::Get_Point_Frame -- Get default point frame. *
473 * *
474 * INPUT: *
475 * *
476 * OUTPUT: *
477 * *
478 * WARNINGS: This frame is ignored if an frame array is present. *
479 * *
480 * HISTORY: *
481 * 06/28/2000 NH : Created. *
482 *========================================================================*/
484{
485 return DefaultPointFrame;
486}
487
488
489/**************************************************************************
490 * PointGroupClass::Set_Point_Mode -- Set point rendering method. *
491 * *
492 * INPUT: *
493 * *
494 * OUTPUT: *
495 * *
496 * WARNINGS: *
497 * *
498 * HISTORY: *
499 * 11/17/1998 NH : Created. *
500 *========================================================================*/
505
506
507/**************************************************************************
508 * PointGroupClass::Get_Point_Mode -- Get point rendering method. *
509 * *
510 * INPUT: *
511 * *
512 * OUTPUT: *
513 * *
514 * WARNINGS: *
515 * *
516 * HISTORY: *
517 * 11/17/1998 NH : Created. *
518 *========================================================================*/
523
524
525/**************************************************************************
526 * Set_Flag -- PointGroupClass::Set given flag to on or off. *
527 * *
528 * INPUT: *
529 * *
530 * OUTPUT: *
531 * *
532 * WARNINGS: *
533 * *
534 * HISTORY: *
535 * 11/17/1998 NH : Created. *
536 *========================================================================*/
538{
539 if (onoff) Flags|=1<<flag;
540 else
541 Flags&=~(1<<flag);
542}
543
544/**************************************************************************
545 * PointGroupClass::Get_Flag -- Get current value (on/off) of given flag. *
546 * *
547 * INPUT: *
548 * *
549 * OUTPUT: *
550 * *
551 * WARNINGS: *
552 * *
553 * HISTORY: *
554 * 11/17/1998 NH : Created. *
555 *========================================================================*/
557{
558 return (Flags>>flag) & 0x1;
559}
560
561/**************************************************************************
562 * PointGroupClass::Set_Texture -- Set texture used. *
563 * *
564 * INPUT: *
565 * *
566 * OUTPUT: *
567 * *
568 * WARNINGS: *
569 * *
570 * HISTORY: *
571 * 11/17/1998 NH : Created. *
572 * 02/08/2001 HY : Upgraded to DX8 *
573 *========================================================================*/
575{
576 REF_PTR_SET(Texture,texture);
577}
578
579/**************************************************************************
580 * PointGroupClass::Get_Texture -- Get texture used. *
581 * *
582 * INPUT: *
583 * *
584 * OUTPUT: *
585 * *
586 * WARNINGS: *
587 * *
588 * HISTORY: *
589 * 11/17/1998 NH : Created. *
590 * 02/08/2001 HY : Upgraded to DX8 *
591 *========================================================================*/
593{
594 if (Texture) Texture->Add_Ref();
595 return Texture;
596}
597
598
599/***********************************************************************************************
600 * PointGroupClass::Peek_Texture -- Peeks texture *
601 * *
602 * *
603 * *
604 * *
605 * INPUT: *
606 * *
607 * OUTPUT: *
608 * *
609 * WARNINGS: *
610 * *
611 * HISTORY: *
612 * 4/12/2001 hy : Created. *
613 *=============================================================================================*/
618
619/**************************************************************************
620 * PointGroupClass::Set_Shader -- Set shader used. *
621 * *
622 * INPUT: *
623 * *
624 * OUTPUT: *
625 * *
626 * WARNINGS: the primary gradient will be set to MODULATE/DISABLE in *
627 * the shader depending on whether a color or alpha array was *
628 * passed in Set_Point_Arrays. also, texturing will be *
629 * enabled or disabled dependent on whether a non-NULL *
630 * texture was set. *
631 * these will override the primary gradient/texturing *
632 * settings in the given shader. *
633 * *
634 * HISTORY: *
635 * 11/17/1998 NH : Created. *
636 * 02/08/2001 HY : Upgraded to DX8 *
637 *========================================================================*/
639{
640 Shader = shader;
641}
642
643
644/**************************************************************************
645 * PointGroupClass::Get_Shader -- Get shader used. *
646 * *
647 * INPUT: *
648 * *
649 * OUTPUT: *
650 * *
651 * WARNINGS: *
652 * *
653 * HISTORY: *
654 * 11/17/1998 NH : Created. *
655 * 02/08/2001 HY : Upgraded to DX8 *
656 *========================================================================*/
661
662/**************************************************************************
663 * PointGroupClass::Set_Billboard -- Set whether to Billboard. *
664 * *
665 * INPUT: *
666 * *
667 * OUTPUT: *
668 * *
669 * WARNINGS: *
670 * *
671 * HISTORY: *
672 * 04/25/2002 JM : Created. *
673 *========================================================================*/
674void PointGroupClass::Set_Billboard(bool shouldBillboard)
675{
676 Billboard = shouldBillboard;
677}
678
679/**************************************************************************
680 * PointGroupClass::Get_Billboard -- Get whether to Billboard. *
681 * *
682 * INPUT: *
683 * *
684 * OUTPUT: *
685 * *
686 * WARNINGS: *
687 * *
688 * HISTORY: *
689 * 04/25/2002 JM : Created. *
690 *========================================================================*/
692{
693 return Billboard;
694}
695
696/**************************************************************************
697 * PointGroupClass::Get_Frame_Row_Column_Count_Log2 -- what it says *
698 * *
699 * INPUT: *
700 * *
701 * OUTPUT: *
702 * *
703 * WARNINGS: *
704 * *
705 * HISTORY: *
706 * 06/28/2000 NH : Created. *
707 * 02/08/2001 HY : Upgraded to DX8 *
708 *========================================================================*/
713
714
715/**************************************************************************
716 * PointGroupClass::Set_Frame_Row_Column_Count_Log2 -- what it says. *
717 * *
718 * INPUT: *
719 * *
720 * OUTPUT: *
721 * *
722 * WARNINGS: *
723 * *
724 * HISTORY: *
725 * 06/28/2000 NH : Created. *
726 * 02/08/2001 HY : Upgraded to DX8 *
727 *========================================================================*/
729{
730 FrameRowColumnCountLog2 = MIN(frccl2, 4);
731}
732
733/**************************************************************************
734 * PointGroupClass::Get_Polygon_Count -- Get estimated polygon count. *
735 * *
736 * INPUT: *
737 * *
738 * OUTPUT: *
739 * *
740 * WARNINGS: *
741 * *
742 * HISTORY: *
743 * 11/18/1998 NH : Created. *
744 * 02/08/2001 HY : Upgraded to DX8 *
745 *========================================================================*/
747{
748 switch (PointMode) {
749 case TRIS:
750 case SCREENSPACE:
751 return PointCount;
752 break;
753 case QUADS:
754 return PointCount * 2;
755 break;
756 }
757 WWASSERT(0);
758 return 0;
759}
760
761/**************************************************************************
762 * PointGroupClass::Render -- draw point group. *
763 * *
764 * INPUT: *
765 * *
766 * OUTPUT: *
767 * *
768 * WARNINGS: *
769 * *
770 * HISTORY: *
771 * 12/10/1998 NH : Created. *
772 * 02/08/2001 HY : Upgraded to DX8 *
773 *========================================================================*/
776{
778 // NB: the winding for pointgroups is wrong, but we
779 // are disabling culling for particles anyway
781
782 // If no points, do nothing:
783 if (PointCount == 0) return;
784
785 WWASSERT(PointLoc && PointLoc->Get_Array());
786
787 // Process texture reductions:
788// if (Texture) Texture->Process_Reduction();
789
790 // Pointers which point into existing buffers (member or static):
791 Vector3 *current_loc = NULL;
792 Vector4 *current_diffuse = NULL;
793 float *current_size = NULL;
794 unsigned char *current_orient = NULL;
795 unsigned char *current_frame = NULL;
796
797 // If there is a color or alpha array enable gradient in shader - otherwise disable.
798 float value_255 = 0.9961f; //254 / 255
799 bool default_white_opaque = ( DefaultPointColor.X > value_255 &&
800 DefaultPointColor.Y > value_255 &&
801 DefaultPointColor.Z > value_255 &&
802 DefaultPointAlpha > value_255);
803
804 // The reason we check for lack of texture here is that SR seems to render black triangles
805 // rather than white triangles as would be expected) when there is no texture AND no gradient.
806 if (PointDiffuse || !default_white_opaque || !Texture) {
807 Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE);
808 } else {
809 Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE);
810 }
811
812 // If Texture is non-NULL enable texturing in shader - otherwise disable.
813 if (Texture) {
815 } else {
817 }
818
819 // If there is an active point table, use it to compress the point
820 // locations/colors/alphas/sizes/orientations/frames.
821 if (APT) {
822 // Resize compressed result arrays if needed (2x guardband to prevent
823 // frequent reallocations):
824
826
827 if (compressed_loc.Length() < PointCount) {
828 compressed_loc.Resize(PointCount * 2);
829 }
830 VectorProcessorClass::CopyIndexed(&compressed_loc[0],
831 PointLoc->Get_Array(), APT->Get_Array(), PointCount);
832 current_loc = &compressed_loc[0];
833 if (PointDiffuse) {
834 if (compressed_diffuse.Length() < PointCount) {
835 compressed_diffuse.Resize(PointCount * 2);
836 }
837 VectorProcessorClass::CopyIndexed(&compressed_diffuse[0],
838 PointDiffuse->Get_Array(), APT->Get_Array(), PointCount);
839 current_diffuse = &compressed_diffuse[0];
840 }
841 if (PointSize) {
842 if (compressed_size.Length() < PointCount) {
843 compressed_size.Resize(PointCount * 2);
844 }
845 VectorProcessorClass::CopyIndexed(&compressed_size[0],
846 PointSize->Get_Array(), APT->Get_Array(), PointCount);
847 current_size = &compressed_size[0];
848 }
849 if (PointOrientation) {
850 if (compressed_orient.Length() < PointCount) {
851 compressed_orient.Resize(PointCount * 2);
852 }
853 VectorProcessorClass::CopyIndexed(&compressed_orient[0],
854 PointOrientation->Get_Array(), APT->Get_Array(), PointCount);
855 current_orient = &compressed_orient[0];
856 }
857 if (PointFrame) {
858 if (compressed_frame.Length() < PointCount) {
859 compressed_frame.Resize(PointCount * 2);
860 }
861 VectorProcessorClass::CopyIndexed(&compressed_frame[0],
862 PointFrame->Get_Array(), APT->Get_Array(), PointCount);
863 current_frame = &compressed_frame[0];
864 }
865 } else {
866 current_loc = PointLoc->Get_Array();
867 if (PointDiffuse) {
868 current_diffuse = PointDiffuse->Get_Array();
869 }
870 if (PointSize) {
871 current_size = PointSize->Get_Array();
872 }
873 if (PointOrientation) {
874 current_orient = PointOrientation->Get_Array();
875 }
876 if (PointFrame) {
877 current_frame = PointFrame->Get_Array();
878 }
879 }
880
881 // Get the world and view matrices
882 Matrix4x4 view;
883 DX8Wrapper::Get_Transform(D3DTS_VIEW,view);
884
885 // Transform the point locations from worldspace to camera space if needed
886 // (i.e. if they are not already in camera space):
887
888 // need to interrupt this processing. If we are not billboarding, then we need the actual position
889 // of the vertice to lay it down flat.
890
891 // (gth) changed this 'if' to use OR rather than AND... The way it was caused all emitters to break
892 if (Get_Flag(TRANSFORM) && Billboard) {
893 // Resize transformed location array if needed (2x guardband to prevent
894 // frequent reallocations):
895 if (transformed_loc.Length() < PointCount) {
896 transformed_loc.Resize(PointCount * 2);
897 }
898 // Not using vector processor class because we are discarding w
899 // Not using T&L in DX8 because we don't want DX8 to transform
900 // 3 times per particle when we can do it once
901 for (int i=0; i<PointCount; i++)
902 {
904 Vector4 result=view*current_loc[i];
905 transformed_loc[i].X=result.X;
906 transformed_loc[i].Y=result.Y;
907 transformed_loc[i].Z=result.Z;
908 }
909 current_loc = &transformed_loc[0];
910 } // if transform
911
912 // Update the arrays with the offsets.
913 int vnum, pnum;
914
915 Update_Arrays(current_loc, current_diffuse, current_size, current_orient, current_frame,
916 PointCount, PointLoc->Get_Count(), vnum, pnum);
917
918 // the locations are now in view space
919 // so set world and view matrices to identity and render
920
921 Matrix4x4 identity(true);
922 DX8Wrapper::Set_Transform(D3DTS_WORLD,identity);
923 DX8Wrapper::Set_Transform(D3DTS_VIEW,identity);
924
925 DX8Wrapper::Set_Material(PointMaterial);
928
929 // Enable sorting if the primitives are translucent and alpha testing is not enabled.
930 const bool sort = (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled());
931
932 IndexBufferClass *indexbuffer;
933 int verticesperprimitive;
934 int current;
935 int delta;
936
938 if (PointMode == QUADS) {
939 verticesperprimitive = 2;
940 indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingQuads) : static_cast <IndexBufferClass*> (Quads);
941 } else {
942 verticesperprimitive = 3;
943 indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingTris) : static_cast <IndexBufferClass*> (Tris);
944 }
945
946 current = 0;
947 while (current<vnum)
948 {
949 delta=MIN(vnum-current,MAX_VB_SIZE);
951
952 // Copy in the data to the VB
953 {
954 DynamicVBAccessClass::WriteLockClass Lock(&PointVerts);
955 int i;
956 unsigned char *vb=(unsigned char*)Lock.Get_Formatted_Vertex_Array();
957 const FVFInfoClass& fvfinfo=PointVerts.FVF_Info();
958
959 for (i = current; i < current + delta; i++)
960 {
964 // Copy Locations
965 *(Vector3*)(vb+fvfinfo.Get_Location_Offset())=VertexLoc[i];
966 if (current_diffuse) {
968 *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=color;
969 }
970 else
971 *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=
973 *(Vector2*)(vb+fvfinfo.Get_Tex_Offset(0))=VertexUV[i];
974 vb+=fvfinfo.Get_FVF_Size();
975 }
976 } // copy
977
978 DX8Wrapper::Set_Index_Buffer (indexbuffer, 0);
980
981 if ( sort )
982 {
983 SortingRendererClass::Insert_Triangles (0, delta / verticesperprimitive, 0, delta);
984 }
985 else
986 {
987 DX8Wrapper::Draw_Triangles (0, delta / verticesperprimitive, 0, delta);
988 }
989
990 current+=delta;
991 } // loop while (current<vnum)
992
993 // restore the matrices
994 DX8Wrapper::Set_Transform(D3DTS_VIEW,view);
995}
996
997
998
999
1000
1001
1002
1003/**************************************************************************
1004 * PointGroupClass::Update_Arrays -- Update all arrays used in rendering *
1005 * *
1006 * INPUT: *
1007 * *
1008 * OUTPUT: *
1009 * *
1010 * WARNINGS: *
1011 * *
1012 * HISTORY: *
1013 * 11/17/1998 NH : Created. *
1014 *========================================================================*/
1016 Vector3 *point_loc,
1017 Vector4 *point_diffuse,
1018 float *point_size,
1019 unsigned char *point_orientation,
1020 unsigned char *point_frame,
1021 int active_points,
1022 int total_points,
1023 int &vnum,
1024 int &pnum)
1025{
1026 int verts_per_point = (PointMode == QUADS) ? 4 : 3;
1027 int polys_per_point = (PointMode == QUADS) ? 2 : 1;
1028
1029 // total_vnum/pnum reflect the size of the point arrays passed to the
1030 // point group. These (instead of vnum/pnum, which reflect the number of
1031 // active points) are used for the resize logic - the idea is that these
1032 // numbers will vary less often than the active numbers.
1033 int total_vnum = verts_per_point * total_points;
1034 vnum = verts_per_point * active_points;
1035 pnum = polys_per_point * active_points;
1036
1037 // Resize the arrays if they are too small. We only need to check the length of one array
1038 // since they always all have the same length.
1039
1041
1042 if (VertexLoc.Length() < total_vnum) {
1043 // Resize arrays (2x guardband to prevent frequent reallocations).
1044 VertexLoc.Resize(total_vnum * 2, false);
1045 VertexUV.Resize(total_vnum * 2, false);
1046 VertexDiffuse.Resize(total_vnum * 2, false);
1047 }
1048
1049 int vert, i, j;
1050
1051 /*
1052 ** Generate the vertex locations from the point locations (note that both are in camera space).
1053 ** Vertex locations depend on the point mode and the points' orientation and size
1054 */
1055
1056 // This defines the loop we run: the LSB indicates whether there is a size override array, the
1057 // next bit indicates whether there is an orientation override array, and the higher bits
1058 // indicate the point mode.
1059 enum LoopSelectionEnum {
1060 TRIS_NOSIZE_NOORIENT = ((int)TRIS << 2) + 0,
1061 TRIS_SIZE_NOORIENT = ((int)TRIS << 2) + 1,
1062 TRIS_NOSIZE_ORIENT = ((int)TRIS << 2) + 2,
1063 TRIS_SIZE_ORIENT = ((int)TRIS << 2) + 3,
1064 QUADS_NOSIZE_NOORIENT = ((int)QUADS << 2) + 0,
1065 QUADS_SIZE_NOORIENT = ((int)QUADS << 2) + 1,
1066 QUADS_NOSIZE_ORIENT = ((int)QUADS << 2) + 2,
1067 QUADS_SIZE_ORIENT = ((int)QUADS << 2) + 3,
1068 SCREEN_NOSIZE_NOORIENT = ((int)SCREENSPACE << 2) + 0,
1069 SCREEN_SIZE_NOORIENT = ((int)SCREENSPACE << 2) + 1,
1070 SCREEN_NOSIZE_ORIENT = ((int)SCREENSPACE << 2) + 2,
1071 SCREEN_SIZE_ORIENT = ((int)SCREENSPACE << 2) + 3,
1072 };
1073 LoopSelectionEnum loop_sel = (LoopSelectionEnum)(((int)PointMode << 2) +
1074 (point_orientation ? 2 : 0) + (point_size ? 1 : 0));
1075
1076 vert = 0;
1077 Vector3 *vertex_loc = &VertexLoc[0];
1078
1079
1081
1082 switch (loop_sel) {
1083
1084 case TRIS_NOSIZE_NOORIENT:
1085 {
1086 // Setup constant vertex offsets (since size and orientation are invariants)
1087 Vector3 scaled_offset[3];
1088 scaled_offset[0] = _TriVertexLocationOrientationTable[DefaultPointOrientation][0] * DefaultPointSize;
1089 scaled_offset[1] = _TriVertexLocationOrientationTable[DefaultPointOrientation][1] * DefaultPointSize;
1090 scaled_offset[2] = _TriVertexLocationOrientationTable[DefaultPointOrientation][2] * DefaultPointSize;
1091
1092 // Add vertex offsets to point locations to get vertex locations
1093 for (i = 0; i < active_points; i++) {
1094 vertex_loc[vert + 0] = point_loc[i] + scaled_offset[0];
1095 vertex_loc[vert + 1] = point_loc[i] + scaled_offset[1];
1096 vertex_loc[vert + 2] = point_loc[i] + scaled_offset[2];
1097 vert += 3;
1098 }
1099 }
1100 break;
1101
1102 case TRIS_SIZE_NOORIENT:
1103 {
1104 // Scale vertex offsets and add them to point locations to get vertex locations
1105 for (i = 0; i < active_points; i++) {
1106 vertex_loc[vert + 0] = point_loc[i] +
1107 _TriVertexLocationOrientationTable[DefaultPointOrientation][0] * point_size[i];
1108 vertex_loc[vert + 1] = point_loc[i] +
1109 _TriVertexLocationOrientationTable[DefaultPointOrientation][1] * point_size[i];
1110 vertex_loc[vert + 2] = point_loc[i] +
1111 _TriVertexLocationOrientationTable[DefaultPointOrientation][2] * point_size[i];
1112 vert += 3;
1113 }
1114 }
1115 break;
1116
1117 case TRIS_NOSIZE_ORIENT:
1118 {
1119 // Scale vertex offsets and add them to point locations to get vertex locations
1120 for (i = 0; i < active_points; i++) {
1121 vertex_loc[vert + 0] = point_loc[i] +
1122 _TriVertexLocationOrientationTable[point_orientation[i]][0] * DefaultPointSize;
1123 vertex_loc[vert + 1] = point_loc[i] +
1124 _TriVertexLocationOrientationTable[point_orientation[i]][1] * DefaultPointSize;
1125 vertex_loc[vert + 2] = point_loc[i] +
1126 _TriVertexLocationOrientationTable[point_orientation[i]][2] * DefaultPointSize;
1127 vert += 3;
1128 }
1129 }
1130 break;
1131
1132 case TRIS_SIZE_ORIENT:
1133 {
1134 // Scale vertex offsets and add them to point locations to get vertex locations
1135 for (i = 0; i < active_points; i++) {
1136 vertex_loc[vert + 0] = point_loc[i] +
1137 _TriVertexLocationOrientationTable[point_orientation[i]][0] * point_size[i];
1138 vertex_loc[vert + 1] = point_loc[i] +
1139 _TriVertexLocationOrientationTable[point_orientation[i]][1] * point_size[i];
1140 vertex_loc[vert + 2] = point_loc[i] +
1141 _TriVertexLocationOrientationTable[point_orientation[i]][2] * point_size[i];
1142 vert += 3;
1143 }
1144 }
1145 break;
1146
1147 case QUADS_NOSIZE_NOORIENT:
1148 {
1149 // Setup constant vertex offsets (since size and orientation are invariants)
1150 Vector3 scaled_offset[4];
1151 scaled_offset[0] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][0] * DefaultPointSize;
1152 scaled_offset[1] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][1] * DefaultPointSize;
1153 scaled_offset[2] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][2] * DefaultPointSize;
1154 scaled_offset[3] = _QuadVertexLocationOrientationTable[DefaultPointOrientation][3] * DefaultPointSize;
1155
1156 // Add vertex offsets to point locations to get vertex locations
1157 for (i = 0; i < active_points; i++) {
1158 vertex_loc[vert + 0] = point_loc[i] + scaled_offset[0];
1159 vertex_loc[vert + 1] = point_loc[i] + scaled_offset[1];
1160 vertex_loc[vert + 2] = point_loc[i] + scaled_offset[2];
1161 vertex_loc[vert + 3] = point_loc[i] + scaled_offset[3];
1162 vert += 4;
1163 }
1164 }
1165 break;
1166
1167 case QUADS_SIZE_NOORIENT:
1168 {
1169 // Scale vertex offsets and add them to point locations to get vertex locations
1170 for (i = 0; i < active_points; i++) {
1171 vertex_loc[vert + 0] = point_loc[i] +
1172 _QuadVertexLocationOrientationTable[DefaultPointOrientation][0] * point_size[i];
1173 vertex_loc[vert + 1] = point_loc[i] +
1174 _QuadVertexLocationOrientationTable[DefaultPointOrientation][1] * point_size[i];
1175 vertex_loc[vert + 2] = point_loc[i] +
1176 _QuadVertexLocationOrientationTable[DefaultPointOrientation][2] * point_size[i];
1177 vertex_loc[vert + 3] = point_loc[i] +
1178 _QuadVertexLocationOrientationTable[DefaultPointOrientation][3] * point_size[i];
1179 vert += 4;
1180 }
1181 }
1182 break;
1183
1184 case QUADS_NOSIZE_ORIENT:
1185 {
1186 // Scale vertex offsets and add them to point locations to get vertex locations
1187 for (i = 0; i < active_points; i++) {
1188 vertex_loc[vert + 0] = point_loc[i] +
1189 _QuadVertexLocationOrientationTable[point_orientation[i]][0] * DefaultPointSize;
1190 vertex_loc[vert + 1] = point_loc[i] +
1191 _QuadVertexLocationOrientationTable[point_orientation[i]][1] * DefaultPointSize;
1192 vertex_loc[vert + 2] = point_loc[i] +
1193 _QuadVertexLocationOrientationTable[point_orientation[i]][2] * DefaultPointSize;
1194 vertex_loc[vert + 3] = point_loc[i] +
1195 _QuadVertexLocationOrientationTable[point_orientation[i]][3] * DefaultPointSize;
1196 vert += 4;
1197 }
1198 }
1199 break;
1200
1201 case QUADS_SIZE_ORIENT:
1202 {
1203 Matrix4x4 view;
1204 Vector4 result;
1205 if (!Billboard) {
1206 DX8Wrapper::Get_Transform(D3DTS_VIEW,view);
1207 }
1208
1209 // Scale vertex offsets and add them to point locations to get vertex locations
1210 for (i = 0; i < active_points; i++) {
1211 if (!Billboard) {
1212 // If we're not billboarding, then the coordinate we have is in screen space.
1213 Matrix4x4 rotMat;
1214 D3DXMatrixRotationZ(&(D3DXMATRIX&) rotMat, ((float)point_orientation[i] / 255.0f * 2 * D3DX_PI));
1215
1216 Vector4 orientedVecX = rotMat * GroundMultiplierX;
1217 Vector4 orientedVecY = rotMat * GroundMultiplierY;
1218
1219 vertex_loc[vert + 0].X = point_loc[i].X + (orientedVecX.X + orientedVecY.X) * point_size[i];
1220 vertex_loc[vert + 0].Y = point_loc[i].Y + (orientedVecX.Y + orientedVecY.Y) * point_size[i];
1221 vertex_loc[vert + 0].Z = point_loc[i].Z;
1222
1223 vertex_loc[vert + 1].X = point_loc[i].X + (orientedVecX.X - orientedVecY.X) * point_size[i];
1224 vertex_loc[vert + 1].Y = point_loc[i].Y + (orientedVecX.Y - orientedVecY.Y) * point_size[i];
1225 vertex_loc[vert + 1].Z = point_loc[i].Z;
1226
1227 vertex_loc[vert + 2].X = point_loc[i].X + -(orientedVecX.X + orientedVecY.X) * point_size[i];
1228 vertex_loc[vert + 2].Y = point_loc[i].Y + -(orientedVecX.Y + orientedVecY.Y) * point_size[i];
1229 vertex_loc[vert + 2].Z = point_loc[i].Z;
1230
1231 vertex_loc[vert + 3].X = point_loc[i].X + (-orientedVecX.X + orientedVecY.X) * point_size[i];
1232 vertex_loc[vert + 3].Y = point_loc[i].Y + (-orientedVecX.Y + orientedVecY.Y) * point_size[i];
1233 vertex_loc[vert + 3].Z = point_loc[i].Z;
1234
1235 // now apply the view transform so that this data is in the format expected
1236 // upon the functions return.
1237 result = view*vertex_loc[vert + 0];
1238 vertex_loc[vert + 0].X = result.X;
1239 vertex_loc[vert + 0].Y = result.Y;
1240 vertex_loc[vert + 0].Z = result.Z;
1241
1242 result = view*vertex_loc[vert + 1];
1243 vertex_loc[vert + 1].X = result.X;
1244 vertex_loc[vert + 1].Y = result.Y;
1245 vertex_loc[vert + 1].Z = result.Z;
1246
1247 result = view*vertex_loc[vert + 2];
1248 vertex_loc[vert + 2].X = result.X;
1249 vertex_loc[vert + 2].Y = result.Y;
1250 vertex_loc[vert + 2].Z = result.Z;
1251
1252 result = view*vertex_loc[vert + 3];
1253 vertex_loc[vert + 3].X = result.X;
1254 vertex_loc[vert + 3].Y = result.Y;
1255 vertex_loc[vert + 3].Z = result.Z;
1256 } else {
1257
1258 vertex_loc[vert + 0] = point_loc[i] +
1259 _QuadVertexLocationOrientationTable[point_orientation[i]][0] * point_size[i];
1260 vertex_loc[vert + 1] = point_loc[i] +
1261 _QuadVertexLocationOrientationTable[point_orientation[i]][1] * point_size[i];
1262 vertex_loc[vert + 2] = point_loc[i] +
1263 _QuadVertexLocationOrientationTable[point_orientation[i]][2] * point_size[i];
1264 vertex_loc[vert + 3] = point_loc[i] +
1265 _QuadVertexLocationOrientationTable[point_orientation[i]][3] * point_size[i];
1266 }
1267 vert += 4;
1268 }
1269 }
1270 break;
1271
1272 // Orientations are ignored for screensize pointgroups
1273 case SCREEN_NOSIZE_NOORIENT:
1274 case SCREEN_NOSIZE_ORIENT:
1275 {
1276 // Offsets need to be scaled to the current screen resolution
1277
1278 // First find x and y scale factors (sizes in pixels need to be
1279 // normalized to 2D cam viewplane of -1,-1 to 1,1)
1280 int xres, yres, bitdepth;
1281 bool windowed;
1282 WW3D::Get_Render_Target_Resolution(xres, yres, bitdepth, windowed);
1283
1284 float x_scale = (VPXMax - VPXMin) / xres;
1285 float y_scale = (VPYMax - VPYMin) / yres;
1286
1287 Vector3 scaled_locs[2][3];
1288 for (int i = 0; i < 2; i++) {
1289 for (int j = 0; j < 3; j++) {
1290 scaled_locs[i][j].X = _ScreenspaceVertexLocationSizeTable[i][j].X * x_scale;
1291 scaled_locs[i][j].Y = _ScreenspaceVertexLocationSizeTable[i][j].Y * y_scale;
1292 scaled_locs[i][j].Z = _ScreenspaceVertexLocationSizeTable[i][j].Z;
1293 }
1294 }
1295
1296 // Add vertex offsets to point locations to get vertex locations
1297 int size_idx = (DefaultPointSize <= 1.0f) ? 0 : 1;
1298 for (i = 0; i < active_points; i++) {
1299 vertex_loc[vert + 0] = point_loc[i] + scaled_locs[size_idx][0];
1300 vertex_loc[vert + 1] = point_loc[i] + scaled_locs[size_idx][1];
1301 vertex_loc[vert + 2] = point_loc[i] + scaled_locs[size_idx][2];
1302 vert += 3;
1303 }
1304 }
1305 break;
1306
1307 case SCREEN_SIZE_NOORIENT:
1308 case SCREEN_SIZE_ORIENT:
1309 {
1310 // Offsets need to be scaled to the current screen resolution
1311
1312 // First find x and y scale factors (sizes in pixels need to be
1313 // normalized to 2D cam viewplane of -1,-1 to 1,1)
1314 int xres, yres, bitdepth;
1315 bool windowed;
1316 WW3D::Get_Render_Target_Resolution(xres, yres, bitdepth, windowed);
1317
1318 float x_scale = (VPXMax - VPXMin) / xres;
1319 float y_scale = (VPYMax - VPYMin) / yres;
1320
1321 Vector3 scaled_locs[2][3];
1322 for (int i = 0; i < 2; i++) {
1323 for (int j = 0; j < 3; j++) {
1324 scaled_locs[i][j].X = _ScreenspaceVertexLocationSizeTable[i][j].X * x_scale;
1325 scaled_locs[i][j].Y = _ScreenspaceVertexLocationSizeTable[i][j].Y * y_scale;
1326 scaled_locs[i][j].Z = _ScreenspaceVertexLocationSizeTable[i][j].Z;
1327 }
1328 }
1329
1330 // Add vertex offsets to point locations to get vertex locations
1331 for (i = 0; i < active_points; i++) {
1332 int size_idx = (point_size[i] <= 1.0f) ? 0 : 1;
1333 vertex_loc[vert + 0] = point_loc[i] + scaled_locs[size_idx][0];
1334 vertex_loc[vert + 1] = point_loc[i] + scaled_locs[size_idx][1];
1335 vertex_loc[vert + 2] = point_loc[i] + scaled_locs[size_idx][2];
1336 vert += 3;
1337 }
1338 }
1339 break;
1340
1341 default:
1342 WWASSERT(0);
1343 break;
1344
1345 }
1346
1347 /*
1348 ** Fill the UV vertex array
1349 */
1350
1351 unsigned int frame_mask = ~(0xFFFFFFFF << (FrameRowColumnCountLog2 + FrameRowColumnCountLog2));// To ensure frames in range
1352 if (point_frame) {
1353
1355
1356 // Fill UV array according to frame override array:
1357 Vector2 *vertex_uv = &VertexUV[0];
1358 if (PointMode != QUADS) {
1359 // Modes with three vertices per point:
1360 Vector2 *uv_ptr = _TriVertexUVFrameTable[FrameRowColumnCountLog2];
1361 int vert = 0;
1362 for (int i = 0; i < active_points; i++) {
1363 int uv_idx = (point_frame[i] & frame_mask) * 3;
1364 vertex_uv[vert++] = uv_ptr[uv_idx + 0];
1365 vertex_uv[vert++] = uv_ptr[uv_idx + 1];
1366 vertex_uv[vert++] = uv_ptr[uv_idx + 2];
1367 }
1368 } else {
1369 // Modes with four vertices per point:
1370 Vector2 *uv_ptr = _QuadVertexUVFrameTable[FrameRowColumnCountLog2];
1371 int vert = 0;
1372 for (int i = 0; i < active_points; i++) {
1373 int uv_idx = (point_frame[i] & frame_mask) * 4;
1374 vertex_uv[vert++] = uv_ptr[uv_idx + 0];
1375 vertex_uv[vert++] = uv_ptr[uv_idx + 1];
1376 vertex_uv[vert++] = uv_ptr[uv_idx + 2];
1377 vertex_uv[vert++] = uv_ptr[uv_idx + 3];
1378 }
1379 }
1380
1381 } else {
1383 // Fill UV array according to frame state:
1384 Vector2 *vertex_uv = &VertexUV[0];
1385 if (PointMode != QUADS) {
1386 // Modes with three vertices per point:
1387 Vector2 *uv_ptr = _TriVertexUVFrameTable[FrameRowColumnCountLog2] + ((DefaultPointFrame & frame_mask) * 3);
1388 int vert = 0;
1389 for (int i = 0; i < active_points; i++) {
1390 vertex_uv[vert++] = uv_ptr[0];
1391 vertex_uv[vert++] = uv_ptr[1];
1392 vertex_uv[vert++] = uv_ptr[2];
1393 }
1394 } else {
1395 // Modes with four vertices per point:
1396 Vector2 *uv_ptr = _QuadVertexUVFrameTable[FrameRowColumnCountLog2] + ((DefaultPointFrame & frame_mask) * 4);
1397 int vert = 0;
1398 for (int i = 0; i < active_points; i++) {
1399 vertex_uv[vert++] = uv_ptr[0];
1400 vertex_uv[vert++] = uv_ptr[1];
1401 vertex_uv[vert++] = uv_ptr[2];
1402 vertex_uv[vert++] = uv_ptr[3];
1403 }
1404 }
1405
1406 }
1407
1408 /*
1409 ** If we have a point color array, fill the vertex diffuse array from it.
1410 */
1413 vert = 0;
1414 if (point_diffuse) {
1415 Vector4* vertex_color = &VertexDiffuse[0];
1416 for (i = 0; i < active_points; i++) {
1417 for (j = 0; j < verts_per_point; j++) {
1418 vertex_color[vert + j] = point_diffuse[i];
1419 }
1420 vert += verts_per_point;
1421 }
1422 }
1423}
1424
1425
1426/**************************************************************************
1427 * PointGroupClass::_Init -- Create static data. *
1428 * *
1429 * INPUT: *
1430 * *
1431 * OUTPUT: *
1432 * *
1433 * WARNINGS: *
1434 * *
1435 * HISTORY: *
1436 * 06/28/2000 NH : Created. *
1437 *========================================================================*/
1439{
1440 int i, j;
1441
1442 /*
1443 ** Fill vertex location orientation tables
1444 */
1445
1446 // Unrotated locations
1447 Vector3 tri_locs[3] = {
1448 Vector3(0.0f, -2.0f, 0.0f),
1449 Vector3(-1.732f, 1.0f, 0.0f),
1450 Vector3(1.732f, 1.0f, 0.0f)
1451 };
1452 Vector3 quad_locs[4] = {
1453 Vector3(-0.5f, 0.5f, 0.0f),
1454 Vector3(-0.5f, -0.5f, 0.0f),
1455 Vector3(0.5f, -0.5f, 0.0f),
1456 Vector3(0.5f, 0.5f, 0.0f)
1457 };
1458
1460
1461 float angle = 0.0f; // In radians
1462 float angle_step = (WWMATH_PI * 2.0f) / 256.0f; // In radians
1463 for (i = 0; i < 256; i++) {
1464 float c = WWMath::Fast_Cos(angle);
1465 float s = WWMath::Fast_Sin(angle);
1466 for (j = 0; j < 3; j++) {
1467 _TriVertexLocationOrientationTable[i][j].X = tri_locs[j].X * c - tri_locs[j].Y * s;
1468 _TriVertexLocationOrientationTable[i][j].Y = tri_locs[j].X * s + tri_locs[j].Y * c;
1469 _TriVertexLocationOrientationTable[i][j].Z = tri_locs[j].Z;
1470 }
1471 for (j = 0; j < 4; j++) {
1472 _QuadVertexLocationOrientationTable[i][j].X = quad_locs[j].X * c - quad_locs[j].Y * s;
1473 _QuadVertexLocationOrientationTable[i][j].Y = quad_locs[j].X * s + quad_locs[j].Y * c;
1474 _QuadVertexLocationOrientationTable[i][j].Z = quad_locs[j].Z;
1475 }
1476 angle += angle_step;
1477 }
1478
1479 /*
1480 ** Fill frame UV tables
1481 */
1482 // Unscaled / untranslated UVs
1483 Vector2 tri_uvs[3] = {
1484 Vector2(0.5f, 0.0f),
1485 Vector2(0.0f, 0.866f),
1486 Vector2(1.0f, 0.866f)
1487 };
1488 Vector2 quad_uvs[4] = {
1489 Vector2(0.0f, 0.0f),
1490 Vector2(0.0f, 1.0f),
1491 Vector2(1.0f, 1.0f),
1492 Vector2(1.0f, 0.0f)
1493 };
1494
1496 for (i = 0; i < 5; i++) {
1497
1498 unsigned int rows = 1 << i;
1499 unsigned int count = rows * rows;
1500
1501 Vector2 *tri_table = _TriVertexUVFrameTable[i] = W3DNEWARRAY Vector2[count * 3];
1502 Vector2 *quad_table = _QuadVertexUVFrameTable[i] = W3DNEWARRAY Vector2[count * 4];
1503
1504 Vector2 corner(0.0f, 0.0f);
1505 float scale = 1.0f / (float)rows;
1506
1507 int tri_idx = 0;
1508 int quad_idx = 0;
1509 for (unsigned int v = 0; v < rows; v++) {
1510 for (unsigned int u = 0; u < rows; u++) {
1511
1512 tri_table[tri_idx++] = corner + (tri_uvs[0] * scale);
1513 tri_table[tri_idx++] = corner + (tri_uvs[1] * scale);
1514 tri_table[tri_idx++] = corner + (tri_uvs[2] * scale);
1515
1516 quad_table[quad_idx++] = corner + (quad_uvs[0] * scale);
1517 quad_table[quad_idx++] = corner + (quad_uvs[1] * scale);
1518 quad_table[quad_idx++] = corner + (quad_uvs[2] * scale);
1519 quad_table[quad_idx++] = corner + (quad_uvs[3] * scale);
1520
1521 corner.X += scale;
1522 }
1523 corner.Y += scale;
1524 corner.X = 0.0f;
1525 }
1526 }
1527
1528 // Create the IBs
1533
1534 // Fill up the IBs
1535 {
1537 unsigned short *ib=locktris.Get_Index_Array();
1538 for (i=0; i<MAX_TRI_IB_SIZE; i++) ib[i]=(unsigned short) i;
1539 }
1540
1541 {
1542 unsigned short vert=0;
1544 unsigned short *ib=lockquads.Get_Index_Array();
1545 vert=0;
1546 for (i=0; i<MAX_QUAD_IB_SIZE; i+=6)
1547 {
1549
1550 ib[i]=vert;
1551 ib[i+1]=vert+1;
1552 ib[i+2]=vert+2;
1553
1554 ib[i+3]=vert+2;
1555 ib[i+4]=vert+3;
1556 ib[i+5]=vert;
1557 vert+=4;
1558 }
1559 }
1560
1561 {
1563 unsigned short *ib=locktris.Get_Index_Array();
1564 for (i=0; i<MAX_TRI_IB_SIZE; i++) ib[i]=(unsigned short) i;
1565 }
1566
1567 {
1568 unsigned short vert=0;
1570 unsigned short *ib=lockquads.Get_Index_Array();
1571 vert=0;
1572 for (i=0; i<MAX_QUAD_IB_SIZE; i+=6)
1573 {
1575 ib[i]=vert;
1576 ib[i+1]=vert+1;
1577 ib[i+2]=vert+2;
1578
1579 ib[i+3]=vert+2;
1580 ib[i+4]=vert+3;
1581 ib[i+5]=vert;
1582 vert+=4;
1583 }
1584 }
1585
1587}
1588
1589
1590/**************************************************************************
1591 * PointGroupClass::_Shutdown -- Destroy static data. *
1592 * *
1593 * INPUT: *
1594 * *
1595 * OUTPUT: *
1596 * *
1597 * WARNINGS: *
1598 * *
1599 * HISTORY: *
1600 * 06/28/2000 NH : Created. *
1601 *========================================================================*/
1603{
1604 for (int i = 0; i < 5; i++) {
1605 delete [] _TriVertexUVFrameTable[i];
1606 delete [] _QuadVertexUVFrameTable[i];
1607 }
1608 REF_PTR_RELEASE(PointMaterial);
1613 transformed_loc.Clear();
1614 VertexLoc.Clear();
1615 VertexDiffuse.Clear();
1616 VertexUV.Clear();
1617}
1618
1619
1620
1621
1622
1623
1624/**************************************************************************
1625 * PointGroupClass::RenderVolumeParticles -- draw a point group.sandwich *
1626 * *
1627 * This is a specialized renderer. It will draw the particle repeatedly *
1628 * while attenuating opacity appropriately, and bumping the z-position. *
1629 * This is actually done by cloning the particle over and over at *
1630 * successively closer positions to the camera. Very Slow! *
1631 * *
1632 * INPUT: *
1633 * *
1634 * OUTPUT: *
1635 * *
1636 * WARNINGS: USE SPARINGLY, IT IS EXPENSIVE!!!!! *
1637 * *
1638 * HISTORY: *
1639 * 12/03/2002 Mark Lorenzen Created. *
1640 * *
1641 *========================================================================*/
1642#define MAX_VOLUME_PARTICLE_DEPTH ( 16 )
1644{
1645
1646 if ( depth <= 1 ) //oops,wrong number
1647 {
1648 Render( rinfo );
1649 return;
1650 }
1651
1652 if ( depth > MAX_VOLUME_PARTICLE_DEPTH )
1653 depth = MAX_VOLUME_PARTICLE_DEPTH; // sanity
1654
1656
1657 if (PointCount == 0)
1658 return;
1659
1660 WWASSERT(PointLoc && PointLoc->Get_Array());
1661
1662 // Pointers which point into existing buffers (member or static):
1663 Vector3 *current_loc = NULL;
1664 Vector4 *current_diffuse = NULL;
1665 float *current_size = NULL;
1666 unsigned char *current_orient = NULL;
1667 unsigned char *current_frame = NULL;
1668
1669 // If there is a color or alpha array enable gradient in shader - otherwise disable.
1670 float value_255 = 0.9961f; //254 / 255
1671 bool default_white_opaque = ( DefaultPointColor.X > value_255 &&
1672 DefaultPointColor.Y > value_255 &&
1673 DefaultPointColor.Z > value_255 &&
1674 DefaultPointAlpha > value_255);
1675
1676 // The reason we check for lack of texture here is that SR seems to render black triangles
1677 // rather than white triangles as would be expected) when there is no texture AND no gradient.
1678 if (PointDiffuse || !default_white_opaque || !Texture) {
1679 Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_MODULATE);
1680 } else {
1681 Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE);
1682 }
1683
1684 // If Texture is non-NULL enable texturing in shader - otherwise disable.
1685 if (Texture) {
1687 } else {
1689 }
1690
1691 // Get the world and view matrices
1692 Matrix4x4 view;
1693 DX8Wrapper::Get_Transform(D3DTS_VIEW,view);
1694
1695
1696
1698 for ( int t = 0; t < depth; ++t )
1699 {
1700
1701
1702
1703
1704
1705 // If there is an active point table, use it to compress the point
1706 // locations/colors/alphas/sizes/orientations/frames.
1707 if (APT) {
1708 // Resize compressed result arrays if needed (2x guardband to prevent
1709 // frequent reallocations):
1710
1712
1713 if (compressed_loc.Length() < PointCount) {
1714 compressed_loc.Resize(PointCount * 2);
1715 }
1716 VectorProcessorClass::CopyIndexed(&compressed_loc[0],
1717 PointLoc->Get_Array(), APT->Get_Array(), PointCount);
1718 current_loc = &compressed_loc[0];
1719 if (PointDiffuse) {
1720 if (compressed_diffuse.Length() < PointCount) {
1721 compressed_diffuse.Resize(PointCount * 2);
1722 }
1723 VectorProcessorClass::CopyIndexed(&compressed_diffuse[0],
1724 PointDiffuse->Get_Array(), APT->Get_Array(), PointCount);
1725 current_diffuse = &compressed_diffuse[0];
1726 }
1727 if (PointSize) {
1728 if (compressed_size.Length() < PointCount) {
1729 compressed_size.Resize(PointCount * 2);
1730 }
1731 VectorProcessorClass::CopyIndexed(&compressed_size[0],
1732 PointSize->Get_Array(), APT->Get_Array(), PointCount);
1733 current_size = &compressed_size[0];
1734 }
1735 if (PointOrientation) {
1736 if (compressed_orient.Length() < PointCount) {
1737 compressed_orient.Resize(PointCount * 2);
1738 }
1739 VectorProcessorClass::CopyIndexed(&compressed_orient[0],
1740 PointOrientation->Get_Array(), APT->Get_Array(), PointCount);
1741 current_orient = &compressed_orient[0];
1742 }
1743 if (PointFrame) {
1744 if (compressed_frame.Length() < PointCount) {
1745 compressed_frame.Resize(PointCount * 2);
1746 }
1747 VectorProcessorClass::CopyIndexed(&compressed_frame[0],
1748 PointFrame->Get_Array(), APT->Get_Array(), PointCount);
1749 current_frame = &compressed_frame[0];
1750 }
1751 } else {
1752 current_loc = PointLoc->Get_Array();
1753 if (PointDiffuse) {
1754 current_diffuse = PointDiffuse->Get_Array();
1755 }
1756 if (PointSize) {
1757 current_size = PointSize->Get_Array();
1758 }
1759 if (PointOrientation) {
1760 current_orient = PointOrientation->Get_Array();
1761 }
1762 if (PointFrame) {
1763 current_frame = PointFrame->Get_Array();
1764 }
1765 }
1766
1767
1768
1769
1770
1771 // Transform the point locations from worldspace to camera space if needed
1772 // (i.e. if they are not already in camera space):
1773
1774 // need to interrupt this processing. If we are not billboarding, then we need the actual position
1775 // of the vertice to lay it down flat.
1776 if (Get_Flag(TRANSFORM) && Billboard) {
1777 // Resize transformed location array if needed (2x guardband to prevent
1778 // frequent reallocations):
1779 if (transformed_loc.Length() < PointCount) {
1780 transformed_loc.Resize(PointCount * 2);
1781 }
1782 // Not using vector processor class because we are discarding w
1783 // Not using T&L in DX8 because we don't want DX8 to transform
1784 // 3 times per particle when we can do it once
1785 float recipDepth = 0.1f / (float)depth;
1786
1787 float shiftInc = ( t * *current_size * recipDepth );
1788
1789 Vector3 volumeLayerShift;
1790 Vector3 cameraPosition = rinfo.Camera.Get_Position();
1791
1792 for (int i=0; i<PointCount; i++)
1793 {
1795 Vector3 cameraToPointDelta;
1796 Vector3::Subtract( cameraPosition, current_loc[i], &cameraToPointDelta );
1797 cameraToPointDelta.Normalize();
1798 cameraToPointDelta.X *= shiftInc;
1799 cameraToPointDelta.Y *= shiftInc;
1800 cameraToPointDelta.Z *= shiftInc;
1801
1802 Vector3 temp;
1803 temp.X = current_loc[i].X + cameraToPointDelta.X;
1804 temp.Y = current_loc[i].Y + cameraToPointDelta.Y;
1805 temp.Z = current_loc[i].Z + cameraToPointDelta.Z;
1806
1807 Vector4 result= view * temp;
1808 transformed_loc[i].X=result.X;
1809 transformed_loc[i].Y=result.Y;
1810 transformed_loc[i].Z=result.Z;
1811 }
1812 current_loc = &transformed_loc[0];
1813 } // if transform
1814
1815 // Update the arrays with the offsets.
1816 int vnum, pnum;
1817
1818 //float attenuator = 1.0f - (1.0f/(float)depth);
1819 //current_diffuse->X *= attenuator;
1820 //current_diffuse->Y *= attenuator;
1821 //current_diffuse->Z *= attenuator;
1822 //current_diffuse->W *= attenuator;
1823
1824 Update_Arrays(current_loc, current_diffuse, current_size, current_orient, current_frame,
1825 PointCount, PointLoc->Get_Count(), vnum, pnum);
1826
1827 // the locations are now in view space
1828 // so set world and view matrices to identity and render
1829
1830 Matrix4x4 identity(true);
1831 DX8Wrapper::Set_Transform(D3DTS_WORLD,identity);
1832 DX8Wrapper::Set_Transform(D3DTS_VIEW,identity);
1833
1834 DX8Wrapper::Set_Material(PointMaterial);
1837
1838 // Enable sorting if the primitives are translucent and alpha testing is not enabled.
1839 const bool sort = (Shader.Get_Dst_Blend_Func() != ShaderClass::DSTBLEND_ZERO) && (Shader.Get_Alpha_Test() == ShaderClass::ALPHATEST_DISABLE) && (WW3D::Is_Sorting_Enabled());
1840
1841 IndexBufferClass *indexbuffer;
1842 int verticesperprimitive;
1843 int current;
1844 int delta;
1845
1847 if (PointMode == QUADS) {
1848 verticesperprimitive = 2;
1849 indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingQuads) : static_cast <IndexBufferClass*> (Quads);
1850 } else {
1851 verticesperprimitive = 3;
1852 indexbuffer = sort ? static_cast <IndexBufferClass*> (SortingTris) : static_cast <IndexBufferClass*> (Tris);
1853 }
1854
1855
1856 float nudge = 0;
1857
1858 current = 0;
1859 while (current<vnum)
1860 {
1861 delta=MIN(vnum-current,MAX_VB_SIZE);
1863
1864 // Copy in the data to the VB
1865 {
1866 DynamicVBAccessClass::WriteLockClass Lock(&PointVerts);
1867 int i;
1868 unsigned char *vb=(unsigned char*)Lock.Get_Formatted_Vertex_Array();
1869 const FVFInfoClass& fvfinfo = PointVerts.FVF_Info();
1870
1871
1872 for (i = current; i < current + delta; i++)
1873 {
1877 // Copy Locations
1878 *(Vector3*)(vb+fvfinfo.Get_Location_Offset()) = VertexLoc[i];
1879
1880 if (current_diffuse) {
1882 *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=color;
1883 }
1884 else
1885 *(unsigned int*)(vb+fvfinfo.Get_Diffuse_Offset())=
1887 *(Vector2*)(vb+fvfinfo.Get_Tex_Offset(0))=VertexUV[i];
1888 vb+=fvfinfo.Get_FVF_Size();
1889 }
1890 } // copy
1891
1892 DX8Wrapper::Set_Index_Buffer (indexbuffer, 0);
1893 DX8Wrapper::Set_Vertex_Buffer (PointVerts);
1894
1896
1897
1898 if ( sort )
1899 SortingRendererClass::Insert_Triangles (0, delta / verticesperprimitive, 0, delta);
1900 else
1901 DX8Wrapper::Draw_Triangles (0, delta / verticesperprimitive, 0, delta);
1902
1903
1904 current+=delta;
1905 } // loop while (current<vnum)
1906
1907
1908
1909 }// next volume layer
1910
1911
1912
1913
1914 // restore the matrices
1915 DX8Wrapper::Set_Transform(D3DTS_VIEW,view);
1916}
#define NULL
Definition BaseType.h:92
Color scale(const Color &a, const Color &b)
Definition GameMtl.cpp:722
#define WWASSERT
#define W3DNEWARRAY
Definition always.h:110
#define MIN(a, b)
Definition always.h:189
#define WWMATH_PI
Definition wwmath.h:56
#define MAX_VOLUME_PARTICLE_DEPTH
Definition ParticleSys.h:64
static void Set_Vertex_Buffer(const VertexBufferClass *vb, unsigned stream=0)
static void Set_Texture(unsigned stage, TextureBaseClass *texture)
static void Set_Index_Buffer(const IndexBufferClass *ib, unsigned short index_base_offset)
static unsigned int Convert_Color_Clamp(const Vector4 &color)
static void Draw_Triangles(unsigned buffer_type, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
static void Set_Material(const VertexMaterialClass *material)
static void Set_Shader(const ShaderClass &shader)
static void Get_Transform(D3DTRANSFORMSTATETYPE transform, Matrix4x4 &m)
static void Set_Transform(D3DTRANSFORMSTATETYPE transform, const Matrix4x4 &m)
VertexFormatXYZNDUV2 * Get_Formatted_Vertex_Array()
const FVFInfoClass & FVF_Info() const
unsigned Get_Tex_Offset(unsigned int n) const
Definition dx8fvf.h:274
unsigned Get_FVF_Size() const
Definition dx8fvf.h:280
unsigned Get_Diffuse_Offset() const
Definition dx8fvf.h:277
unsigned Get_Location_Offset() const
Definition dx8fvf.h:269
void Set_Point_Orientation(unsigned char orientation)
Definition pointgr.cpp:427
virtual ~PointGroupClass(void)
Definition pointgr.cpp:188
void Set_Point_Alpha(float alpha)
Definition pointgr.cpp:389
void Set_Frame_Row_Column_Count_Log2(unsigned char frccl2)
Definition pointgr.cpp:728
unsigned char Get_Point_Orientation(void)
Definition pointgr.cpp:445
unsigned char DefaultPointOrientation
Definition pointgr.h:179
unsigned char DefaultPointFrame
Definition pointgr.h:180
unsigned char FrameRowColumnCountLog2
Definition pointgr.h:167
ShareBufferClass< Vector4 > * PointDiffuse
Definition pointgr.h:159
void Set_Texture(TextureClass *texture)
Definition pointgr.cpp:574
void Set_Shader(ShaderClass shader)
Definition pointgr.cpp:638
static void _Shutdown(void)
Definition pointgr.cpp:1602
TextureClass * Texture
Definition pointgr.h:170
void Render(RenderInfoClass &rinfo)
Definition pointgr.cpp:775
PointModeEnum PointMode
Definition pointgr.h:174
ShareBufferClass< unsigned int > * APT
Definition pointgr.h:160
ShaderClass Get_Shader(void)
Definition pointgr.cpp:657
Vector3 DefaultPointColor
Definition pointgr.h:177
PointGroupClass & operator=(const PointGroupClass &that)
Definition pointgr.cpp:232
void Set_Arrays(ShareBufferClass< Vector3 > *locs, ShareBufferClass< Vector4 > *diffuse=NULL, ShareBufferClass< unsigned int > *apt=NULL, ShareBufferClass< float > *sizes=NULL, ShareBufferClass< unsigned char > *orientations=NULL, ShareBufferClass< unsigned char > *frames=NULL, int active_point_count=-1, float vpxmin=0.0f, float vpymin=0.0f, float vpxmax=0.0f, float vpymax=0.0f)
Definition pointgr.cpp:264
unsigned char Get_Frame_Row_Column_Count_Log2(void)
Definition pointgr.cpp:709
void Set_Point_Color(Vector3 color)
Definition pointgr.cpp:355
void Set_Flag(FlagsType flag, bool onoff)
Definition pointgr.cpp:537
ShareBufferClass< Vector3 > * PointLoc
Definition pointgr.h:158
ShareBufferClass< float > * PointSize
Definition pointgr.h:161
void RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int depth)
Definition pointgr.cpp:1643
float Get_Point_Alpha(void)
Definition pointgr.cpp:407
unsigned char Get_Point_Frame(void)
Definition pointgr.cpp:483
void Set_Point_Size(float size)
Definition pointgr.cpp:319
ShareBufferClass< unsigned char > * PointFrame
Definition pointgr.h:163
PointGroupClass(void)
Definition pointgr.cpp:151
float Get_Point_Size(void)
Definition pointgr.cpp:337
float DefaultPointSize
Definition pointgr.h:176
unsigned int Flags
Definition pointgr.h:175
void Set_Billboard(bool shouldBillboard)
Definition pointgr.cpp:674
TextureClass * Peek_Texture(void)
Definition pointgr.cpp:614
void Set_Point_Frame(unsigned char frame)
Definition pointgr.cpp:465
ShareBufferClass< unsigned char > * PointOrientation
Definition pointgr.h:162
int Get_Flag(FlagsType flag)
Definition pointgr.cpp:556
void Set_Point_Mode(PointModeEnum mode)
Definition pointgr.cpp:501
Vector3 Get_Point_Color(void)
Definition pointgr.cpp:372
TextureClass * Get_Texture(void)
Definition pointgr.cpp:592
int Get_Polygon_Count(void)
Definition pointgr.cpp:746
void Update_Arrays(Vector3 *point_loc, Vector4 *point_diffuse, float *point_size, unsigned char *point_orientation, unsigned char *point_frame, int active_points, int total_points, int &vnum, int &pnum)
Definition pointgr.cpp:1015
float DefaultPointAlpha
Definition pointgr.h:178
PointModeEnum Get_Point_Mode(void)
Definition pointgr.cpp:519
bool Get_Billboard(void)
Definition pointgr.cpp:691
ShaderClass Shader
Definition pointgr.h:171
static void _Init(void)
Definition pointgr.cpp:1438
CameraClass & Camera
Definition rinfo.h:100
Vector3 Get_Position(void) const
Definition rendobj.cpp:508
@ GRADIENT_DISABLE
Definition shader.h:192
@ GRADIENT_MODULATE
Definition shader.h:193
@ TEXTURING_DISABLE
Definition shader.h:219
@ TEXTURING_ENABLE
Definition shader.h:220
@ CULL_MODE_DISABLE
Definition shader.h:158
@ ALPHATEST_DISABLE
Definition shader.h:96
@ DSTBLEND_ZERO
Definition shader.h:172
int Get_Count(void)
Definition sharebuf.h:64
static void Insert_Triangles(const SphereClass &bounding_sphere, unsigned short start_index, unsigned short polygon_count, unsigned short min_vertex_index, unsigned short vertex_count)
float Y
Definition vector2.h:79
float X
Definition vector2.h:74
float X
Definition vector3.h:90
float Z
Definition vector3.h:92
float Y
Definition vector3.h:91
static WWINLINE void Subtract(const Vector3 &a, const Vector3 &b, Vector3 *c)
Definition vector3.h:576
void Normalize(void)
Definition vector3.h:417
float Y
Definition vector4.h:67
float Z
Definition vector4.h:68
float X
Definition vector4.h:66
static void CopyIndexed(unsigned *dst, const unsigned *src, const unsigned int *index, const int count)
Definition vp.cpp:393
static VertexMaterialClass * Get_Preset(PresetType type)
static bool Is_Sorting_Enabled(void)
Definition ww3d.h:220
static void Get_Render_Target_Resolution(int &set_w, int &set_h, int &get_bits, bool &get_windowed)
Definition ww3d.cpp:651
static WWINLINE float Fast_Sin(float val)
Definition wwmath.h:388
static WWINLINE float Fast_Cos(float val)
Definition wwmath.h:435
const unsigned dynamic_fvf_type
@ BUFFER_TYPE_DYNAMIC_DX8
Definition dx8wrapper.h:90
@ BUFFER_TYPE_DYNAMIC_SORTING
Definition dx8wrapper.h:91
#define MAX_TRI_IB_SIZE
Definition pointgr.cpp:132
DX8IndexBufferClass * Tris
Definition pointgr.cpp:136
#define MAX_VB_SIZE
Definition pointgr.cpp:130
SortingIndexBufferClass * SortingQuads
Definition pointgr.cpp:137
DX8IndexBufferClass * Quads
Definition pointgr.cpp:136
VectorClass< Vector3 > VertexLoc
Definition pointgr.cpp:125
VectorClass< Vector4 > VertexDiffuse
Definition pointgr.cpp:126
SortingIndexBufferClass * SortingTris
Definition pointgr.cpp:137
VectorClass< Vector2 > VertexUV
Definition pointgr.cpp:127
#define MAX_QUAD_IB_SIZE
Definition pointgr.cpp:134
#define REF_PTR_RELEASE(x)
Definition refcount.h:80
#define REF_PTR_SET(dst, src)
Definition refcount.h:79
#define NEW_REF(C, P)
Definition refcount.h:62
unsigned char flag
Definition vchannel.cpp:273