Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
dazzle.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 : WW3D *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/dazzle.cpp $*
26 * *
27 * Original Author:: Jani Penttinen *
28 * *
29 * $Author:: Kenny Mitchell *
30 * *
31 * $Modtime:: 06/26/02 4:04p $*
32 * *
33 * $Revision:: 32 $*
34 * *
35 * 06/26/02 KM Matrix name change to avoid MAX conflicts *
36 *---------------------------------------------------------------------------------------------*
37 * Functions: *
38 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39
40
41#include "dazzle.h"
42#include "simplevec.h"
43#include "vector2.h"
44#include "camera.h"
45#include "ww3d.h"
46#include "wwstring.h"
47#include "wwdebug.h"
48#include "assetmgr.h"
49#include "vector3i.h"
50#include "quat.h"
51#include "ini.h"
52#include "point.h"
53#include "rinfo.h"
54#include "vertmaterial.h"
55#include "chunkio.h"
56#include "wwfile.h"
57#include "inisup.h"
58#include "persistfactory.h"
59#include "ww3dids.h"
60#include "dx8wrapper.h"
61#include "dx8vertexbuffer.h"
62#include "dx8indexbuffer.h"
63#include "sortingrenderer.h"
64#include "texture.h"
65#include "scene.h"
66#include "wwprofile.h"
67#include "visrasterizer.h"
68#include <cstdio>
69#include <limits.h>
70#include <wwprofile.h>
71
72
73// All dazzle types appear under Dazzles_List in the dazzle.ini file.
74const char* DAZZLE_LIST_STRING="Dazzles_List";
75
76// After the dot product between the camera direction and the camera space location of the light source,
77// we do a power to Halopow for the halo size and power to DazzlePow for the dazzle size. Halo/DazzleArea
78// defines the angle where the values are valid, so any angle beyond HaloArea/DazzleArea results the halo or
79// dazzle being scaled to zero. The angles are re-scaled from normalized angle scale of (-1.0...1.0)
80// only HaloArea/DazzleArea defined part is used.
81const char* DAZZLE_INTENSITY_POW_STRING = "DazzleIntensityPow";
82const char* DAZZLE_SIZE_POW_STRING = "DazzleSizePow";
83const char* DAZZLE_AREA_STRING = "DazzleArea"; // Something like 0.05 is a good starting point for a dazzle...
84const char* HALO_INTENSITY_POW = "HaloIntensityPow";
85
86// Halo and dazzle are scaled by these values
87const char* HALO_SCALE_X_STRING = "HaloScaleX";
88const char* HALO_SCALE_Y_STRING = "HaloScaleY";
89const char* DAZZLE_SCALE_X_STRING = "DazzleScaleX";
90const char* DAZZLE_SCALE_Y_STRING = "DazzleScaleY";
91
92// Dazzle and halo intensity control the base intensities.
93const char* HALO_INTENSITY_STRING = "HaloIntensity";
94const char* DAZZLE_INTENSITY_STRING = "DazzleIntensity";
95
96// Direction area defines the maximum difference between the light direction and the eyespace location,
97// so the dazzle can only be seen if the camera is inside the light cone. Value 0.0 means dazzle is not
98// directional, it can be seen from any direction. Halo is not affected. Dazzle direction defines the light
99// direction vector.
100const char* DAZZLE_DIRECTION_AREA_STRING = "DazzleDirectionArea"; // Something like 0.5 might be a good test value
101const char* DAZZLE_DIRECTION_STRING = "DazzleDirection";
102
103// Dazzle and halo start to afde out after FadeoutStart meters and are completely gone by FadeoutEnd meters.
104const char* FADEOUT_START_STRING = "FadeoutStart";
105const char* FADEOUT_END_STRING = "FadeoutEnd";
106
107// To be done: This parameter needs to be redefined.
108const char* SIZE_OPTIMIZATION_LIMIT_STRING = "SizeOptimizationLimit";
109
110// The weight of history for the intensities. The history weight is per millisecond, so if you want to have
111// any real history, values higher than 0.95 are recommended (don't use value of 1.0 or anything higher!)
112const char* HISTORY_WEIGHT_STRING = "HistoryWeight";
113
114// Textures to be used.
115const char* DAZZLE_TEXTURE_STRING = "DazzleTextureName";
116const char* HALO_TEXTURE_STRING = "HaloTextureName";
117
118// If false, camera matrix's translation term isn't used. If translation isn't used the dazzle is treated as
119// always visible, scene graph visibility is not used.
120const char* USE_CAMERA_TRANSLATION = "UseCameraTranslation";
121
122// Halo and dazzle colors, RGB, (1.0, 1.0, 1.0) is white and (0.0, 0.0, 0.0) is black
123const char* HALO_COLOR_STRING = "HaloColor";
124const char* DAZZLE_COLOR_STRING = "DazzleColor";
125
126// Dazzle test color could be white in many cases but if the level has a lot of white then another color can be defined.
127const char* DAZZLE_TEST_COLOR_STRING = "DazzleTestColor";
128
129// Dazzles can blink on and off. The blink period defines the time for one cycle, the blink "on time" defines
130// the amount of time within that period that the dazzle is "on"
131const char* BLINK_PERIOD_STRING = "BlinkPeriod";
132const char* BLINK_ON_TIME_STRING = "BlinkOnTime";
133
134// Dazzle can use a lensflare by defining a name of lensflare in the ini
135const char* DAZZLE_LENSFLARE_STRING = "LensflareName";
136
137// Lensflare definitions
138const char* LENSFLARE_LIST_STRING = "Lensflares_List";
139
140// Texture to be used by the lensflare
141const char* LENSFLARE_TEXTURE_STRING = "TextureName";
142
143// The number of flare sprites in lensflare. The FlareLocation, FlareSize and FlareColor paremeters are procedural, the
144// names are produced based on this parameter. If FlareCount is 3, there exists FlareLocation1, FlareLocation2 and
145// FlareLocation3... And so on.
146const char* FLARE_COUNT_STRING = "FlareCount";
147
148// 1D-locations of the flares. 0.0 means the location of the center of the screen and 1.0 means the location of the
149// lightsource. The values can be smaller than zero and larger than 1.0.
150const char* FLARE_LOCATION_STRING = "FlareLocation";
151
152// Normalized flare sizes
153const char* FLARE_SIZE_STRING = "FlareSize";
154
155// Colors for each flare sprite
156const char* FLARE_COLOR_STRING = "FlareColor";
157
158// Uv coordinates (as there can be only one texture used, but one may want multiple images). The values is a 4-float
159// vector: start_u, start_v, end_u, end_v.
160const char* FLARE_UV_STRING = "FlareUV";
161
162// Radius of dazzle used for raycast tests
163const char * RADIUS_STRING = "Radius";
164
165
166/*
167; DAZZLE.INI example
168
169[Lensflares_List]
1700=DEFAULT_LENSFLARE
171
172[Dazzles_List]
1730=DEFAULT
174
175;========================================== LENSFLARE DEFINITIONS =================
176
177[DEFAULT_LENSFLARE]
178TextureName=dazzle_secondary.jpg
179FlareCount=5
180FlareLocation1=0.1
181FlareLocation2=0.5
182FlareLocation3=1.1
183FlareLocation4=1.5
184FlareLocation5=-0.4
185FlareSize1=0.1
186FlareSize2=0.05
187FlareSize3=0.08
188FlareSize4=0.15
189FlareSize5=0.10
190FlareColor1=1.0,0.5,0.5
191FlareColor2=0.5,1.0,0.5
192FlareColor3=0.5,0.5,1.0
193FlareColor4=0.5,0.5,1.0
194FlareColor5=0.5,0.5,1.0
195
196
197;========================================== DAZZLE DEFINITIONS ====================
198
199[DEFAULT]
200HaloIntensity=1.0
201HaloIntensityPow=0.95
202HaloSizePow=0.95
203HaloArea=1.0
204HaloScaleX=0.2
205HaloScaleY=0.2
206DazzleArea=0.05
207DazzleDirectionArea=0
208DazzleDirection=0,1,1
209DazzleSizePow=0.9
210DazzleIntensityPow=0.9
211DazzleIntensity=50
212DazzleScaleX=1.0
213DazzleScaleY=1.0
214FadeoutStart=30.0
215FadeoutEnd=40.0
216SizeOptimizationLimit=0.05
217HistoryWeight=0.975
218UseCameraTranslation=1
219DazzleTextureName=dazzle_primary.jpg
220HaloTextureName=dazzle_secondary.jpg
221DazzleColor=1,1,1
222HaloColor=0,0,1
223DazzleTestColor=1,1,1
224LensflareName=DEFAULT_LENSFLARE
225*/
226
227// Global instance of a dazzle loader
229
231
232static DazzleTypeClass** types;
233static unsigned type_count;
234
235// Current dazzle layer - must be set before rendering
236static DazzleLayerClass * current_dazzle_layer = NULL;
237
238static LensflareTypeClass** lensflares;
239static unsigned lensflare_count;
240
241static ShaderClass default_dazzle_shader;
242static ShaderClass default_halo_shader;
243static ShaderClass vis_shader;
244static ShaderClass debug_shader;
245
246// static instance of a default dazzle visibility handler
247static DazzleVisibilityClass _DefaultVisibilityHandler;
248static const DazzleVisibilityClass * _VisibilityHandler = &_DefaultVisibilityHandler;
249
250bool DazzleRenderObjClass::_dazzle_rendering_enabled = true;
251
252
253static void Init_Shaders()
254{
255 default_dazzle_shader.Set_Cull_Mode( ShaderClass::CULL_MODE_DISABLE );
256 default_dazzle_shader.Set_Depth_Mask( ShaderClass::DEPTH_WRITE_DISABLE );
257 default_dazzle_shader.Set_Depth_Compare( ShaderClass::PASS_ALWAYS );
258 default_dazzle_shader.Set_Dst_Blend_Func( ShaderClass::DSTBLEND_ONE );
259 default_dazzle_shader.Set_Src_Blend_Func( ShaderClass::SRCBLEND_ONE );
260 default_dazzle_shader.Set_Fog_Func( ShaderClass::FOG_DISABLE );
261 default_dazzle_shader.Set_Primary_Gradient( ShaderClass::GRADIENT_MODULATE );
262 default_dazzle_shader.Set_Texturing( ShaderClass::TEXTURING_ENABLE );
263
264 default_halo_shader.Set_Cull_Mode( ShaderClass::CULL_MODE_DISABLE );
265 default_halo_shader.Set_Depth_Mask( ShaderClass::DEPTH_WRITE_DISABLE );
266 default_halo_shader.Set_Depth_Compare( ShaderClass::PASS_LEQUAL );
267 default_halo_shader.Set_Dst_Blend_Func( ShaderClass::DSTBLEND_ONE );
268 default_halo_shader.Set_Src_Blend_Func( ShaderClass::SRCBLEND_ONE );
269 default_halo_shader.Set_Fog_Func( ShaderClass::FOG_DISABLE );
270 default_halo_shader.Set_Primary_Gradient( ShaderClass::GRADIENT_MODULATE );
271 default_halo_shader.Set_Texturing( ShaderClass::TEXTURING_ENABLE );
272
273 vis_shader.Set_Cull_Mode( ShaderClass::CULL_MODE_DISABLE );
274 vis_shader.Set_Depth_Mask( ShaderClass::DEPTH_WRITE_DISABLE );
275 vis_shader.Set_Dst_Blend_Func( ShaderClass::DSTBLEND_ZERO );
276 vis_shader.Set_Src_Blend_Func( ShaderClass::SRCBLEND_ONE );
277 vis_shader.Set_Fog_Func( ShaderClass::FOG_DISABLE );
278 vis_shader.Set_Primary_Gradient( ShaderClass::GRADIENT_MODULATE );
279 vis_shader.Set_Texturing( ShaderClass::TEXTURING_DISABLE );
280
281 debug_shader.Set_Cull_Mode( ShaderClass::CULL_MODE_DISABLE );
282 debug_shader.Set_Depth_Mask( ShaderClass::DEPTH_WRITE_DISABLE );
283 debug_shader.Set_Dst_Blend_Func( ShaderClass::DSTBLEND_SRC_ALPHA );
284 debug_shader.Set_Src_Blend_Func( ShaderClass::SRCBLEND_ONE );
285 debug_shader.Set_Fog_Func( ShaderClass::FOG_DISABLE );
286 debug_shader.Set_Primary_Gradient( ShaderClass::GRADIENT_MODULATE );
287 debug_shader.Set_Texturing( ShaderClass::TEXTURING_DISABLE );
288
289}
290
291/*
292** Derived INI to support Vector4
293*/
294class DazzleINIClass : public INIClass {
295public:
297 const Vector2 Get_Vector2(char const *section, char const *entry, const Vector2 & defvalue = Vector2(0,0) );
298 const Vector3 Get_Vector3(char const *section, char const *entry, const Vector3 & defvalue = Vector3(0,0,0) );
299 const Vector4 Get_Vector4(char const *section, char const *entry, const Vector4 & defvalue = Vector4(0,0,0,0) ) const;
300};
301
302const Vector2 DazzleINIClass::Get_Vector2(char const *section, char const *entry, const Vector2 & defvalue)
303{
304 if (section != NULL && entry != NULL) {
305 INIEntry * entryptr = Find_Entry(section, entry);
306 if (entryptr && entryptr->Value != NULL) {
307 Vector2 ret;
308 if ( sscanf( entryptr->Value, "%f,%f", &ret[0], &ret[1], &ret[2] ) == 2 ) {
309 return ret;
310 }
311 }
312 }
313 return defvalue;
314}
315
316const Vector3 DazzleINIClass::Get_Vector3(char const *section, char const * entry, const Vector3 & defvalue )
317{
318 if (section != NULL && entry != NULL) {
319 INIEntry * entryptr = Find_Entry(section, entry);
320 if (entryptr && entryptr->Value != NULL) {
321 Vector3 ret;
322 if ( sscanf( entryptr->Value, "%f,%f,%f", &ret[0], &ret[1], &ret[2] ) == 3 ) {
323 return ret;
324 }
325 }
326 }
327 return defvalue;
328}
329
330const Vector4 DazzleINIClass::Get_Vector4(char const *section, char const *entry, const Vector4 & defvalue) const
331{
332 if (section != NULL && entry != NULL) {
333 INIEntry * entryptr = Find_Entry(section, entry);
334 if (entryptr && entryptr->Value != NULL) {
335 Vector4 ret;
336 if ( sscanf( entryptr->Value, "%f,%f,%f,%f", &ret[0], &ret[1], &ret[2], &ret[3] ) == 4 ) {
337 return ret;
338 }
339 }
340 }
341 return defvalue;
342}
343
344// ----------------------------------------------------------------------------
345
346LensflareTypeClass::LensflareTypeClass(const LensflareInitClass& is)
347 :
348 lic(is),
349 texture(NULL)
350{
351}
352
353LensflareTypeClass::~LensflareTypeClass()
354{
355 REF_PTR_RELEASE(texture);
356}
357
359{
360 if (!texture) {
361 texture = WW3DAssetManager::Get_Instance()->Get_Texture(lic.texture_name);
362 SET_REF_OWNER(texture);
363 }
364 return texture;
365}
366
368 VertexFormatXYZNDUV2* vertex,
369 int& vertex_count,
370 float screen_x_scale,
371 float screen_y_scale,
372 float dazzle_intensity,
373 const Vector4& transformed_location)
374{
375// Lensflares are placed on a line 2D that goes through the lightsource and the center of the screen
376// float scale=sqrt(transformed_location[0]*transformed_location[0]+transformed_location[1]*transformed_location[1]);
377
378 float z=transformed_location[2];
379
380 float distance_multiplier=sqrt(transformed_location[0]*transformed_location[0]+transformed_location[1]*transformed_location[1])+1.0f;
381
382 for (int a=0;a<lic.flare_count;++a) {
383 float x=lic.flare_locations[a]*transformed_location[0];
384 float y=lic.flare_locations[a]*transformed_location[1];
385 float size=lic.flare_sizes[a]*distance_multiplier;
386 float ix=size*screen_x_scale;
387 float iy=size*screen_y_scale;
388
389 Vector3 col=lic.flare_colors[a]*dazzle_intensity;
390 if (col[0]>1.0f) col[0]=1.0f;
391 if (col[1]>1.0f) col[1]=1.0f;
392 if (col[2]>1.0f) col[2]=1.0f;
393 unsigned color=DX8Wrapper::Convert_Color(col,1.0f);
394
395 vertex->x=x+ix;
396 vertex->y=y-iy;
397 vertex->z=z;
398 vertex->u1=lic.flare_uv[a][0];
399 vertex->v1=lic.flare_uv[a][1];
400 vertex->diffuse=color;
401 vertex++;
402
403 vertex->x=x+ix;
404 vertex->y=y+iy;
405 vertex->z=z;
406 vertex->u1=lic.flare_uv[a][2];
407 vertex->v1=lic.flare_uv[a][1];
408 vertex->diffuse=color;
409 vertex++;
410
411 vertex->x=x-ix;
412 vertex->y=y+iy;
413 vertex->z=z;
414 vertex->u1=lic.flare_uv[a][2];
415 vertex->v1=lic.flare_uv[a][3];
416 vertex->diffuse=color;
417 vertex++;
418
419 vertex->x=x-ix;
420 vertex->y=y-iy;
421 vertex->z=z;
422 vertex->u1=lic.flare_uv[a][0];
423 vertex->v1=lic.flare_uv[a][3];
424 vertex->diffuse=color;
425 vertex++;
426
427 vertex_count+=4;
428 }
429}
430
431// ----------------------------------------------------------------------------
432
433DazzleTypeClass::DazzleTypeClass(const DazzleInitClass& is)
434 :
435 ic(is),
436 dazzle_shader(default_dazzle_shader),
437 halo_shader(default_halo_shader),
438 primary_texture(NULL),
439 secondary_texture(NULL),
440 lensflare_id(DazzleRenderObjClass::Get_Lensflare_ID(is.lensflare_name)),
441 radius(is.radius)
442{
443 fadeout_end_sqr=ic.fadeout_end*ic.fadeout_end;
444 fadeout_start_sqr=ic.fadeout_start*ic.fadeout_start;
445 dazzle_test_color_integer=
446 0xff000000|
447 (unsigned(255.0f*ic.dazzle_test_color[2])<<16)|
448 (unsigned(255.0f*ic.dazzle_test_color[1])<<8)|
449 (unsigned(255.0f*ic.dazzle_test_color[0]));
450 dazzle_test_mask_integer=dazzle_test_color_integer&0xf8f8f8f8;
451}
452
453DazzleTypeClass::~DazzleTypeClass()
454{
455 REF_PTR_RELEASE(primary_texture);
456 REF_PTR_RELEASE(secondary_texture);
457}
458
459// ----------------------------------------------------------------------------
460
461void DazzleTypeClass::Set_Dazzle_Shader(const ShaderClass& s) // Set shader for the dazzle type
462{
463 dazzle_shader=s;
464}
465
466// ----------------------------------------------------------------------------
467
468void DazzleTypeClass::Set_Halo_Shader(const ShaderClass& s) // Set shader for the dazzle type
469{
470 halo_shader=s;
471}
472
473// ----------------------------------------------------------------------------
474
476{
477 if (!primary_texture) {
478 primary_texture = WW3DAssetManager::Get_Instance()->Get_Texture(ic.primary_texture_name);
479 if ( primary_texture ) {
480 SET_REF_OWNER(primary_texture);
481 }
482 }
483 return primary_texture;
484}
485
486// ----------------------------------------------------------------------------
487
489{
490 if (!secondary_texture) {
491 secondary_texture = WW3DAssetManager::Get_Instance()->Get_Texture(ic.secondary_texture_name);
492 if ( secondary_texture ) {
493 SET_REF_OWNER(secondary_texture);
494 }
495 }
496 return secondary_texture;
497}
498
499// ----------------------------------------------------------------------------
500
502 float& dazzle_intensity,
503 float& dazzle_size,
504 float& halo_intensity,
505 const Vector3& camera_dir,
506 const Vector3& dazzle_dir,
507 const Vector3& dir_to_dazzle,
508 float distance) const
509{
510 float dot = -Vector3::Dot_Product(dir_to_dazzle,camera_dir);
511 dazzle_intensity = dot;
512
513 if (ic.use_camera_translation && distance>(fadeout_end_sqr)) {
514 dazzle_intensity=0.0f;
515 return;
516 }
517
518 dazzle_intensity-=1.0f-ic.dazzle_area;
519 dazzle_intensity/=ic.dazzle_area;
520 dazzle_intensity=WWMath::Clamp(dazzle_intensity);
521 if (ic.dazzle_direction_area>0.0f) {
522 float angle=-Vector3::Dot_Product(camera_dir,dazzle_dir);
523 angle-=1.0f-ic.dazzle_direction_area;
524 angle/=ic.dazzle_direction_area;
525 angle=WWMath::Clamp(angle);
526 dazzle_intensity*=angle;
527 }
528
529 if (dazzle_intensity>0.0f) {
530 dazzle_size=pow(dazzle_intensity,ic.dazzle_size_pow);
531 dazzle_intensity=pow(dazzle_intensity,ic.dazzle_intensity_pow);
532 }
533 else {
534 dazzle_intensity=0.0f;
535 }
536
537 if (ic.halo_intensity_pow > WWMATH_EPSILON) {
538 if (dot > 0.0f) {
539 float scale = powf(dot, ic.halo_intensity_pow);
540 halo_intensity *= scale;
541 } else {
542 halo_intensity = 0.0f;
543 }
544 }
545
546 dazzle_intensity*=ic.dazzle_intensity;
547 halo_intensity*=ic.halo_intensity;
548
549 // Flare fadeout distance - fade it out...
550 if (ic.use_camera_translation) {
551 if (distance>(fadeout_start_sqr)) {
552 distance=sqrt(distance);
553 distance-=ic.fadeout_start;
554 distance/=ic.fadeout_end-ic.fadeout_start;
555 dazzle_intensity*=1.0f-distance; // Scale down intensity
556 halo_intensity*=1.0f-distance; // Scale down intensity
557 }
558 }
559
560 return;
561}
562
563// ----------------------------------------------------------------------------
564
566{
567 if (!ini) return;
568 if (ini->Section_Count()==0) return;
569
570 Init_Shaders();
571
572 unsigned count=ini->Entry_Count( LENSFLARE_LIST_STRING );
573 unsigned entry;
574 for ( entry = 0; entry < count; entry++ ) {
575 char section_name[80];
576 ini->Get_String(
578 ini->Get_Entry( LENSFLARE_LIST_STRING, entry),
579 "",
580 section_name,
581 sizeof( section_name ));
582
584
585 ini->Get_String(lic.texture_name,section_name,LENSFLARE_TEXTURE_STRING);
586 lic.flare_count=ini->Get_Int(section_name,FLARE_COUNT_STRING,0);
587 if (lic.flare_count) {
588 lic.flare_locations=W3DNEWARRAY float[lic.flare_count]; // Flare location is 1D
589 lic.flare_sizes=W3DNEWARRAY float[lic.flare_count];
592 }
593 else {
595 lic.flare_sizes=NULL;
596 lic.flare_colors=NULL;
597 }
598
599 for (int flare=0;flare<lic.flare_count;++flare) {
600 // Flare location
601 StringClass tmp_name(true);
602 tmp_name.Format("%s%d",FLARE_LOCATION_STRING,flare+1);
603 lic.flare_locations[flare]=ini->Get_Float(section_name,tmp_name,0.0f);
604 // Flare size
605 tmp_name.Format("%s%d",FLARE_SIZE_STRING,flare+1);
606 lic.flare_sizes[flare]=ini->Get_Float(section_name,tmp_name,1.0f);
607 // Flare color
608 tmp_name.Format("%s%d",FLARE_COLOR_STRING,flare+1);
609 TPoint3D<float> tp=ini->Get_Point(section_name,tmp_name,TPoint3D<float>(1.0f,1.0f,1.0f));
610 lic.flare_colors[flare]=reinterpret_cast<const Vector3&>(tp);
611 // Flare uv
612 const DazzleINIClass* dini=reinterpret_cast<const DazzleINIClass*>(ini);
613 tmp_name.Format("%s%d",FLARE_UV_STRING,flare+1);
614 lic.flare_uv[flare]=dini->Get_Vector4(section_name,tmp_name,Vector4(0.0f,0.0f,1.0f,1.0f));
615 }
616 lic.type=entry;
617
618 Init_Lensflare(lic);
619 lensflares[entry]->name=section_name;
620 }
621
622 count=ini->Entry_Count( DAZZLE_LIST_STRING );
623 for ( entry = 0; entry < count; entry++ ) {
624 char section_name[80];
625 ini->Get_String(
627 ini->Get_Entry( DAZZLE_LIST_STRING, entry),
628 "",
629 section_name,
630 sizeof( section_name ));
631
632 DazzleInitClass dic;
633
636 dic.halo_intensity=ini->Get_Float(section_name,HALO_INTENSITY_STRING,0.95f);
637 dic.halo_intensity_pow=ini->Get_Float(section_name,HALO_INTENSITY_POW, 0.0f);
638 dic.halo_scale_x=ini->Get_Float(section_name,HALO_SCALE_X_STRING,2.0f);
639 dic.halo_scale_y=ini->Get_Float(section_name,HALO_SCALE_Y_STRING,2.0f);
640 dic.dazzle_area=ini->Get_Float(section_name,DAZZLE_AREA_STRING,0.05f);
642 dic.dazzle_intensity=ini->Get_Float(section_name,DAZZLE_INTENSITY_STRING,0.90f);
644 dic.dazzle_size_pow=ini->Get_Float(section_name,DAZZLE_SIZE_POW_STRING,0.90f);
645 dic.dazzle_scale_x=ini->Get_Float(section_name,DAZZLE_SCALE_X_STRING,100.0f);
646 dic.dazzle_scale_y=ini->Get_Float(section_name,DAZZLE_SCALE_Y_STRING,25.0f);
647 dic.fadeout_start=ini->Get_Float(section_name,FADEOUT_START_STRING,25.0f);
648 dic.fadeout_end=ini->Get_Float(section_name,FADEOUT_END_STRING,50.0f);
650 dic.history_weight=ini->Get_Float(section_name,HISTORY_WEIGHT_STRING,0.5f);
651 dic.use_camera_translation=!!ini->Get_Int(section_name,USE_CAMERA_TRANSLATION,1);
653 dic.type=entry;
654
655 TPoint3D<float> tp=ini->Get_Point(section_name,DAZZLE_DIRECTION_STRING,TPoint3D<float>(0.0f,0.0f,0.0f));
656 tp.Normalize();
657 dic.dazzle_direction=reinterpret_cast<const Vector3&>(tp);
658
659 tp=ini->Get_Point(section_name,DAZZLE_TEST_COLOR_STRING,TPoint3D<float>(1.0f,1.0f,1.0f));
660 dic.dazzle_test_color=reinterpret_cast<const Vector3&>(tp);
661
662 tp=ini->Get_Point(section_name,DAZZLE_COLOR_STRING,TPoint3D<float>(1.0f,1.0f,1.0f));
663 dic.dazzle_color=reinterpret_cast<const Vector3&>(tp);
664
665 tp=ini->Get_Point(section_name,HALO_COLOR_STRING,TPoint3D<float>(1.0f,1.0f,1.0f));
666 dic.halo_color=reinterpret_cast<const Vector3&>(tp);
667
668 dic.radius=ini->Get_Float(section_name,RADIUS_STRING,1.0f);
669
670 dic.blink_period=ini->Get_Float(section_name,BLINK_PERIOD_STRING,0.0f);
671 dic.blink_on_time=ini->Get_Float(section_name,BLINK_ON_TIME_STRING,0.0f);
672
673 Init_Type(dic);
674 types[entry]->name=section_name;
675 }
676}
677
678// ----------------------------------------------------------------------------
679
681{
682 Init_Shaders();
683
684 if (i.type>=type_count) {
685 unsigned new_count=i.type+1;
686 DazzleTypeClass** new_types=W3DNEWARRAY DazzleTypeClass*[new_count];
687 for (unsigned a=0;a<type_count;++a) {
688 new_types[a]=types[a];
689 }
690 for (;a<new_count;++a) {
691 new_types[a]=0;
692 }
693 delete[] types;
694 types=new_types;
695 type_count=new_count;
696 }
697 delete types[i.type];
698 types[i.type]=W3DNEW DazzleTypeClass(i);
699}
700
701// ----------------------------------------------------------------------------
702
704{
705 Init_Shaders();
706
707 if (i.type>=lensflare_count) {
708 unsigned new_count=i.type+1;
709 LensflareTypeClass** new_lensflares=W3DNEWARRAY LensflareTypeClass*[new_count];
710 for (unsigned a=0;a<lensflare_count;++a) {
711 new_lensflares[a]=lensflares[a];
712 }
713 for (;a<new_count;++a) {
714 new_lensflares[a]=0;
715 }
716 delete[] lensflares;
717 lensflares=new_lensflares;
718 lensflare_count=new_count;
719 }
720 delete lensflares[i.type];
721 lensflares[i.type]=W3DNEW LensflareTypeClass(i);
722}
723
724// ----------------------------------------------------------------------------
725
727{
728 // Deinit dazzle types
729 if (types) {
730 for (unsigned a=0;a<type_count;++a) {
731 delete types[a];
732 }
733 delete[] types;
734 }
735 types=NULL;
736 type_count=0;
737
738 // Deinit lensflare types
739 if (lensflares) {
740 for (unsigned a=0;a<lensflare_count;++a) {
741 delete lensflares[a];
742 }
743 delete[] lensflares;
744 }
745 lensflares=NULL;
746 lensflare_count=0;
747
748}
749
751{
752 if (visibility_handler == NULL) {
753 _VisibilityHandler = &_DefaultVisibilityHandler;
754 } else {
755 _VisibilityHandler = visibility_handler;
756 }
757}
758
759
760// ----------------------------------------------------------------------------
761//
762// The parameter t defines the dazzle type. t has to be a valid type id in order
763// for the dazzle to work.
764//
765// ----------------------------------------------------------------------------
766
768 :
769 succ(NULL),
770 type(t),
771 current_dazzle_intensity(0.0f),
772 current_dazzle_size(0.0f),
773 dazzle_color(1.0f,1.0f,1.0f),
774 halo_color(1.0f,1.0f,1.0f),
775 lensflare_intensity(1.0f),
776 on_list(false),
777 visibility(0.0f),
778 current_scale(1.0f)
779{
780 if (types && types[t]) {
781 radius = types[t]->radius;
782 } else {
783 radius = 0.0f;
784 }
785 creation_time = WW3D::Get_Sync_Time();
786}
787
788// ----------------------------------------------------------------------------
789//
790// Creating a dazzle with its type name is a bit slower (due to scanning) but
791// works equally to the creation with id.
792//
793// ----------------------------------------------------------------------------
794
796 :
797 succ(NULL),
798 type(Get_Type_ID(type_name)),
799 current_dazzle_intensity(0.0f),
800 current_dazzle_size(0.0f),
801 dazzle_color(1.0f,1.0f,1.0f),
802 halo_color(1.0f,1.0f,1.0f),
803 lensflare_intensity(1.0f),
804 on_list(false),
805 visibility(0.0f),
806 current_scale(1.0f)
807{
808 int id = Get_Type_ID(type_name);
809 if (types && types[id]) {
810 radius = types[id]->radius;
811 } else {
812 radius = 0.0f;
813 }
814 creation_time = WW3D::Get_Sync_Time();
815}
816
817// ----------------------------------------------------------------------------
818//
819// Copy constructor creates an exact copy of the object, except for the visibility
820// information, which is initialised with default values.
821//
822// ----------------------------------------------------------------------------
823
825 :
826 succ(NULL),
827 type(src.type),
828 current_dazzle_intensity(src.current_dazzle_intensity),
829 current_dazzle_size(src.current_dazzle_size),
830 current_dir(src.current_dir),
831 dazzle_color(src.dazzle_color),
832 halo_color(src.halo_color),
833 lensflare_intensity(src.lensflare_intensity),
834 on_list(false),
835 visibility(src.visibility),
836 radius(src.radius),
837 current_scale(src.current_scale)
838{
839 creation_time = WW3D::Get_Sync_Time();
840}
841
843{
844 type=src.type;
845 current_dir=src.current_dir;
846 current_dazzle_intensity=src.current_dazzle_intensity;
847 current_dazzle_size=src.current_dazzle_size;
848 dazzle_color=src.dazzle_color;
849 halo_color=src.halo_color;
850 lensflare_intensity=src.lensflare_intensity;
851 visibility=src.visibility;
852 radius=src.radius;
853 creation_time = WW3D::Get_Sync_Time();
854 current_scale = src.current_scale;
855 return *this;
856}
857
859{
860 sphere.Center.Set(0,0,0);
861 sphere.Radius = radius * current_scale;
862}
863
865{
866 box.Center.Set(0,0,0);
867 box.Extent.Set(radius,radius,radius);
868 box.Extent *= current_scale;
869}
870
871void DazzleRenderObjClass::Set_Layer(DazzleLayerClass *layer)
872{
873 // Never insert a dazzle into a list if it already is on one - this caould create infinite
874 // loops in the dazzle list.
875 if (on_list) return;
876
877 // This function sets the dazzle to be visible in the given layer.
878 if (!layer) {
879 WWASSERT(0);
880 return;
881 }
882
883 if (type>=type_count) return; // If the type doesn't exist the visibility can't be changed
884
885 // Insert at the head of the layer's visible list
886 succ = layer->visible_lists[type];
887 layer->visible_lists[type] = this;
888 on_list = true;
889 Add_Ref();
890}
891
893{
894 current_dazzle_layer = layer;
895}
896
898// Render Object Interface
900
902{
903 return NEW_REF(DazzleRenderObjClass, (*this));
904}
905
906// ----------------------------------------------------------------------------
907//
908// DazzleRenderObjClass's Render() function doesn't actually render the dazzle
909// immediatelly but just sets the dazzle visible. This is due to the way the
910// dazzle system works (the dazzles need to be rendered after everything else).
911// Having the Render() function flag the visibility offers us the visibility
912// functionality of the scene graph.
913//
914// ----------------------------------------------------------------------------
916{
917 WWPROFILE("Dazzle::Render");
918
919 if ( Is_Not_Hidden_At_All() &&
920 _dazzle_rendering_enabled &&
922 {
923 // First check if the dazzle is blinking and is "off"
924 bool is_on = true;
925 DazzleInitClass & ic = types[type]->ic;
926
927 if (ic.blink_period > 0.0f) {
928 float elapsed_time = ((float)(WW3D::Get_Sync_Time() - creation_time)) / 1000.0f;
929 float wrapped_time = fmodf(elapsed_time,ic.blink_period);
930 if (wrapped_time > ic.blink_on_time) {
931 is_on = false;
932 }
933 }
934
935 // Next, check visibility
936 visibility = 1.0f;
937
938 if (is_on == false) {
939 visibility = 0.0f;
940 } else {
941// Vector3 position;
942// Get_Transform().Get_Translation(&position);
943// visibility = _VisibilityHandler->Compute_Dazzle_Visibility(rinfo,this,position);
944
945 Matrix4x4 view_transform,projection_transform;
946 DX8Wrapper::Get_Transform(D3DTS_VIEW,view_transform);
947 DX8Wrapper::Get_Transform(D3DTS_PROJECTION,projection_transform);
948 Vector3 camera_loc(rinfo.Camera.Get_Position());
949 Vector3 camera_dir(-view_transform[2][0],-view_transform[2][1],-view_transform[2][2]);
950// Matrix3D cam(rinfo.Camera.Get_Transform());
951// Vector3 camera_dir(-cam[2][0],-cam[2][1],-cam[2][2]);
952// camera_dir.Normalize();
953
954 Vector3 loc=Get_Position();
955 transformed_loc=view_transform*loc;
956 transformed_loc=projection_transform*transformed_loc;
957 transformed_loc[0]/=transformed_loc[3];
958 transformed_loc[1]/=transformed_loc[3];
959 transformed_loc[2]/=transformed_loc[3];
960 transformed_loc[3]=1.0f;
961 current_vloc=Vector3(transformed_loc[0],transformed_loc[1],transformed_loc[2]);
962
963 float dazzle_intensity=1.0f;
964 Vector3 dir;
965 dir=camera_loc-loc;
966 current_distance=dir.Length2();
967 dir.Normalize();
968
969 float dazzle_size;
970 current_halo_intensity=1.0f;
971 const DazzleTypeClass* params=types[type];
972 params->Calculate_Intensities(dazzle_intensity,dazzle_size,current_halo_intensity,camera_dir,current_dir,dir,current_distance);
973
974 unsigned time_ms=WW3D::Get_Frame_Time();
975 if (time_ms==0) time_ms=1;
976 float weight=pow(params->ic.history_weight,time_ms);
977
978 if (dazzle_intensity>0.0f) {
979 visibility = _VisibilityHandler->Compute_Dazzle_Visibility(rinfo,this,loc);
980//visibility=1.0f;
981 dazzle_intensity*=visibility;
982 }
983 else {
984 visibility=0.0f;
985 }
986 if (visibility == 0.0f) {
987
988 float i=dazzle_intensity*(1.0f-weight)+current_dazzle_intensity*weight;
989 current_dazzle_intensity=i;
990 if (current_dazzle_intensity<0.05f) current_dazzle_intensity=0.0f;
991 dazzle_intensity=i;
992
993 float s=dazzle_size*(1.0f-weight)+current_dazzle_size*weight;
994 current_dazzle_size=s;
995 dazzle_size=s;
996
997 } else {
998 current_dazzle_intensity = dazzle_intensity;
999 current_dazzle_size = dazzle_size;
1000 }
1001
1002 }
1003
1004 // If this dazzle is visible or it is currently fading, submit it for rendering
1005 if (/*visibility > 0.0f ||*/ current_dazzle_intensity>0.0f || current_halo_intensity>0.0f) {
1006 WWASSERT(types[type]);
1007 Set_Layer(current_dazzle_layer);
1008 }
1009 }
1010 else {
1011 visibility=0.0f;
1012 }
1013}
1014
1015void DazzleRenderObjClass::Render_Dazzle(CameraClass* camera)
1016{
1017 WWPROFILE("Dazzle::Render");
1018 Matrix4x4 old_view_transform;
1019 Matrix4x4 old_world_transform;
1020 Matrix4x4 old_projection_transform;
1021 Matrix4x4 view_transform;
1022 Matrix4x4 world_transform;
1023 Matrix4x4 projection_transform;
1024 DX8Wrapper::Get_Transform(D3DTS_VIEW,view_transform);
1025 DX8Wrapper::Get_Transform(D3DTS_WORLD,world_transform);
1026 DX8Wrapper::Get_Transform(D3DTS_PROJECTION,projection_transform);
1027 old_view_transform=view_transform;
1028 old_world_transform=world_transform;
1029 old_projection_transform=projection_transform;
1030 Vector3 camera_loc(camera->Get_Position());
1031 Vector3 camera_dir(-view_transform[2][0],-view_transform[2][1],-view_transform[2][2]);
1032
1033 int display_width,display_height,display_bits;
1034 bool windowed;
1035 WW3D::Get_Device_Resolution(display_width,display_height,display_bits,windowed);
1036 float w=float(display_width);
1037 float h=float(display_height);
1038 float screen_x_scale=1.0f;
1039 float screen_y_scale=1.0f;
1040 if (w>h) {
1041 screen_y_scale=w/h;
1042 }
1043 else {
1044 screen_x_scale=h/w;
1045 }
1046
1047// unsigned time_ms=WW3D::Get_Frame_Time();
1048// if (time_ms==0) time_ms=1;
1049
1050 // Do NOT scale halo by current scale
1051 // because it uses screen parallel primitives
1052 // and if it's too big it will be visible until
1053 // it collides with the near clip plane and then pop and vanish
1054 float halo_scale_x=types[type]->ic.halo_scale_x;
1055 float halo_scale_y=types[type]->ic.halo_scale_y;
1056 float dazzle_scale_x=types[type]->ic.dazzle_scale_x * current_scale;
1057 float dazzle_scale_y=types[type]->ic.dazzle_scale_y * current_scale;
1058
1059 // Allocate some arrays for the dazzle rendering
1060 int vertex_count=4;
1061
1062 const DazzleTypeClass* params=types[type];
1063
1064 int halo_vertex_count=0;
1065 int dazzle_vertex_count=0;
1066 int lensflare_vertex_count=0;
1067
1068 Vector3 dl;
1069
1070 int lens_max_verts=0;
1071 LensflareTypeClass* lensflare = DazzleRenderObjClass::Get_Lensflare_Class(types[type]->lensflare_id);
1072 if (lensflare) {
1073 lens_max_verts=4*lensflare->lic.flare_count;
1074 }
1075
1076 DynamicVBAccessClass vb_access(BUFFER_TYPE_DYNAMIC_DX8,dynamic_fvf_type,vertex_count*2+lens_max_verts);
1077 {
1078 DynamicVBAccessClass::WriteLockClass lock(&vb_access);
1079 VertexFormatXYZNDUV2* verts=lock.Get_Formatted_Vertex_Array();
1080
1081 float halo_size=1.0f;
1082
1083 Vector3 dazzle_dxt(screen_x_scale,0.0f,0.0f);
1084 Vector3 halo_dxt=dazzle_dxt*halo_scale_x;
1085 dazzle_dxt*=dazzle_scale_x;
1086
1087 Vector3 dazzle_dyt(0.0f,screen_y_scale,0.0f);
1088 Vector3 halo_dyt=dazzle_dyt*halo_scale_y;
1089 dazzle_dyt*=dazzle_scale_y;
1090
1091 if (current_dazzle_intensity>0.0f) {
1092 VertexFormatXYZNDUV2* vertex=verts;
1093 dazzle_vertex_count+=4;
1094
1095 Vector3 col(
1096 dazzle_color[0]*params->ic.dazzle_color[0],
1097 dazzle_color[1]*params->ic.dazzle_color[1],
1098 dazzle_color[2]*params->ic.dazzle_color[2]);
1099 col*=current_dazzle_intensity;
1100
1101 if (col[0]>1.0f) col[0]=1.0f;
1102 if (col[1]>1.0f) col[1]=1.0f;
1103 if (col[2]>1.0f) col[2]=1.0f;
1104
1105 unsigned color=DX8Wrapper::Convert_Color(col,1.0f);
1106
1107 dl=current_vloc+(dazzle_dxt-dazzle_dyt)*current_dazzle_size;
1108 reinterpret_cast<Vector3&>(vertex->x)=dl;
1109 vertex->u1=0.0f;
1110 vertex->v1=0.0f;
1111 vertex->diffuse=color;
1112 vertex++;
1113
1114 dl=current_vloc+(dazzle_dxt+dazzle_dyt)*current_dazzle_size;
1115 reinterpret_cast<Vector3&>(vertex->x)=dl;
1116 vertex->u1=1.0f;
1117 vertex->v1=0.0f;
1118 vertex->diffuse=color;
1119 vertex++;
1120
1121 dl=current_vloc-(dazzle_dxt-dazzle_dyt)*current_dazzle_size;
1122 reinterpret_cast<Vector3&>(vertex->x)=dl;
1123 vertex->u1=1.0f;
1124 vertex->v1=1.0f;
1125 vertex->diffuse=color;
1126 vertex++;
1127
1128 dl=current_vloc-(dazzle_dxt+dazzle_dyt)*current_dazzle_size;
1129 reinterpret_cast<Vector3&>(vertex->x)=dl;
1130 vertex->u1=0.0f;
1131 vertex->v1=1.0f;
1132 vertex->diffuse=color;
1133 }
1134
1135 if (current_halo_intensity) {
1136 VertexFormatXYZNDUV2* vertex=verts+dazzle_vertex_count;
1137 halo_vertex_count+=4;
1138
1139 Vector3 col(
1140 halo_color[0]*params->ic.halo_color[0],
1141 halo_color[1]*params->ic.halo_color[1],
1142 halo_color[2]*params->ic.halo_color[2]);
1143 col*=current_halo_intensity;
1144 if (col[0]>1.0f) col[0]=1.0f;
1145 if (col[1]>1.0f) col[1]=1.0f;
1146 if (col[2]>1.0f) col[2]=1.0f;
1147
1148 unsigned color=DX8Wrapper::Convert_Color(col,1.0f);
1149
1150 Vector3 offset;
1151
1152 offset = (halo_dxt - halo_dyt) * halo_size;
1153 dl = current_vloc + offset;
1154 reinterpret_cast<Vector3&>(vertex->x)=dl;
1155 vertex->u1=0.0f;
1156 vertex->v1=0.0f;
1157 vertex->diffuse=color;
1158 vertex++;
1159
1160 offset = (halo_dxt + halo_dyt) * halo_size;
1161 dl =current_vloc + offset;
1162 reinterpret_cast<Vector3&>(vertex->x)=dl;
1163 vertex->u1=1.0f;
1164 vertex->v1=0.0f;
1165 vertex->diffuse=color;
1166 vertex++;
1167
1168 offset = -(halo_dxt - halo_dyt) * halo_size;
1169 dl = current_vloc + offset;
1170 reinterpret_cast<Vector3&>(vertex->x)=dl;
1171 vertex->u1=1.0f;
1172 vertex->v1=1.0f;
1173 vertex->diffuse=color;
1174 vertex++;
1175
1176 offset = -(halo_dxt + halo_dyt) * halo_size;
1177 dl=current_vloc + offset;
1178 reinterpret_cast<Vector3&>(vertex->x)=dl;
1179 vertex->u1=0.0f;
1180 vertex->v1=1.0f;
1181 vertex->diffuse=color;
1182 }
1183
1184 if (lensflare && current_dazzle_intensity>0.0f) {
1185 VertexFormatXYZNDUV2* vertex=verts+halo_vertex_count+dazzle_vertex_count;
1186
1187 lensflare->Generate_Vertex_Buffers(
1188 vertex,
1189 lensflare_vertex_count,
1190 screen_x_scale,
1191 screen_y_scale,
1192 current_dazzle_intensity * lensflare_intensity,
1193 transformed_loc);
1194 vertex_count+=lensflare_vertex_count;
1195 }
1196 }
1197
1198 int dazzle_poly_count=dazzle_vertex_count>>1;
1199 int halo_poly_count=halo_vertex_count>>1;
1200 int lensflare_poly_count=lensflare_vertex_count>>1;
1201 int poly_count=halo_poly_count>dazzle_poly_count ? halo_poly_count : dazzle_poly_count;
1202 if (lensflare_poly_count>poly_count) poly_count=lensflare_poly_count;
1203 if (!poly_count) {
1204 return;
1205 }
1206
1208
1209 DynamicIBAccessClass ib_access(BUFFER_TYPE_DYNAMIC_DX8,poly_count*3);
1210 {
1211 DynamicIBAccessClass::WriteLockClass lock(&ib_access);
1212 unsigned short* inds=lock.Get_Index_Array();
1213
1214 // Proceed two polygons at a time
1215 for (int a=0;a<poly_count/2;a++) {
1216 *inds++=short(4*a);
1217 *inds++=short(4*a+1);
1218 *inds++=short(4*a+2);
1219 *inds++=short(4*a);
1220 *inds++=short(4*a+2);
1221 *inds++=short(4*a+3);
1222 }
1223 }
1224
1227 DX8Wrapper::Set_Transform(D3DTS_PROJECTION,Matrix4x4(true));
1228
1229 if (halo_poly_count) {
1230 DX8Wrapper::Set_Index_Buffer(ib_access,dazzle_vertex_count);
1231 DX8Wrapper::Set_Shader(default_halo_shader);
1232 DX8Wrapper::Set_Texture(0,types[type]->Get_Halo_Texture());
1233 SphereClass sphere(Get_Position(),0.1f);
1234
1235 DX8Wrapper::Draw_Triangles(0,halo_poly_count,0,vertex_count);
1236 }
1237
1238 if (dazzle_poly_count) {
1239 DX8Wrapper::Set_Index_Buffer(ib_access,0);
1240 DX8Wrapper::Set_Shader(default_dazzle_shader);
1241 DX8Wrapper::Set_Texture(0,types[type]->Get_Dazzle_Texture());
1242 SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f);
1243 DX8Wrapper::Draw_Triangles(0,dazzle_poly_count,0,vertex_count);
1244 }
1245
1246 if (lensflare_poly_count) {
1247 DX8Wrapper::Set_Index_Buffer(ib_access,dazzle_vertex_count+halo_vertex_count);
1248 DX8Wrapper::Set_Shader(default_dazzle_shader);
1249 DX8Wrapper::Set_Texture(0,lensflare->Get_Texture());
1250 SphereClass sphere(Vector3(0.0f,0.0f,0.0f),0.0f);
1251 DX8Wrapper::Draw_Triangles(0,lensflare_poly_count,0,vertex_count);
1252 }
1253
1254 DX8Wrapper::Set_Transform(D3DTS_PROJECTION,old_projection_transform);
1255 DX8Wrapper::Set_Transform(D3DTS_VIEW,old_view_transform);
1256 DX8Wrapper::Set_Transform(D3DTS_WORLD,old_world_transform);
1257}
1258
1259// ----------------------------------------------------------------------------
1260
1262{
1264 if (type<type_count) {
1265 Matrix3D::Rotate_Vector(m,types[type]->ic.dazzle_direction,&current_dir);
1266 }
1267}
1268
1269// ----------------------------------------------------------------------------
1270//
1271// Return the type id of a dazzle class with given name. If such type is not
1272// found, return UINT_MAX.
1273//
1274// ----------------------------------------------------------------------------
1275
1276unsigned DazzleRenderObjClass::Get_Type_ID(const char* name)
1277{
1278 for (unsigned a=0;a<type_count;++a) {
1279 if (types[a] && types[a]->name==name) return a;
1280 }
1281 return UINT_MAX;
1282}
1283
1284
1285// ----------------------------------------------------------------------------
1286//
1287// Return the type name of a dazzle class with given id. If the id is out
1288// of range, return "DEFAULT" which by convention is always defined and is
1289// id 0.
1290//
1291// ----------------------------------------------------------------------------
1292
1294{
1295 if ((id < type_count) && (id >= 0)) {
1296 return types[id]->name;
1297 } else {
1298 return "DEFAULT";
1299 }
1300}
1301
1302// ----------------------------------------------------------------------------
1303//
1304// Return pointer to DazzleTypeClass object with given id. If the id is out
1305// of range (usually UINT_MAX, in can the id was obtained with invalid name
1306// string) return NULL.
1307//
1308// ----------------------------------------------------------------------------
1309
1310DazzleTypeClass* DazzleRenderObjClass::Get_Type_Class(unsigned id) // Return dazzle type class pointer, or NULL if not found
1311{
1312 if (id>=type_count) return NULL;
1313 return types[id];
1314}
1315
1316// ----------------------------------------------------------------------------
1317//
1318// Return the type id of a lensflare type class with given name. If such type is
1319// not found, return UINT_MAX.
1320//
1321// ----------------------------------------------------------------------------
1322
1324{
1325 for (unsigned a=0;a<lensflare_count;++a) {
1326 if (lensflares[a] && lensflares[a]->name==name) return a;
1327 }
1328 return UINT_MAX;
1329}
1330
1331// ----------------------------------------------------------------------------
1332//
1333// Return pointer to LensflareTypeClass object with given id. If the id is out
1334// of range (usually UINT_MAX, in can the id was obtained with invalid name
1335// string) return NULL.
1336//
1337// ----------------------------------------------------------------------------
1338
1339LensflareTypeClass* DazzleRenderObjClass::Get_Lensflare_Class(unsigned id) // Return lensflare type class pointer, or NULL if not found
1340{
1341 if (id>=lensflare_count) return NULL;
1342 return lensflares[id];
1343}
1344
1345// ----------------------------------------------------------------------------
1346//
1347// Should static dazzles require vis information, here's a function that renders
1348// a quad at the location of the dazzle
1349//
1350// ----------------------------------------------------------------------------
1351
1352void DazzleRenderObjClass::vis_render_dazzle(SpecialRenderInfoClass & rinfo)
1353{
1354
1355 WWASSERT(rinfo.VisRasterizer != NULL);
1357
1358 /*
1359 ** Create a transform which is facing the camera
1360 */
1362 Vector3 daz_point = Get_Transform().Get_Translation();
1363
1364 Matrix3D tm;
1365 tm.Look_At(daz_point,cam_point,0.0f);
1367
1368 /*
1369 ** Now, generate a single triangle on the X-Y plane
1370 */
1371 Vector3 verts[4];
1372 TriIndex polys[2];
1373
1374 polys[0] = TriIndex(0,1,2);
1375 polys[1] = TriIndex(0,2,3);
1376
1377 Vector2 view_min,view_max;
1378 rinfo.VisRasterizer->Peek_Camera()->Get_View_Plane(view_min,view_max);
1379
1380 float scale_x=types[type]->ic.halo_scale_x;
1381 if ((scale_x < 0.001f) && (types[type]->ic.dazzle_scale_x > scale_x)) {
1382 scale_x = types[type]->ic.dazzle_scale_x;
1383 }
1384
1385 float scale_y=types[type]->ic.halo_scale_y;
1386 if ((scale_y < 0.001f) && (types[type]->ic.dazzle_scale_y > scale_y)) {
1387 scale_y = types[type]->ic.dazzle_scale_y;
1388 }
1389
1390 float dist = (daz_point - cam_point).Length();
1391 Vector3 dxt(dist * scale_x / (view_max.X - view_min.X),0.0f,0.0f);
1392 Vector3 dyt(0.0f,dist * scale_y / (view_max.Y - view_min.Y),0.0f);
1393
1394 verts[0].Set(dxt+dyt);
1395 verts[1].Set(dxt-dyt);
1396 verts[2].Set(-dxt-dyt);
1397 verts[3].Set(-dxt+dyt);
1398
1399 AABoxClass bounds;
1400 float extent = 1.1f * (dxt+dyt).Length();
1401 bounds.Center = daz_point; //making up a conservative bounding box
1402 bounds.Extent.Set(extent,extent,extent);
1403
1404 /*
1405 ** Render
1406 */
1408 rinfo.VisRasterizer->Render_Triangles(verts,4,polys,2,bounds);
1410}
1411
1413{
1415 vis_render_dazzle(rinfo);
1416 }
1417}
1418
1419
1420
1421/****************************************************************************************
1422
1423
1424 DazzleRenderObjClass - Persistant object support.
1425
1426 Dazzles are going to save their type and their transform and simply
1427 re-create another dazzle of the same type when loaded.
1428
1429
1430****************************************************************************************/
1431
1433{
1434 virtual uint32 Chunk_ID(void) const;
1435 virtual PersistClass * Load(ChunkLoadClass & cload) const;
1436 virtual void Save(ChunkSaveClass & csave,PersistClass * obj) const;
1437
1438 enum
1439 {
1440 DAZZLEFACTORY_CHUNKID_VARIABLES = 1212000336,
1441 DAZZLEFACTORY_VARIABLE_OBJPOINTER = 0x00,
1442 OBSOLETE_DAZZLEFACTORY_VARIABLE_TYPE,
1443 DAZZLEFACTORY_VARIABLE_TRANSFORM,
1444 DAZZLEFACTORY_VARIABLE_TYPENAME,
1445 };
1446};
1447
1448static DazzlePersistFactoryClass _DazzleFactory;
1449
1450uint32 DazzlePersistFactoryClass::Chunk_ID(void) const
1451{
1453}
1454
1455PersistClass * DazzlePersistFactoryClass::Load(ChunkLoadClass & cload) const
1456{
1457 DazzleRenderObjClass * old_obj = NULL;
1458 Matrix3D tm(1);
1459 char dazzle_type[256];
1460 dazzle_type[0] = 0;
1461
1462 /*
1463 ** Load the dazzle parameters
1464 */
1465 while (cload.Open_Chunk()) {
1466 switch (cload.Cur_Chunk_ID()) {
1467
1468 case DAZZLEFACTORY_CHUNKID_VARIABLES:
1469
1470 while (cload.Open_Micro_Chunk()) {
1471 switch(cload.Cur_Micro_Chunk_ID()) {
1472 READ_MICRO_CHUNK(cload,DAZZLEFACTORY_VARIABLE_OBJPOINTER,old_obj);
1473 READ_MICRO_CHUNK(cload,DAZZLEFACTORY_VARIABLE_TRANSFORM,tm);
1474 READ_MICRO_CHUNK_STRING(cload,DAZZLEFACTORY_VARIABLE_TYPENAME,dazzle_type,sizeof(dazzle_type));
1475 }
1476 cload.Close_Micro_Chunk();
1477 }
1478 break;
1479
1480 default:
1481 WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d\r\n",__FILE__,__LINE__));
1482 break;
1483 };
1484 cload.Close_Chunk();
1485 }
1486
1487 /*
1488 ** Create a new dazzle object
1489 */
1490 int type_index = 0;
1491 if (strlen(dazzle_type) > 0) {
1492 type_index = DazzleRenderObjClass::Get_Type_ID(dazzle_type);
1493 }
1494 RenderObjClass * new_obj = NEW_REF(DazzleRenderObjClass,(dazzle_type));
1495
1496 /*
1497 ** If we failed to create it, replace it with a NULL
1498 */
1499 if (new_obj == NULL) {
1500 static int count = 0;
1501 if ( ++count < 10 ) {
1502 WWDEBUG_SAY(("DazzlePersistFactory failed to create dazzle of type: %s!!\r\n",dazzle_type));
1503 WWDEBUG_SAY(("Replacing it with a NULL render object!\r\n"));
1504 }
1506 }
1507
1508 WWASSERT(new_obj != NULL);
1509 if (new_obj) {
1510 new_obj->Set_Transform(tm);
1511 }
1512
1513 /*
1514 ** Register the old pointer for re-mapping to the new pointer
1515 */
1517 return new_obj;
1518}
1519
1520void DazzlePersistFactoryClass::Save(ChunkSaveClass & csave,PersistClass * obj) const
1521{
1522 DazzleRenderObjClass * robj = (DazzleRenderObjClass *)obj;
1523 unsigned int dazzle_type = robj->Get_Dazzle_Type();
1524 const char * dazzle_type_name = DazzleRenderObjClass::Get_Type_Name(dazzle_type);
1525 Matrix3D tm = robj->Get_Transform();
1526
1527 csave.Begin_Chunk(DAZZLEFACTORY_CHUNKID_VARIABLES);
1528 WRITE_MICRO_CHUNK(csave,DAZZLEFACTORY_VARIABLE_OBJPOINTER,robj);
1529 WRITE_MICRO_CHUNK(csave,DAZZLEFACTORY_VARIABLE_TRANSFORM,tm);
1530 WRITE_MICRO_CHUNK_STRING(csave,DAZZLEFACTORY_VARIABLE_TYPENAME,dazzle_type_name);
1531
1532 csave.End_Chunk();
1533}
1534
1535
1536/*
1537** DazzleRenderObj save-load.
1538*/
1540{
1541 return _DazzleFactory;
1542}
1543
1544
1545
1546/**********************************************************************************************
1547**
1548** DazzleLayerClass Implementation
1549**
1550**********************************************************************************************/
1552 visible_lists(NULL)
1553{
1554 if (type_count != 0) {
1555
1556 // Generate an array with one visible list for each type.
1557 // NOTE - this means that this constructor must be called AFTER all types
1558 // are initialized
1559 WWASSERT(type_count);
1560
1561 visible_lists = W3DNEWARRAY DazzleRenderObjClass *[type_count];
1562 for (unsigned int i = 0; i < type_count; i++) {
1563 visible_lists[i] = NULL;
1564 }
1565 }
1566}
1567
1569{
1570 // NOTE - this destructor must be called BEFORE DeInit().
1571// WWASSERT(type_count);
1572
1573 for (unsigned int i = 0; i < type_count; i++) {
1574 Clear_Visible_List(i);
1575 }
1576
1577 delete [] visible_lists;
1578}
1579
1581{
1582 if (!camera) return;
1583
1584 camera->Apply();
1585
1586 unsigned time_ms=WW3D::Get_Frame_Time();
1587 if (time_ms==0) time_ms=1;
1588
1590
1591 for (unsigned type=0;type<type_count;++type) {
1592 if (!types[type]) continue;
1593 int count = Get_Visible_Item_Count(type);
1594
1595 if (!count) continue;
1596
1597 DazzleRenderObjClass* n = visible_lists[type];
1598 while (n) {
1599 n->Render_Dazzle(camera);
1600 n=n->Succ();
1601 }
1602
1603 // Must clear the visible list at the end of each render.
1604 Clear_Visible_List(type);
1605 }
1606}
1607
1608// ----------------------------------------------------------------------------
1609
1610int DazzleLayerClass::Get_Visible_Item_Count(unsigned int type) const
1611{
1612 if (type >= type_count) {
1613 WWASSERT(0);
1614 return 0;
1615 }
1616
1617 int count=0;
1618
1619 DazzleRenderObjClass* n = visible_lists[type];
1620 while (n) {
1621 count++;
1622 n=n->Succ();
1623 }
1624 return count;
1625}
1626
1627// ----------------------------------------------------------------------------
1628
1629void DazzleLayerClass::Clear_Visible_List(unsigned int type)
1630{
1631 if (type >= type_count) {
1632 WWASSERT(0);
1633 return;
1634 }
1635
1636
1637 DazzleRenderObjClass* n = visible_lists[type];
1638 while (n) {
1639 n->Release_Ref();
1640 n->on_list = false;
1641 n=n->Succ();
1642 }
1643
1644 visible_lists[type] = NULL;
1645}
1646
1647/**********************************************************************************************
1648**
1649** DazzleVisibilityClass Implementation
1650** The default dazzle visibility handler asks the scene to determine whether the dazzle
1651** is occluded.
1652**
1653**********************************************************************************************/
1654
1656(
1657 RenderInfoClass & rinfo,
1658 DazzleRenderObjClass * dazzle,
1659 const Vector3 & point
1660) const
1661{
1662 /*
1663 ** Look up the scene this dazzle is in
1664 */
1665 SceneClass * scene = dazzle->Get_Scene();
1666 RenderObjClass * container = dazzle->Get_Container();
1667 while ((scene == NULL) && (container != NULL)) {
1668 scene = container->Get_Scene();
1669 container = container->Get_Container();
1670 }
1671
1672 /*
1673 ** If we found the scene (we SHOULD!) then ask it to compute the visibility
1674 */
1675 if (scene != NULL) {
1676 float value = scene->Compute_Point_Visibility(rinfo,point);
1677 scene->Release_Ref();
1678 return value;
1679 } else {
1680 return 1.0f;
1681 }
1682}
1683
1684
1685/**********************************************************************************************
1686**
1687** DazzlePrototypeClass Implementation
1688**
1689**********************************************************************************************/
1690
1692{
1693 return NEW_REF(DazzleRenderObjClass,(DazzleType));
1694}
1695
1696
1698{
1699 StringClass dazzle_type;
1700
1701 while (cload.Open_Chunk()) {
1702 switch (cload.Cur_Chunk_ID())
1703 {
1706 default:
1707 break;
1708 }
1709 cload.Close_Chunk();
1710 }
1711
1712 DazzleType = DazzleRenderObjClass::Get_Type_ID(dazzle_type);
1713 if (DazzleType == UINT_MAX) {
1714 DazzleType = 0;
1715 }
1716
1717 return WW3D_ERROR_OK;
1718}
1719
1720
1721/**********************************************************************************************
1722**
1723** DazzleLoaderClass Implementation
1724**
1725**********************************************************************************************/
1726
1728{
1730 new_proto->Load_W3D(cload);
1731 return new_proto;
1732}
#define NULL
Definition BaseType.h:92
void const char * value
Color scale(const Color &a, const Color &b)
Definition GameMtl.cpp:722
#define WWASSERT
@ W3D_CHUNK_DAZZLE_NAME
Definition w3d_file.h:484
@ W3D_CHUNK_DAZZLE_TYPENAME
Definition w3d_file.h:485
#define W3DNEWARRAY
Definition always.h:110
#define W3DNEW
Definition always.h:109
unsigned long uint32
Definition bittype.h:46
@ false
Definition bool.h:59
#define WRITE_MICRO_CHUNK(csave, id, var)
Definition chunkio.h:293
#define READ_WWSTRING_CHUNK(cload, id, var)
Definition chunkio.h:275
#define READ_MICRO_CHUNK_STRING(cload, id, var, size)
Definition chunkio.h:348
#define WRITE_MICRO_CHUNK_STRING(csave, id, var)
Definition chunkio.h:304
#define READ_MICRO_CHUNK(cload, id, var)
Definition chunkio.h:334
#define WWMATH_EPSILON
Definition wwmath.h:54
char dir[_MAX_DIR]
Definition autorun.cpp:215
Vector3 Center
Definition aabox.h:123
Vector3 Extent
Definition aabox.h:124
void Apply(void)
Definition camera.cpp:719
void Get_View_Plane(Vector2 &set_min, Vector2 &set_max) const
Definition camera.cpp:380
bool Close_Micro_Chunk()
Definition chunkio.cpp:585
bool Close_Chunk()
Definition chunkio.cpp:448
uint32 Cur_Chunk_ID()
Definition chunkio.cpp:484
uint32 Cur_Micro_Chunk_ID()
Definition chunkio.cpp:622
bool Open_Chunk()
Definition chunkio.cpp:412
bool Open_Micro_Chunk()
Definition chunkio.cpp:557
bool Begin_Chunk(uint32 id)
Definition chunkio.cpp:108
bool End_Chunk()
Definition chunkio.cpp:148
static void Set_World_Identity()
static void Set_Vertex_Buffer(const VertexBufferClass *vb, unsigned stream=0)
static void Set_Texture(unsigned stage, TextureBaseClass *texture)
static void Set_View_Identity()
static void Set_Index_Buffer(const IndexBufferClass *ib, unsigned short index_base_offset)
static Vector4 Convert_Color(unsigned color)
Definition dx8wrapper.h:958
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)
static bool Is_Render_To_Texture(void)
Definition dx8wrapper.h:493
const Vector4 Get_Vector4(char const *section, char const *entry, const Vector4 &defvalue=Vector4(0, 0, 0, 0)) const
Definition dazzle.cpp:330
const Vector2 Get_Vector2(char const *section, char const *entry, const Vector2 &defvalue=Vector2(0, 0))
Definition dazzle.cpp:302
const Vector3 Get_Vector3(char const *section, char const *entry, const Vector3 &defvalue=Vector3(0, 0, 0))
Definition dazzle.cpp:316
DazzleINIClass(FileClass &file)
Definition dazzle.cpp:296
float dazzle_area
Definition dazzle.h:55
float halo_scale_x
Definition dazzle.h:50
bool use_camera_translation
Definition dazzle.h:44
float dazzle_scale_y
Definition dazzle.h:62
float halo_intensity_pow
Definition dazzle.h:49
Vector3 dazzle_test_color
Definition dazzle.h:58
float dazzle_size_pow
Definition dazzle.h:52
unsigned type
Definition dazzle.h:43
Vector3 halo_color
Definition dazzle.h:60
float dazzle_scale_x
Definition dazzle.h:61
StringClass primary_texture_name
Definition dazzle.h:45
float halo_scale_y
Definition dazzle.h:51
float size_optimization_limit
Definition dazzle.h:65
float radius
Definition dazzle.h:67
float dazzle_intensity
Definition dazzle.h:54
Vector3 dazzle_color
Definition dazzle.h:59
float history_weight
Definition dazzle.h:66
float fadeout_end
Definition dazzle.h:64
float fadeout_start
Definition dazzle.h:63
float halo_intensity
Definition dazzle.h:48
float blink_period
Definition dazzle.h:68
StringClass secondary_texture_name
Definition dazzle.h:46
float blink_on_time
Definition dazzle.h:69
float dazzle_intensity_pow
Definition dazzle.h:53
Vector3 dazzle_direction
Definition dazzle.h:57
float dazzle_direction_area
Definition dazzle.h:56
StringClass lensflare_name
Definition dazzle.h:47
~DazzleLayerClass(void)
Definition dazzle.cpp:1568
void Render(CameraClass *camera)
Definition dazzle.cpp:1580
DazzleLayerClass(void)
Definition dazzle.cpp:1551
virtual PrototypeClass * Load_W3D(ChunkLoadClass &cload)
Definition dazzle.cpp:1727
WW3DErrorType Load_W3D(ChunkLoadClass &cload)
Definition dazzle.cpp:1697
virtual RenderObjClass * Create(void)
Definition dazzle.cpp:1691
static void Init_Lensflare(const LensflareInitClass &i)
Definition dazzle.cpp:703
static void Set_Current_Dazzle_Layer(DazzleLayerClass *layer)
Definition dazzle.cpp:892
DazzleRenderObjClass * Succ()
Definition dazzle.h:273
virtual void Get_Obj_Space_Bounding_Box(AABoxClass &box) const
Definition dazzle.cpp:864
DazzleRenderObjClass(unsigned type)
Definition dazzle.cpp:767
virtual void Special_Render(SpecialRenderInfoClass &rinfo)
Definition dazzle.cpp:1412
virtual void Render(RenderInfoClass &rinfo)
Definition dazzle.cpp:915
static unsigned Get_Lensflare_ID(const char *name)
Definition dazzle.cpp:1323
DazzleRenderObjClass & operator=(const DazzleRenderObjClass &)
Definition dazzle.cpp:842
static void Init_From_INI(const INIClass *ini)
Definition dazzle.cpp:565
static void Init_Type(const DazzleInitClass &i)
Definition dazzle.cpp:680
static unsigned Get_Type_ID(const char *name)
Definition dazzle.cpp:1276
static LensflareTypeClass * Get_Lensflare_Class(unsigned id)
Definition dazzle.cpp:1339
virtual void Set_Transform(const Matrix3D &m)
Definition dazzle.cpp:1261
static const char * Get_Type_Name(unsigned int id)
Definition dazzle.cpp:1293
virtual const PersistFactoryClass & Get_Factory(void) const
Definition dazzle.cpp:1539
virtual RenderObjClass * Clone(void) const
Definition dazzle.cpp:901
void Set_Layer(DazzleLayerClass *layer)
Definition dazzle.cpp:871
static void Deinit()
Definition dazzle.cpp:726
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass &sphere) const
Definition dazzle.cpp:858
static void Install_Dazzle_Visibility_Handler(const DazzleVisibilityClass *visibility_handler)
Definition dazzle.cpp:750
unsigned int Get_Dazzle_Type(void)
Definition dazzle.h:293
static DazzleTypeClass * Get_Type_Class(unsigned id)
Definition dazzle.cpp:1310
void Set_Dazzle_Shader(const ShaderClass &s)
Definition dazzle.cpp:461
TextureClass * Get_Dazzle_Texture()
Definition dazzle.cpp:475
TextureClass * Get_Halo_Texture()
Definition dazzle.cpp:488
virtual void Calculate_Intensities(float &dazzle_intensity, float &dazzle_size, float &halo_intensity, const Vector3 &camera_dir, const Vector3 &dazzle_dir, const Vector3 &dir_to_dazzle, float distance) const
Definition dazzle.cpp:501
void Set_Halo_Shader(const ShaderClass &s)
Definition dazzle.cpp:468
virtual float Compute_Dazzle_Visibility(RenderInfoClass &rinfo, DazzleRenderObjClass *dazzle, const Vector3 &point) const
Definition dazzle.cpp:1656
Definition INI.H:80
TPoint3D< int > const Get_Point(char const *section, char const *entry, TPoint3D< int > const &defvalue) const
Definition ini.cpp:2080
float Get_Float(char const *section, char const *entry, float defvalue=0.0f) const
Definition ini.cpp:1486
char const * Get_Entry(char const *section, int index) const
Definition ini.cpp:828
INIClass(void)
Definition ini.cpp:172
int Section_Count(void) const
Definition ini.cpp:750
int Get_Int(char const *section, char const *entry, int defvalue=0) const
Definition ini.cpp:1315
int Get_String(char const *section, char const *entry, char const *defvalue, char *buffer, int size) const
Definition ini.cpp:1700
int Entry_Count(char const *section) const
Definition ini.cpp:772
INIEntry * Find_Entry(char const *section, char const *entry) const
Definition ini.cpp:800
Vector4 * flare_uv
Definition dazzle.h:120
StringClass texture_name
Definition dazzle.h:115
float * flare_sizes
Definition dazzle.h:118
unsigned type
Definition dazzle.h:114
Vector3 * flare_colors
Definition dazzle.h:119
float * flare_locations
Definition dazzle.h:117
TextureClass * Get_Texture()
Definition dazzle.cpp:358
void Generate_Vertex_Buffers(VertexFormatXYZNDUV2 *vertex, int &vertex_count, float screen_x_scale, float screen_y_scale, float dazzle_intensity, const Vector4 &transformed_location)
Definition dazzle.cpp:367
Vector3 Rotate_Vector(const Vector3 &vect) const
Definition matrix3d.cpp:300
WWINLINE Vector3 Get_Translation(void) const
Definition matrix3d.h:217
void Look_At(const Vector3 &p, const Vector3 &t, float roll)
Definition matrix3d.cpp:354
WWINLINE void Release_Ref(void) const
Definition refcount.h:146
void Add_Ref(void) const
Definition refcount.cpp:171
CameraClass & Camera
Definition rinfo.h:100
Vector3 Get_Position(void) const
Definition rendobj.cpp:508
virtual void Set_Transform(const Matrix3D &m)
Definition rendobj.cpp:423
virtual int Is_Not_Hidden_At_All(void)
Definition rendobj.h:463
RenderObjClass(void)
Definition rendobj.cpp:170
virtual SceneClass * Get_Scene(void)
Definition rendobj.cpp:361
const Matrix3D & Get_Transform(void) const
Definition rendobj.h:617
RenderObjClass * Get_Container(void) const
Definition rendobj.h:291
static void Register_Pointer(void *old_pointer, void *new_pointer)
Definition saveload.cpp:210
virtual float Compute_Point_Visibility(RenderInfoClass &rinfo, const Vector3 &point)
Definition scene.h:176
@ GRADIENT_MODULATE
Definition shader.h:193
@ PASS_LEQUAL
Definition shader.h:106
@ PASS_ALWAYS
Definition shader.h:110
@ FOG_DISABLE
Definition shader.h:183
@ TEXTURING_DISABLE
Definition shader.h:219
@ TEXTURING_ENABLE
Definition shader.h:220
@ CULL_MODE_DISABLE
Definition shader.h:158
@ DEPTH_WRITE_DISABLE
Definition shader.h:116
@ SRCBLEND_ONE
Definition shader.h:211
@ DSTBLEND_ZERO
Definition shader.h:172
@ DSTBLEND_ONE
Definition shader.h:173
@ DSTBLEND_SRC_ALPHA
Definition shader.h:176
VisRasterizerClass * VisRasterizer
Definition rinfo.h:153
float Radius
Definition sphere.h:91
Vector3 Center
Definition sphere.h:90
int _cdecl Format(const TCHAR *format,...)
Definition wwstring.cpp:273
TPoint3D< T > const Normalize(void) const
Definition Point.h:167
float Y
Definition vector2.h:79
float X
Definition vector2.h:74
static WWINLINE float Dot_Product(const Vector3 &a, const Vector3 &b)
Definition vector3.h:293
WWINLINE void Set(float x, float y, float z)
Definition vector3.h:103
CameraClass * Peek_Camera(void)
void Enable_Two_Sided_Rendering(bool onoff)
void Set_Model_Transform(const Matrix3D &model)
bool Render_Triangles(const Vector3 *verts, int vcount, const TriIndex *tris, int tcount, const AABoxClass &bounds)
virtual TextureClass * Get_Texture(const char *filename, MipCountType mip_level_count=MIP_LEVELS_ALL, WW3DFormat texture_format=WW3D_FORMAT_UNKNOWN, bool allow_compression=true, TextureBaseClass::TexAssetType type=TextureBaseClass::TEX_REGULAR, bool allow_reduction=true)
virtual RenderObjClass * Create_Render_Obj(const char *name)
Definition assetmgr.cpp:799
static WW3DAssetManager * Get_Instance(void)
Definition assetmgr.h:205
static unsigned int Get_Sync_Time(void)
Definition ww3d.h:172
static unsigned int Get_Frame_Time(void)
Definition ww3d.h:173
static void Get_Device_Resolution(int &set_w, int &set_h, int &get_bits, bool &get_windowed)
Definition ww3d.cpp:670
static float Clamp(float val, float min=0.0f, float max=1.0f)
Definition wwmath.h:208
const char * DAZZLE_INTENSITY_STRING
Definition dazzle.cpp:94
const char * USE_CAMERA_TRANSLATION
Definition dazzle.cpp:120
const char * DAZZLE_TEST_COLOR_STRING
Definition dazzle.cpp:127
const char * HALO_COLOR_STRING
Definition dazzle.cpp:123
const char * HALO_INTENSITY_POW
Definition dazzle.cpp:84
const char * DAZZLE_TEXTURE_STRING
Definition dazzle.cpp:115
const char * HALO_TEXTURE_STRING
Definition dazzle.cpp:116
const char * DAZZLE_SCALE_X_STRING
Definition dazzle.cpp:89
const char * BLINK_ON_TIME_STRING
Definition dazzle.cpp:132
const char * FLARE_LOCATION_STRING
Definition dazzle.cpp:150
const char * DAZZLE_LIST_STRING
Definition dazzle.cpp:74
const char * DAZZLE_COLOR_STRING
Definition dazzle.cpp:124
const char * FLARE_UV_STRING
Definition dazzle.cpp:160
const char * BLINK_PERIOD_STRING
Definition dazzle.cpp:131
const char * DAZZLE_AREA_STRING
Definition dazzle.cpp:83
const char * DAZZLE_DIRECTION_AREA_STRING
Definition dazzle.cpp:100
const char * DAZZLE_LENSFLARE_STRING
Definition dazzle.cpp:135
const char * FLARE_SIZE_STRING
Definition dazzle.cpp:153
DazzleLoaderClass _DazzleLoader
Definition dazzle.cpp:228
const char * HISTORY_WEIGHT_STRING
Definition dazzle.cpp:112
const char * LENSFLARE_TEXTURE_STRING
Definition dazzle.cpp:141
const char * FLARE_COUNT_STRING
Definition dazzle.cpp:146
const char * DAZZLE_DIRECTION_STRING
Definition dazzle.cpp:101
const char * HALO_SCALE_Y_STRING
Definition dazzle.cpp:88
const char * DAZZLE_INTENSITY_POW_STRING
Definition dazzle.cpp:81
const char * FADEOUT_START_STRING
Definition dazzle.cpp:104
const char * HALO_INTENSITY_STRING
Definition dazzle.cpp:93
const char * FADEOUT_END_STRING
Definition dazzle.cpp:105
const char * HALO_SCALE_X_STRING
Definition dazzle.cpp:87
const char * SIZE_OPTIMIZATION_LIMIT_STRING
Definition dazzle.cpp:108
const char * FLARE_COLOR_STRING
Definition dazzle.cpp:156
const char * RADIUS_STRING
Definition dazzle.cpp:163
const char * DAZZLE_SCALE_Y_STRING
Definition dazzle.cpp:90
const char * LENSFLARE_LIST_STRING
Definition dazzle.cpp:138
const char * DAZZLE_SIZE_POW_STRING
Definition dazzle.cpp:82
const unsigned dynamic_fvf_type
@ BUFFER_TYPE_DYNAMIC_DX8
Definition dx8wrapper.h:90
Vector3i16 TriIndex
#define SET_REF_OWNER(P)
Definition refcount.h:63
#define REF_PTR_RELEASE(x)
Definition refcount.h:80
#define NEW_REF(C, P)
Definition refcount.h:62
Definition inisup.h:56
char * Value
Definition inisup.h:64
WW3DErrorType
Definition w3derr.h:51
@ WW3D_ERROR_OK
Definition w3derr.h:52
@ WW3D_PERSIST_CHUNKID_DAZZLE
Definition ww3dids.h:74
#define WWDEBUG_SAY(x)
Definition wwdebug.h:114
#define WWPROFILE(name)
Definition wwprofile.h:270