Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
mapper.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:: /Commando/Code/ww3d2/mapper.cpp $*
26 * *
27 * $Org Author:: Hector_y $*
28 * *
29 * $Author:: Kenny Mitchell *
30 * *
31 * $Modtime:: 06/26/02 4:04p $*
32 * *
33 * $Revision:: 33 $*
34 * *
35 * 06/26/02 KM Matrix name change to avoid MAX conflicts *
36 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
37
38#include "mapper.h"
39#include "ww3d.h"
40#include "ini.h"
41#include "chunkio.h"
42#include "w3derr.h"
43#include "meshmatdesc.h"
44#include "dx8wrapper.h"
45#include "wwdebug.h"
46#include "matinfo.h"
47#include "rendobj.h"
48#include "mesh.h"
49#include <random.h>
50#include <bound.h>
51
53
54inline DWORD F2DW( FLOAT f ) { return *((DWORD*)&f); }
55
56
57// HY 1/26/01
58// Rewritten to use DX 8 texture matrices
59
65
66
67// Scale mapper
68// HY 5/16/01
74
75ScaleTextureMapperClass::ScaleTextureMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
76 TextureMapperClass(stage)
77{
78 Scale.U = ini.Get_Float(section, "UScale", 1.0f);
79 Scale.V = ini.Get_Float(section, "VScale", 1.0f);
80}
81
87
88void ScaleTextureMapperClass::Apply(int uv_array_index)
89{
90 // Set up the texture matrix
91 Matrix4x4 m;
93 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
94
95 // Disable Texgen
96 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_PASSTHRU | uv_array_index);
97
98 // Tell rasterizer to expect 2D texture coordinates
99 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
100}
101
103{
104 tex_matrix.Make_Identity();
105 tex_matrix[0].X = Scale.U;
106 tex_matrix[1].Y = Scale.V;
107}
108
109// Linear Offset Mapper
111 const Vector2 & start_offset, bool clamp_fix, const Vector2 &scale, unsigned int stage) :
113 LastUsedSyncTime(WW3D::Get_Sync_Time()),
114 StartingUVOffset(start_offset),
115 ClampFix(clamp_fix)
116{
118
119 // HY 5/16/01
120 // This is horrible disgusting legacy from the unmentionable API we used before
121 // leaving it unchanged because the artists have worked around it
122 UVOffsetDeltaPerMS = offset_per_sec * -0.001f;
123}
124
125LinearOffsetTextureMapperClass::LinearOffsetTextureMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
126 ScaleTextureMapperClass(ini,section,stage),
127 LastUsedSyncTime(WW3D::Get_Sync_Time())
128{
129 float u_offset_per_sec = ini.Get_Float(section, "UPerSec", 0.0f);
130 float v_offset_per_sec = ini.Get_Float(section, "VPerSec", 0.0f);
131 UVOffsetDeltaPerMS = Vector2(u_offset_per_sec, v_offset_per_sec) * -0.001f;
132
133 float u_start_offset = ini.Get_Float(section, "UOffset", 0.0f);
134 float v_start_offset = ini.Get_Float(section, "VOffset", 0.0f);
135 StartingUVOffset.Set(u_start_offset, v_start_offset);
137
138 ClampFix = ini.Get_Bool(section, "ClampFix", false);
139}
140
150
156
158{
159 unsigned int delta = WW3D::Get_Sync_Time() - LastUsedSyncTime;
160 float del = (float)delta;
161 float offset_u = CurrentUVOffset.X + UVOffsetDeltaPerMS.X * del;
162 float offset_v = CurrentUVOffset.Y + UVOffsetDeltaPerMS.Y * del;
163
164 // We need to clamp these texture coordinates to a reasonable range so the hardware doesn't
165 // choke on them. We do this in one of two ways:
166 // If ClampFix is not TRUE we use the fractional part of the offset, restricting it between
167 // 0 and 1 with wraparound. This works well for tiled textures.
168 // If ClampFix is TRUE we clamp the offsets between -Scale and +Scale with no wraparound.
169 // This works well for clamped textures.
170 if (!ClampFix) {
171 offset_u = offset_u - WWMath::Floor(offset_u);
172 offset_v = offset_v - WWMath::Floor(offset_v);
173 } else {
174 offset_u = WWMath::Clamp(offset_u, -Scale.X, Scale.X);
175 offset_v = WWMath::Clamp(offset_v, -Scale.Y, Scale.Y);
176 }
177
178 // Set up the offset matrix
179 tex_matrix.Make_Identity();
180
181 // According to the docs this should work since its 2D
182 // otherwise change to translate
183 tex_matrix[0].Z=offset_u;
184 tex_matrix[0].X=Scale.X;
185 tex_matrix[1].Z=offset_v;
186 tex_matrix[1].Y=Scale.Y;
187
188 // Update state
189 CurrentUVOffset.X = offset_u;
190 CurrentUVOffset.Y = offset_v;
192}
193
194// Grid Mapper
195// HY 5/16/01
196GridTextureMapperClass::GridTextureMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, unsigned int stage) :
197 TextureMapperClass(stage),
198 LastFrame(last_frame),
199 Offset(offset)
200{
201 initialize(fps, gridwidth_log2);
202}
203
204GridTextureMapperClass::GridTextureMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
205 TextureMapperClass(stage)
206{
207 float fps = ini.Get_Float(section, "FPS", 1.0f);
208 unsigned int gridwidth_log2 = ini.Get_Int(section, "Log2Width", 1);
209 LastFrame = ini.Get_Int(section, "Last", 0);
210 Offset = ini.Get_Int(section, "Offset", 0);
211 initialize(fps, gridwidth_log2);
212}
213
225
226void GridTextureMapperClass::Apply(int uv_array_index)
227{
228 // Set up the texture matrix
229 Matrix4x4 m;
231 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage), m);
232
233 // Disable Texgen
234 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU | uv_array_index);
235
236 // Tell rasterizer to expect 2D texture coordinates
237 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
238}
239
241{
242 Remainder = 0;
243 if (Sign >= 0) {
245 } else {
246 CurrentFrame = (LastFrame - 1) - Offset;
247 }
249}
250
252{
254
255 float u_offset, v_offset;
256 calculate_uv_offset(&u_offset, &v_offset);
257
258 // Set up the offset matrix
259 tex_matrix.Make_Identity();
260
261 // According to the docs this should work since its 2D
262 // otherwise change to translate
263 tex_matrix[0].Z = u_offset;
264 tex_matrix[1].Z = v_offset;
265}
266
271
272void GridTextureMapperClass::initialize(float fps, unsigned int gridwidth_log2)
273{
274 unsigned int grid_width = (1 << gridwidth_log2);
275
276 if (LastFrame == 0) LastFrame = (grid_width * grid_width);
279 GridWidthLog2 = gridwidth_log2;
280 OOGridWidth = 1.0f / (float)(grid_width);
281 if (fps == 0.0f) {
282 // Value of MSPerFrame does not matter as long as it is not 0 - sign will multiply results,
283 // zeroing them out.
284 Sign = 0;
285 MSPerFrame = 1;
287 } else if (fps < 0.0f) {
288 Sign = -1;
289 MSPerFrame = (unsigned int)(1000.0f / fabs(fps));
290 CurrentFrame = (LastFrame - 1) - Offset;
291 } else {
292 Sign = 1;
293 MSPerFrame = (unsigned int)(1000.0f / fabs(fps));
295 }
296 Remainder = 0;
297}
298
300{
301 unsigned int now = WW3D::Get_Sync_Time();
302 unsigned int delta = now - LastUsedSyncTime;
303 Remainder += delta;
304 LastUsedSyncTime = now;
305
306 int new_frame = (int)CurrentFrame + ((int)(Remainder / MSPerFrame) * Sign);
307 new_frame=new_frame % LastFrame;
308
309 if (new_frame<0) {
310 CurrentFrame=LastFrame+new_frame;
311 } else {
312 CurrentFrame=(unsigned int) new_frame;
313 }
315}
316
317void GridTextureMapperClass::calculate_uv_offset(float * u_offset, float * v_offset)
318{
319 unsigned int row_mask = ~(0xFFFFFFFF << GridWidthLog2);
320 unsigned int col_mask = row_mask << GridWidthLog2;
321 unsigned int x = CurrentFrame & row_mask;
322 unsigned int y = (CurrentFrame & col_mask) >> GridWidthLog2;
323 *u_offset = x * OOGridWidth;
324 *v_offset = y * OOGridWidth;
325}
326
327// Rotate Mapper
328// HY 5/16/01
329RotateTextureMapperClass::RotateTextureMapperClass(float rad_per_sec, const Vector2 &center, const Vector2 &scale, unsigned int stage) :
331 LastUsedSyncTime(WW3D::Get_Sync_Time()),
332 CurrentAngle(0.0f),
333 RadiansPerMilliSec(rad_per_sec/1000.0f),
334 Center(center)
335{
336}
337
338RotateTextureMapperClass::RotateTextureMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
339 ScaleTextureMapperClass(ini, section, stage),
340 LastUsedSyncTime(WW3D::Get_Sync_Time()),
341 CurrentAngle(0.0f)
342{
343 RadiansPerMilliSec=2*WWMATH_PI*ini.Get_Float(section,"Speed",0.1f)/1000.0f;
344 Center.U=ini.Get_Float(section,"UCenter",0.0f);
345 Center.V=ini.Get_Float(section,"VCenter",0.0f);
346}
347
350 LastUsedSyncTime(WW3D::Get_Sync_Time()),
351 RadiansPerMilliSec(src.RadiansPerMilliSec),
352 CurrentAngle(0.0f),
353 Center(src.Center)
354{
355}
356
358{
359 CurrentAngle = 0.0f;
360 LastUsedSyncTime = WW3D::Get_Sync_Time();
361}
362
364{
365 unsigned int now = WW3D::Get_Sync_Time();
366 unsigned int delta = now - LastUsedSyncTime;
367 LastUsedSyncTime=now;
368
369 CurrentAngle+=RadiansPerMilliSec * delta;
370 CurrentAngle=fmodf(CurrentAngle,2*WWMATH_PI);
371 if (CurrentAngle<0.0f) CurrentAngle+=2*WWMATH_PI;
372
373 // Set up the rotation matrix
374 float c,s;
375 c=WWMath::Cos(CurrentAngle);
376 s=WWMath::Sin(CurrentAngle);
377 tex_matrix.Make_Identity();
378
379 // subtract center
380 // rotate
381 // add center
382 // then scale
383 tex_matrix[0].Set(Scale.X * c, -Scale.X * s, -Scale.X * (c * Center.U - s * Center.V - Center.U), 0.0f);
384 tex_matrix[1].Set(Scale.Y * s, Scale.Y * c, -Scale.Y * (s * Center.U + c * Center.V - Center.V), 0.0f);
385}
386
387// SineLinearOffset Mapper
388// HY 5/16/01
391 LastUsedSyncTime(WW3D::Get_Sync_Time()),
392 UAFP(uafp),
393 VAFP(vafp),
394 CurrentAngle(0.0f)
395{
396}
397
398SineLinearOffsetTextureMapperClass::SineLinearOffsetTextureMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
399 ScaleTextureMapperClass(ini, section, stage),
400 LastUsedSyncTime(WW3D::Get_Sync_Time()),
401 CurrentAngle(0.0f)
402{
403 UAFP.X = ini.Get_Float(section, "UAmp", 1.0f);
404 UAFP.Y = ini.Get_Float(section, "UFreq", 1.0f);
405 UAFP.Z = ini.Get_Float(section, "UPhase", 0.0f);
406
407 VAFP.X = ini.Get_Float(section, "VAmp", 1.0f);
408 VAFP.Y = ini.Get_Float(section, "VFreq", 1.0f);
409 VAFP.Z = ini.Get_Float(section, "VPhase", 0.0f);
410}
411
414 LastUsedSyncTime(WW3D::Get_Sync_Time()),
415 UAFP(src.UAFP),
416 VAFP(src.VAFP),
417 CurrentAngle(0.0f)
418{
419}
420
422{
423 CurrentAngle = 0.0f;
424 LastUsedSyncTime = WW3D::Get_Sync_Time();
425}
426
428{
429 unsigned int now = WW3D::Get_Sync_Time();
430 unsigned int delta = now - LastUsedSyncTime;
431 LastUsedSyncTime=now;
432
433 const float ms_to_radians=2*WWMATH_PI/1000.0f;
434
435 CurrentAngle+=delta*ms_to_radians;
436
437 float offset_u=UAFP.X*sin(UAFP.Y*CurrentAngle+UAFP.Z*WWMATH_PI);
438 float offset_v=VAFP.X*sin(VAFP.Y*CurrentAngle+VAFP.Z*WWMATH_PI);
439
440 // Set up the offset matrix
441 tex_matrix.Make_Identity();
442
443 // According to the docs this should work since its 2D
444 // otherwise change to translate
445 tex_matrix[0].Z = offset_u;
446 tex_matrix[0].X = Scale.X;
447 tex_matrix[1].Z = offset_v;
448 tex_matrix[1].Y = Scale.Y;
449}
450
451// StepLinearOffset Mapper
452// HY 5/16/01
454 float steps_per_sec, bool clamp_fix, const Vector2 &scale, unsigned int stage) :
456 LastUsedSyncTime(WW3D::Get_Sync_Time()),
457 Step(step),
458 StepsPerMilliSec(steps_per_sec/1000.0f),
459 CurrentStep(0.0f,0.0f),
460 Remainder(0),
461 ClampFix(clamp_fix)
462{
463}
464
465StepLinearOffsetTextureMapperClass::StepLinearOffsetTextureMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
466 ScaleTextureMapperClass(ini, section, stage),
467 LastUsedSyncTime(WW3D::Get_Sync_Time()),
468 CurrentStep(0.0f,0.0f),
469 Remainder(0)
470{
471 Step.U = ini.Get_Float(section, "UStep", 0.0f);
472 Step.V = ini.Get_Float(section, "VStep", 0.0f);
473 StepsPerMilliSec = ini.Get_Float(section, "SPS", 0.0f)/1000.0f;
474 ClampFix = ini.Get_Bool(section, "ClampFix", false);
475}
476
479 LastUsedSyncTime(WW3D::Get_Sync_Time()),
480 Step(src.Step),
481 StepsPerMilliSec(src.StepsPerMilliSec),
482 CurrentStep(0.0f,0.0f),
483 Remainder(0),
484 ClampFix(src.ClampFix)
485{
486}
487
489{
490 LastUsedSyncTime = WW3D::Get_Sync_Time();
491 CurrentStep.Set(0.0f,0.0f);
492 Remainder=0;
493}
494
496{
497 unsigned int now = WW3D::Get_Sync_Time();
498 unsigned int delta = now - LastUsedSyncTime;
499 LastUsedSyncTime=now;
500
501 Remainder+=delta;
502 int num_steps=(int) (StepsPerMilliSec*Remainder);
503
504 if (num_steps!=0)
505 {
506 CurrentStep+=Step*num_steps;
507 Remainder-=num_steps/(float)StepsPerMilliSec;
508 }
509
510 // We need to clamp these texture coordinates to a reasonable range so the hardware doesn't
511 // choke on them. We do this in one of two ways:
512 // If ClampFix is not TRUE we use the fractional part of the offset, restricting it between
513 // 0 and 1 with wraparound. This works well for tiled textures.
514 // If ClampFix is TRUE we clamp the offsets between -Scale and +Scale with no wraparound.
515 // This works well for clamped textures.
516 if (!ClampFix) {
517 CurrentStep.U -= WWMath::Floor(CurrentStep.U);
518 CurrentStep.V -= WWMath::Floor(CurrentStep.V);
519 } else {
520 CurrentStep.U = WWMath::Clamp(CurrentStep.U, -Scale.X, Scale.X);
521 CurrentStep.V = WWMath::Clamp(CurrentStep.V, -Scale.Y, Scale.Y);
522 }
523
524 // Set up the offset matrix
525 tex_matrix.Make_Identity();
526
527 // According to the docs this should work since its 2D
528 // otherwise change to translate
529 tex_matrix[0].Z = CurrentStep.U;
530 tex_matrix[0].X = Scale.X;
531 tex_matrix[1].Z = CurrentStep.V;
532 tex_matrix[1].Y = Scale.Y;
533}
534
535// ZigZagLinearOffset Mapper
536// HY 5/16/01
539 LastUsedSyncTime(WW3D::Get_Sync_Time()),
540 Speed(speed/1000.0f),
541 Period(period*1000.0f),
542 Remainder(0)
543{
544 // since we're zigzagging, a negative period is the same as a positive one
545 if (Period<0.0f) Period=-Period;
546 Half_Period=0.5f*Period;
547}
548
550 ScaleTextureMapperClass(ini, section, stage),
551 LastUsedSyncTime(WW3D::Get_Sync_Time()),
552 Remainder(0)
553{
554 Speed.U = ini.Get_Float(section, "UPerSec", 0.0f)/1000.0f;
555 Speed.V = ini.Get_Float(section, "VPerSec", 0.0f)/1000.0f;
556 Period = ini.Get_Float(section, "Period", 0.0f)*1000.0f;
557 if (Period<0.0f) Period=-Period;
558 Half_Period=0.5f*Period;
559}
560
563 LastUsedSyncTime(WW3D::Get_Sync_Time()),
564 Speed(src.Speed),
565 Period(src.Period),
566 Half_Period(src.Half_Period),
567 Remainder(0)
568{
569}
570
572{
573 LastUsedSyncTime = WW3D::Get_Sync_Time();
574 Remainder=0;
575}
576
578{
579 unsigned int now = WW3D::Get_Sync_Time();
580 unsigned int delta = now - LastUsedSyncTime;
581 LastUsedSyncTime=now;
582 Remainder+=delta;
583
584 float offset_u=0.0f;
585 float offset_v=0.0f;
586
587 if (Period>0.0f)
588 {
589 // figure out the fractional number of periods
590 int num_periods=(int) (Remainder/Period);
591 Remainder-=num_periods*Period;
592
593 float time=0.0f;
594 if (Remainder>Half_Period) {
595 time=Period-Remainder;
596 } else {
597 time=Remainder;
598 }
599 offset_u=Speed.U * time;
600 offset_v=Speed.V * time;
601 }
602
603 // Set up the offset matrix
604 tex_matrix.Make_Identity();
605
606 // According to the docs this should work since its 2D
607 // otherwise change to translate
608 tex_matrix[0].Z = offset_u;
609 tex_matrix[0].X = Scale.X;
610 tex_matrix[1].Z = offset_v;
611 tex_matrix[1].Y = Scale.Y;
612}
613
614// ----------------------------------------------------------------------------
615//
616// Environment mapper calculates the texture coordinates based on
617// transformed normals
618//
619// ----------------------------------------------------------------------------
620
622{
623 // Set up the texture matrix
624 Matrix4x4 m;
626 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
627
628 // Get camera normals
629 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACENORMAL);
630
631 // Tell rasterizer to expect 2D matrices
632 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
633
634}
635
637{
638 // The canonical environment map
639 // scale the normal by (.5,.5) and add (.5,.5) to move it to (0,1) range
640 // and ignore the Z component
641 tex_matrix.Init( 0.5f, 0.0f, 0.0f, 0.5f,
642 0.0f, 0.5f, 0.0f, 0.5f,
643 0.0f, 0.0f, 1.0f, 0.0f,
644 0.0f, 0.0f, 0.0f, 1.0f);
645}
646
647void EnvironmentMapperClass::Apply(int uv_array_index)
648{
649 // Set up the texture matrix
650 Matrix4x4 m;
652 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
653
654 // Get camera reflection vector
655 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
656
657 // Tell rasterizer to expect 2D matrices
658 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
659
660}
661
663{
664 // The canonical environment map
665 // scale the normal by (.5,.5) and add (.5,.5) to move it to (0,1) range
666 tex_matrix.Init( 0.5f, 0.0f, 0.0f, 0.5f,
667 0.0f, 0.5f, 0.0f, 0.5f,
668 0.0f, 0.0f, 1.0f, 0.0f,
669 0.0f, 0.0f, 0.0f, 1.0f );
670}
671
672// Edge mapper
674 TextureMapperClass(stage),
675 VSpeed(0.0f),
677 LastUsedSyncTime(WW3D::Get_Sync_Time()),
678 VOffset(0.0f)
679{
680}
681
682EdgeMapperClass::EdgeMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
683 TextureMapperClass(stage),
684 VSpeed(0.0f),
686 LastUsedSyncTime(WW3D::Get_Sync_Time()),
687 VOffset(0.0f)
688{
689 VSpeed=ini.Get_Float(section, "VPerSec", 0.0f);
690 VOffset=ini.Get_Float(section, "VStart", 0.0f);
691 UseReflect=ini.Get_Bool(section, "UseReflect", false);
692}
693
696 VSpeed(src.VSpeed),
698 VOffset(src.VOffset),
699 LastUsedSyncTime(WW3D::Get_Sync_Time())
700{
701}
702
703void EdgeMapperClass::Apply(int uv_array_index)
704{
705 // Set up the texture matrix
706 Matrix4x4 m;
708 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
709
710 // Get camera reflection vector
711 if (UseReflect)
712 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
713 else
714 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACENORMAL);
715
716 // Tell rasterizer to expect 2D matrices
717 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
718
719}
720
722{
724 VOffset = 0.0f;
725}
726
728{
729 unsigned int now=WW3D::Get_Sync_Time();
730
731 float delta=(now-LastUsedSyncTime)*0.001f;
733
734 VOffset+=delta*VSpeed;
736
737 // takes the Z component and
738 // uses it to index the texture
739 tex_matrix.Init( 0.0f, 0.0f, 0.5f, 0.5f,
740 0.0f, 0.0f, 0.0f, VOffset,
741 0.0f, 0.0f, 1.0f, 0.0f,
742 0.0f, 0.0f, 0.0f, 1.0f );
743}
744
745WSEnvMapperClass::WSEnvMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
746 TextureMapperClass(stage),
748{
749 char temp[2];
750 ini.Get_String(section, "Axis", "Z", &temp[0], 2);
751 switch(temp[0]) {
752 case 'X':
753 case 'x':
755 break;
756 case 'Y':
757 case 'y':
759 break;
760 case 'Z':
761 case 'z':
763 break;
764 default:
766 break;
767 }
768}
769
771{
772 // The canonical environment map
773 // scale the normal by (.5,.5) and add (.5,.5) to move it to (0,1) range
774 switch (Axis) {
775 case AXISTYPE_X:
776 tex_matrix.Init( 0.0f, 0.5f, 0.0f, 0.5f,
777 0.0f, 0.0f, 0.5f, 0.5f,
778 0.0f, 0.0f, 1.0f, 0.0f,
779 0.0f, 0.0f, 0.0f, 1.0f );
780 break;
781 case AXISTYPE_Y:
782 tex_matrix.Init( 0.5f, 0.0f, 0.0f, 0.5f,
783 0.0f, 0.0f, 0.5f, 0.5f,
784 0.0f, 0.0f, 1.0f, 0.0f,
785 0.0f, 0.0f, 0.0f, 1.0f );
786 break;
787 case AXISTYPE_Z:
788 default:
789 tex_matrix.Init( 0.5f, 0.0f, 0.0f, 0.5f,
790 0.0f, 0.5f, 0.0f, 0.5f,
791 0.0f, 0.0f, 1.0f, 0.0f,
792 0.0f, 0.0f, 0.0f, 1.0f );
793 break;
794 }
795 // multiply by inverse of view transform
796 Matrix4x4 mat;
797 DX8Wrapper::Get_Transform(D3DTS_VIEW,mat);
798 Matrix4x4 mat2( mat[0].X, mat[1].X, mat[2].X, 0.0f,
799 mat[0].Y, mat[1].Y, mat[2].Y, 0.0f,
800 mat[0].Z, mat[1].Z, mat[2].Z, 0.0f,
801 0.0f, 0.0f, 0.0f, 1.0f );
802 tex_matrix = tex_matrix * mat2;
803}
804
806{
807 // Set up the texture matrix
808 Matrix4x4 m;
810 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
811
812 // Get camera normals
813 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACENORMAL);
814
815 // Tell rasterizer to expect 2D matrices
816 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
817
818}
819
820void WSEnvironmentMapperClass::Apply(int uv_array_index)
821{
822 // Set up the texture matrix
823 Matrix4x4 m;
825 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
826
827 // Get camera reflection
828 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
829
830 // Tell rasterizer to expect 2D matrices
831 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
832
833}
834
836{
837 // Set up the texture matrix
838 Matrix4x4 m;
840 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
841
842 // Get camera normals
843 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACENORMAL);
844
845 // Tell rasterizer to expect 2D matrices
846 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
847}
848
850{
852
853 float u_offset, v_offset;
854 calculate_uv_offset(&u_offset, &v_offset);
855
856 float del = 0.5f * OOGridWidth;
857 // Set up the offset matrix
858 tex_matrix.Init( del, 0.0f, 0.0f, u_offset + del,
859 0.0f, del, 0.0f, v_offset + del,
860 0.0f, 0.0f, 1.0f, 0.0f,
861 0.0f, 0.0f, 0.0f, 1.0f );
862}
863
864void GridEnvironmentMapperClass::Apply(int uv_array_index)
865{
866 // Set up the texture matrix
867 Matrix4x4 m;
869 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
870
871 // Get camera space reflection
872 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
873
874 // Tell rasterizer to expect 2D matrices
875 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
876}
877
879{
881
882 float u_offset, v_offset;
883 calculate_uv_offset(&u_offset, &v_offset);
884
885 float del=0.5f * OOGridWidth;
886 // Set up the offset matrix
887 tex_matrix.Init( del, 0.0f, 0.0f, u_offset + del,
888 0.0f, del, 0.0f, v_offset + del,
889 0.0f, 0.0f, 1.0f, 0.0f,
890 0.0f, 0.0f, 0.0f, 1.0f );
891}
892
893void ScreenMapperClass::Apply(int uv_array_index)
894{
895 // Set up the texture matrix
896 Matrix4x4 m;
898 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
899
900 // Get camera space position
901 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEPOSITION);
902
903 // Tell rasterizer what to expect
904 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_PROJECTED | D3DTTFF_COUNT3);
905}
906
908{
909 unsigned int delta = WW3D::Get_Sync_Time() - LastUsedSyncTime;
910 float del = (float)delta;
911 float offset_u = CurrentUVOffset.X + UVOffsetDeltaPerMS.X * del;
912 float offset_v = CurrentUVOffset.Y + UVOffsetDeltaPerMS.Y * del;
913
914 // We need to clamp these texture coordinates to a reasonable range so the hardware doesn't
915 // choke on them. We do this in one of two ways:
916 // If ClampFix is not TRUE we use the fractional part of the offset, restricting it between
917 // 0 and 1 with wraparound. This works well for tiled textures.
918 // If ClampFix is TRUE we clamp the offsets between -Scale and +Scale with no wraparound.
919 // This works well for clamped textures.
920 if (!ClampFix) {
921 offset_u = offset_u - WWMath::Floor(offset_u);
922 offset_v = offset_v - WWMath::Floor(offset_v);
923 } else {
924 offset_u = WWMath::Clamp(offset_u, -Scale.X, Scale.X);
925 offset_v = WWMath::Clamp(offset_v, -Scale.Y, Scale.Y);
926 }
927
928 // multiply by projection matrix
929 // followed by scale and translation
930 DX8Wrapper::Get_Transform(D3DTS_PROJECTION, tex_matrix);
931 tex_matrix[0] *= Scale.X; // entire row since we're pre-multiplying
932 tex_matrix[1] *= Scale.Y;
933 Vector4 last(tex_matrix[3]); // this gets the w
934 last *= offset_u; // multiply by w because the projected flag will divide by w
935 tex_matrix[0] += last;
936 last = tex_matrix[3];
937 last *= offset_v;
938 tex_matrix[1] += last;
939
940 // Update state
941 CurrentUVOffset.X = offset_u;
942 CurrentUVOffset.Y = offset_v;
944}
945
948 FPMS(fps/1000.0f),
949 LastUsedSyncTime(WW3D::Get_Sync_Time()),
950 Speed(0.0f,0.0f),
951 Remainder(0)
952{
953 randomize();
954}
955
956RandomTextureMapperClass::RandomTextureMapperClass(const INIClass &ini, const char *section, unsigned int stage):
957 ScaleTextureMapperClass(ini, section, stage),
958 LastUsedSyncTime(WW3D::Get_Sync_Time()),
959 Remainder(0)
960{
961 FPMS = ini.Get_Float(section, "FPS", 0.0f)/1000.0f;
962 Speed.U = ini.Get_Float(section, "UPerSec", 0.0f)/1000.0f;
963 Speed.V = ini.Get_Float(section, "VPerSec", 0.0f)/1000.0f;
964 randomize();
965}
966
976
978{
979 CurrentAngle=2*WWMATH_PI*rand4.Get_Float();
980 Center.U=rand4.Get_Float();
981 Center.V=rand4.Get_Float();
982}
983
989
991{
992 unsigned int now = WW3D::Get_Sync_Time();
993 unsigned int delta=now-LastUsedSyncTime;
995 Remainder+=delta;
996
997 if (FPMS!=0.0f) {
998
999 int num_frames=(int) (Remainder*FPMS);
1000
1001 if (num_frames!=0) {
1002 randomize();
1003 Remainder-=num_frames/FPMS;
1004 }
1005 }
1006
1007 // Set up the random matrix - start with a rotation matrix of 'CurrentAngle' about the Z-axis.
1008 // We apply the scale matrix to the right of the unscaled rotate/offset matrix, because we
1009 // don't want the scaling to affect the offset. So we get:
1010 // [ c -s uoff ] [ Sx 0 0 ] [ cSx -sSy uoff ]
1011 // [ s c voff ] * [ 0 Sy 0 ] = [ sSx cSy voff ]
1012 // [ 0 0 1 ] [ 0 0 1 ] [ 0 0 1 ]
1013 float c = cosf(CurrentAngle);
1014 float s = sinf(CurrentAngle);
1015 tex_matrix.Make_Identity();
1016 tex_matrix[0][0] = c * Scale.X;
1017 tex_matrix[0][1] = -s * Scale.Y;
1018 tex_matrix[1][0] = s * Scale.X;
1019 tex_matrix[1][1] = c * Scale.Y;
1020
1021 // Offset matrix
1022 float uoff = Center.U + Remainder * Speed.U;
1023 float voff = Center.V + Remainder * Speed.V;
1024 uoff = fmodf(uoff, 1.0f);
1025 voff = fmodf(voff, 1.0f);
1026 tex_matrix[0].Z = uoff;
1027 tex_matrix[1].Z = voff;
1028}
1029
1030// BumpEnv Mapper
1031// GTH 8/22/01
1032BumpEnvTextureMapperClass::BumpEnvTextureMapperClass(float rad_per_sec, float scale_factor,
1033 const Vector2 & offset_per_sec, const Vector2 & start_offset, bool clamp_fix,
1034 const Vector2 &scale, unsigned int stage) :
1035 LinearOffsetTextureMapperClass(offset_per_sec, start_offset, clamp_fix, scale, stage),
1036 LastUsedSyncTime(WW3D::Get_Sync_Time()),
1037 CurrentAngle(0.0f),
1038 RadiansPerSecond(rad_per_sec),
1039 ScaleFactor(scale_factor)
1040{
1041}
1042
1043BumpEnvTextureMapperClass::BumpEnvTextureMapperClass(INIClass &ini, char *section, unsigned int stage) :
1044 LinearOffsetTextureMapperClass(ini, section, stage),
1045 LastUsedSyncTime(WW3D::Get_Sync_Time()),
1046 CurrentAngle(0.0f)
1047{
1048 RadiansPerSecond = 2*WWMATH_PI*ini.Get_Float(section,"BumpRotation",0.0f);
1049 ScaleFactor = ini.Get_Float(section,"BumpScale",1.0f);
1050}
1051
1060
1061void BumpEnvTextureMapperClass::Apply(int uv_array_index)
1062{
1064
1065 unsigned int now = WW3D::Get_Sync_Time();
1066 unsigned int delta = now - LastUsedSyncTime;
1067 LastUsedSyncTime=now;
1068
1069 CurrentAngle+=RadiansPerSecond * delta * 0.001f;
1071
1072 // Compute the sine and cosine for the bump matrix
1073 float c,s;
1076
1077 // Set the Bump Environment Matrix
1078 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_BUMPENVMAT00, F2DW(c));
1079 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_BUMPENVMAT01, F2DW(-s));
1080 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_BUMPENVMAT10, F2DW(s));
1081 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_BUMPENVMAT11, F2DW(c));
1082}
1083
1084/*
1085** Utility functions
1086*/
1087void Reset_All_Texture_Mappers(RenderObjClass *robj, bool make_unique)
1088{
1089
1091 MeshClass *mesh=(MeshClass*) robj;
1092 MaterialInfoClass *minfo = robj->Get_Material_Info();
1093 if (minfo && minfo->Has_Time_Variant_Texture_Mappers()) {
1094 if (make_unique) {
1095 mesh->Make_Unique();
1097 }
1098 minfo->Reset_Texture_Mappers();
1099 minfo->Release_Ref();
1100 }
1101 } else {
1102 int num_obj = robj->Get_Num_Sub_Objects();
1103 RenderObjClass *sub_obj;
1104
1105 for (int i = 0; i < num_obj; i++) {
1106 sub_obj = robj->Get_Sub_Object(i);
1107 if (sub_obj) {
1108 Reset_All_Texture_Mappers(sub_obj, make_unique);
1109 sub_obj->Release_Ref();
1110 }
1111 }
1112 }
1113}
1114
1115
1116GridWSEnvMapperClass::GridWSEnvMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, AxisType axis, unsigned int stage):
1117 GridTextureMapperClass(fps, gridwidth_log2, last_frame, offset, stage),
1118 Axis(axis)
1119{
1120}
1121
1127
1128GridWSEnvMapperClass::GridWSEnvMapperClass(const INIClass &ini, const char *section, unsigned int stage) :
1129 GridTextureMapperClass(ini, section, stage),
1131{
1132 char temp[2];
1133 ini.Get_String(section, "Axis", "Z", &temp[0], 2);
1134 switch(temp[0]) {
1135 case 'X':
1136 case 'x':
1137 Axis = AXISTYPE_X;
1138 break;
1139 case 'Y':
1140 case 'y':
1141 Axis = AXISTYPE_Y;
1142 break;
1143 case 'Z':
1144 case 'z':
1145 Axis = AXISTYPE_Z;
1146 break;
1147 default:
1148 Axis = AXISTYPE_Z;
1149 break;
1150 }
1151}
1152
1154{
1155 // multiply by inverse of view transform
1156 Matrix4x4 mat;
1157 DX8Wrapper::Get_Transform(D3DTS_VIEW,mat);
1158 Matrix4x4 mv ( mat[0].X, mat[1].X, mat[2].X, 0.0f,
1159 mat[0].Y, mat[1].Y, mat[2].Y, 0.0f,
1160 mat[0].Z, mat[1].Z, mat[2].Z, 0.0f,
1161 0.0f, 0.0f, 0.0f, 1.0f );
1162
1164
1165 float u_offset, v_offset;
1166 calculate_uv_offset(&u_offset, &v_offset);
1167
1168 float del=0.5f * OOGridWidth;
1169 // Set up the offset matrix
1170 Matrix4x4 md;
1171
1172 switch (Axis) {
1173 case AXISTYPE_X:
1174 md.Init( 0.0f, del, 0.0f, u_offset + del,
1175 0.0f, 0.0f, del, v_offset + del,
1176 0.0f, 0.0f, 1.0f, 0.0f,
1177 0.0f, 0.0f, 0.0f, 1.0f );
1178 break;
1179 case AXISTYPE_Y:
1180 md.Init( del, 0.0f, 0.0f, u_offset + del,
1181 0.0f, 0.0f, del, v_offset + del,
1182 0.0f, 0.0f, 1.0f, 0.0f,
1183 0.0f, 0.0f, 0.0f, 1.0f );
1184 break;
1185 case AXISTYPE_Z:
1186 default:
1187 md.Init( del, 0.0f, 0.0f, u_offset + del,
1188 0.0f, del, 0.0f, v_offset + del,
1189 0.0f, 0.0f, 1.0f, 0.0f,
1190 0.0f, 0.0f, 0.0f, 1.0f );
1191 break;
1192 }
1193 // multiply by inverse of view transform, then
1194 // change the world space reflection vector to a UV coordinate
1195 // then offset by the grid coordinate
1196
1197 tex_matrix = md * mv;
1198}
1199
1200/***********************************************************************************************
1201 * GridWSClassicEnvironmentMapperClass::GridWSClassicEnvironmentMapperClass -- Grid WS Env Map *
1202 * *
1203 * *
1204 * *
1205 * *
1206 * INPUT: *
1207 * *
1208 * OUTPUT: *
1209 * *
1210 * WARNINGS: *
1211 * *
1212 * HISTORY: *
1213 *=============================================================================================*/
1214GridWSClassicEnvironmentMapperClass::GridWSClassicEnvironmentMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, AxisType axis, unsigned int stage) :
1215 GridWSEnvMapperClass(fps, gridwidth_log2, last_frame, offset, axis, stage)
1216{
1217}
1218
1220 GridWSEnvMapperClass(ini,section,stage)
1221{
1222}
1223
1228
1230{
1231 // Set up the texture matrix
1232 Matrix4x4 m;
1234 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
1235
1236 // Get camera normals
1237 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACENORMAL);
1238
1239 // Tell rasterizer to expect 2D matrices
1240 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
1241}
1242
1243/***********************************************************************************************
1244 * GridWSEnvironmentMapperClass::GridWSEnvironmentMapperClass -- grid ws env *
1245 * *
1246 * *
1247 * *
1248 * *
1249 * INPUT: *
1250 * *
1251 * OUTPUT: *
1252 * *
1253 * WARNINGS: *
1254 * *
1255 * HISTORY: *
1256 * 1/29/2002 hy : Created. *
1257 *=============================================================================================*/
1258GridWSEnvironmentMapperClass::GridWSEnvironmentMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, AxisType axis, unsigned int stage) :
1259 GridWSEnvMapperClass(fps, gridwidth_log2, last_frame, offset, axis, stage)
1260{
1261}
1262
1263GridWSEnvironmentMapperClass::GridWSEnvironmentMapperClass(const INIClass &ini, const char *section, unsigned int stage):
1264 GridWSEnvMapperClass(ini, section, stage)
1265{
1266}
1267
1272
1274{
1275 // Set up the texture matrix
1276 Matrix4x4 m;
1278 DX8Wrapper::Set_Transform((D3DTRANSFORMSTATETYPE) (D3DTS_TEXTURE0+Stage),m);
1279
1280 // Get camera space reflection
1281 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
1282
1283 // Tell rasterizer to expect 2D matrices
1284 DX8Wrapper::Set_DX8_Texture_Stage_State(Stage,D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2);
1285}
Color scale(const Color &a, const Color &b)
Definition GameMtl.cpp:722
unsigned long DWORD
Definition bittype.h:57
@ false
Definition bool.h:59
#define WWMATH_PI
Definition wwmath.h:56
BumpEnvTextureMapperClass(float rad_per_sec, float scale_factor, const Vector2 &offset_per_sec, const Vector2 &start_offset, bool clamp_fix, const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:1032
unsigned int LastUsedSyncTime
Definition mapper.h:529
virtual void Apply(int uv_array_index)
Definition mapper.cpp:1061
virtual void Apply(int uv_array_index)
Definition mapper.cpp:621
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:636
static void Set_DX8_Texture_Stage_State(unsigned stage, D3DTEXTURESTAGESTATETYPE state, unsigned value)
Definition dx8wrapper.h:899
static void Get_Transform(D3DTRANSFORMSTATETYPE transform, Matrix4x4 &m)
static void Set_Transform(D3DTRANSFORMSTATETYPE transform, const Matrix4x4 &m)
float VOffset
Definition mapper.h:388
bool UseReflect
Definition mapper.h:389
virtual void Reset(void)
Definition mapper.cpp:721
unsigned int LastUsedSyncTime
Definition mapper.h:387
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:727
virtual void Apply(int uv_array_index)
Definition mapper.cpp:703
EdgeMapperClass(unsigned int stage)
Definition mapper.cpp:673
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:662
virtual void Apply(int uv_array_index)
Definition mapper.cpp:647
virtual void Apply(int uv_array_index)
Definition mapper.cpp:835
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:849
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:878
virtual void Apply(int uv_array_index)
Definition mapper.cpp:864
void update_temporal_state(void)
Definition mapper.cpp:299
virtual void Apply(int uv_array_index)
Definition mapper.cpp:226
void initialize(float fps, unsigned int gridwidth_log2)
Definition mapper.cpp:272
unsigned int Offset
Definition mapper.h:218
void calculate_uv_offset(float *u_offset, float *v_offset)
Definition mapper.cpp:317
unsigned int LastFrame
Definition mapper.h:217
unsigned int GridWidthLog2
Definition mapper.h:216
void Set_Frame_Per_Second(float fps)
Definition mapper.cpp:267
unsigned int MSPerFrame
Definition mapper.h:214
virtual void Reset(void)
Definition mapper.cpp:240
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:251
unsigned int CurrentFrame
Definition mapper.h:222
unsigned int LastUsedSyncTime
Definition mapper.h:223
GridTextureMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, unsigned int stage)
Definition mapper.cpp:196
unsigned int Remainder
Definition mapper.h:221
virtual void Apply(int uv_array_index)
Definition mapper.cpp:1229
GridWSClassicEnvironmentMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, AxisType axis, unsigned int stage)
Definition mapper.cpp:1214
GridWSEnvMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, AxisType axis, unsigned int stage)
Definition mapper.cpp:1116
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:1153
virtual void Apply(int uv_array_index)
Definition mapper.cpp:1273
GridWSEnvironmentMapperClass(float fps, unsigned int gridwidth_log2, unsigned int last_frame, unsigned int offset, AxisType axis, unsigned int stage)
Definition mapper.cpp:1258
Definition INI.H:80
float Get_Float(char const *section, char const *entry, float defvalue=0.0f) const
Definition ini.cpp:1486
bool Get_Bool(char const *section, char const *entry, bool defvalue=false) const
Definition ini.cpp:1948
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
virtual void Reset(void)
Definition mapper.cpp:151
void Set_Current_UV_Offset(const Vector2 &cur)
Definition mapper.h:161
LinearOffsetTextureMapperClass(const Vector2 &offset_per_sec, const Vector2 &start_offset, bool clamp_fix, const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:110
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:157
unsigned int LastUsedSyncTime
Definition mapper.h:177
bool Has_Time_Variant_Texture_Mappers(void)
Definition matinfo.h:296
void Make_Vertex_Materials_Unique(void)
Definition matinfo.h:305
void Reset_Texture_Mappers(void)
Definition matinfo.h:288
WWINLINE void Init(const Matrix3D &m)
Definition matrix4.h:319
WWINLINE void Make_Identity(void)
Definition matrix4.h:298
void Make_Unique(bool force_meshmdl_clone=false)
Definition mesh.cpp:1114
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:990
virtual void Reset(void)
Definition mapper.cpp:984
unsigned int LastUsedSyncTime
Definition mapper.h:504
RandomTextureMapperClass(float fps, const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:946
WWINLINE void Release_Ref(void) const
Definition refcount.h:146
virtual int Class_ID(void) const
Definition rendobj.h:249
virtual int Get_Num_Sub_Objects(void) const
Definition rendobj.h:309
virtual MaterialInfoClass * Get_Material_Info(void)
Definition rendobj.h:444
virtual RenderObjClass * Get_Sub_Object(int index) const
Definition rendobj.h:310
RotateTextureMapperClass(float rad_per_sec, const Vector2 &center, const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:329
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:363
virtual void Reset(void)
Definition mapper.cpp:357
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:102
ScaleTextureMapperClass(const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:69
virtual void Apply(int uv_array_index)
Definition mapper.cpp:88
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:907
virtual void Apply(int uv_array_index)
Definition mapper.cpp:893
SineLinearOffsetTextureMapperClass(const Vector3 &uafp, const Vector3 &vafp, const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:389
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:427
StepLinearOffsetTextureMapperClass(const Vector2 &step, float steps_per_sec, bool clamp_fix, const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:453
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:495
virtual void Apply(int uv_array_index)=0
unsigned int Stage
Definition mapper.h:113
TextureMapperClass(unsigned int stage=0)
Definition mapper.cpp:60
virtual void Apply(int uv_array_index)
Definition mapper.cpp:805
WSEnvMapperClass(AxisType axis, unsigned int stage)
Definition mapper.h:396
AxisType Axis
Definition mapper.h:402
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:770
virtual void Apply(int uv_array_index)
Definition mapper.cpp:820
Definition ww3d.h:78
static unsigned int Get_Sync_Time(void)
Definition ww3d.h:172
static WWINLINE float Fast_Sin(float val)
Definition wwmath.h:388
static float Clamp(float val, float min=0.0f, float max=1.0f)
Definition wwmath.h:208
static WWINLINE float Fast_Cos(float val)
Definition wwmath.h:435
static float Sin(float val)
Definition wwmath.h:378
static float Floor(float val)
Definition wwmath.h:153
static float Cos(float val)
Definition wwmath.h:356
ZigZagLinearOffsetTextureMapperClass(const Vector2 &speed, float period, const Vector2 &scale, unsigned int stage)
Definition mapper.cpp:537
virtual void Calculate_Texture_Matrix(Matrix4x4 &tex_matrix)
Definition mapper.cpp:577
void Reset_All_Texture_Mappers(RenderObjClass *robj, bool make_unique)
Definition mapper.cpp:1087
DWORD F2DW(FLOAT f)
Definition mapper.cpp:54
Random4Class rand4
Definition mapper.cpp:52