Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
w3dmtl.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 : Max2W3d *
24 * *
25 * $Archive:: /Commando/Code/Tools/max2w3d/w3dmtl.cpp $*
26 * *
27 * $Author:: Greg_h $*
28 * *
29 * $Modtime:: 8/22/01 7:47a $*
30 * *
31 * $Revision:: 32 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37
38#include "w3dmtl.h"
39#include <Max.h>
40#include <StdMat.h>
41#include "gamemtl.h"
42#include "realcrc.h"
43
44static W3dRGBStruct Color_To_W3d(Color & c)
45{
46 W3dRGBStruct wc;
47 wc.R = (c.r * 255.0f);
48 wc.G = (c.g * 255.0f);
49 wc.B = (c.b * 255.0f);
50 wc.pad = 0;
51 return wc;
52}
53
54/*
55
56
57 Implementation of W3dMapClass
58
59
60
61*/
62
64{
66 if (that.AnimInfo) {
68 }
69}
70
72{
73 if (this != &that) {
76 }
77 return *this;
78}
79
81{
82 if (Filename) free(Filename);
83 if (AnimInfo) delete AnimInfo;
84}
85
87{
88 if (Filename) free(Filename);
89 if (AnimInfo) delete AnimInfo;
90 Filename = NULL;
91 AnimInfo = NULL;
92}
93
94void W3dMapClass::Set_Filename(const char * fullpath)
95{
96 if (Filename) {
97 free(Filename);
98 }
99 if (fullpath) {
100 char name[_MAX_FNAME];
101 char exten[_MAX_EXT];
102 char fname[_MAX_FNAME+_MAX_EXT+2];
103
104 _splitpath(fullpath,NULL,NULL,name,exten);
105 _makepath(fname,NULL,NULL,name,exten);
106 //strupr(fname); (gth) need to preserve case since unix/PS2 is case sensitive...
107 Filename = strdup(fname);
108 } else {
109 Filename = NULL;
110 }
111}
112
114{
115 if (info == NULL) {
116 if (AnimInfo) {
117 delete AnimInfo;
118 AnimInfo = NULL;
119 return;
120 }
121 } else {
122 if (AnimInfo == NULL) {
124 }
125 *AnimInfo = *info;
126 }
127}
128
129void W3dMapClass::Set_Anim_Info(int framecount,float framerate)
130{
131 if (AnimInfo == NULL) {
133 }
134
135 AnimInfo->FrameCount = framecount;
136 AnimInfo->FrameRate = framerate;
137}
138
139
140
141/*
142
143
144 Implementation of W3dMaterialClass
145
146
147*/
148
149
151{
152 PassCount = 0;
154 for (int pass = 0; pass < MAX_PASSES; pass++) {
155 Materials[pass] = NULL;
156 W3d_Shader_Reset(&(Shaders[pass]));
157 for (int stage = 0; stage < MAX_STAGES; stage++) {
158 Textures[pass][stage] = NULL;
159 MapChannel[pass][stage] = 1;
160 MapperArgs[pass][stage] = NULL;
161 }
162 }
163}
164
169
171{
172 for (int pass = 0; pass < MAX_PASSES; pass++) {
173
174 if (Materials[pass]) {
175 delete Materials[pass];
176 Materials[pass] = NULL;
177 }
178
179 for (int stage = 0; stage < MAX_STAGES; stage++) {
180 if (Textures[pass][stage]) {
181 delete Textures[pass][stage];
182 Textures[pass][stage] = NULL;
183 }
184
185 if (MapperArgs[pass][stage]) {
186 delete [] MapperArgs[pass][stage];
187 MapperArgs[pass][stage] = NULL;
188 }
189 }
190 }
191}
192
194{
195 Free();
197 for (int pass=0; pass < MAX_PASSES; pass++) {
198 W3d_Shader_Reset(&(Shaders[pass]));
199
200 for (int stage=0; stage < MAX_STAGES; stage++) {
201 MapChannel[pass][stage] = 1;
202 }
203 }
204}
205
207{
208 SurfaceType = type;
209}
210
212{
213 assert(level <= MAX_SORT_LEVEL);
214 SortLevel = level;
215}
216
218{
219 assert(count >= 0);
220 assert(count < MAX_PASSES);
221 PassCount = count;
222}
223
225{
226 assert(pass >= 0);
227 assert(pass < PassCount);
228
229 if (Materials[pass] == NULL) {
231 }
232 *(Materials[pass]) = vmat;
233}
234
235void W3dMaterialClass::Set_Mapper_Args(const char *args_buffer, int pass, int stage)
236{
237 assert(pass >= 0);
238 assert(pass < PassCount);
239 assert(stage >= 0);
240 assert(stage < MAX_STAGES);
241
242 if (MapperArgs[pass][stage] != NULL) {
243 delete [] MapperArgs[pass][stage];
244 MapperArgs[pass][stage] = NULL;
245 }
246 if (args_buffer) {
247 int len = strlen(args_buffer);
248 MapperArgs[pass][stage] = new char [len + 1];
249 strcpy(MapperArgs[pass][stage], args_buffer);
250 }
251}
252
254{
255 assert(pass >= 0);
256 assert(pass < PassCount);
257
258 Shaders[pass] = shader;
259}
260
261void W3dMaterialClass::Set_Texture(const W3dMapClass & map,int pass,int stage)
262{
263 assert(pass >= 0);
264 assert(pass < PassCount);
265
266 if (Textures[pass][stage] == NULL) {
267 Textures[pass][stage] = new W3dMapClass;
268 }
269 *(Textures[pass][stage]) = map;
270}
271
272void W3dMaterialClass::Set_Map_Channel(int pass,int stage,int channel)
273{
274 assert(pass >= 0);
275 assert(pass < PassCount);
276 MapChannel[pass][stage] = channel;
277}
278
280{
281 return SurfaceType;
282}
283
285{
286 return SortLevel;
287}
288
290{
291 return PassCount;
292}
293
295{
296 assert(pass >= 0);
297 assert(pass < PassCount);
298
299 return Materials[pass];
300}
301
302const char * W3dMaterialClass::Get_Mapper_Args(int pass, int stage) const
303{
304 assert(pass >= 0);
305 assert(pass < PassCount);
306 assert(stage >= 0);
307 assert(stage < MAX_STAGES);
308
309 return MapperArgs[pass][stage];
310}
311
313{
314 assert(pass >= 0);
315 assert(pass < PassCount);
316 return Shaders[pass];
317}
318
320{
321 assert(pass >= 0);
322 assert(pass < PassCount);
323 assert(stage >= 0);
324 assert(stage < MAX_STAGES);
325
326 return Textures[pass][stage];
327}
328
329int W3dMaterialClass::Get_Map_Channel(int pass,int stage) const
330{
331 assert(pass >= 0);
332 assert(pass < PassCount);
333 assert(stage >= 0);
334 assert(stage < MAX_STAGES);
335
336 return MapChannel[pass][stage];
337}
338
339void W3dMaterialClass::Init(Mtl * mtl, char *materialColorTexture)
340{
341 bool ps2_mat = false;
342 Reset();
343
344 if (mtl->ClassID() == PS2GameMaterialClassID)
345 {
346 ps2_mat = true;
347 }
348
349 if ((mtl->ClassID() == GameMaterialClassID) || ps2_mat) {
350 Init((GameMtl*)mtl, materialColorTexture);
351 return;
352 }
353
354 Texmap * tmap;
355 PassCount = 1;
356
357 tmap = mtl->GetSubTexmap(ID_RL);
358 if (tmap && tmap->ClassID() == Class_ID(BMTEX_CLASS_ID,0)) {
359 PassCount++;
360 }
361
363 W3dShaderStruct shader;
364 W3dMapClass tex;
365
366 /*
367 ** Setting up the diffuse color pass
368 */
369 W3d_Shader_Reset(&shader);
370
371 mat.Attributes = 0;
372 mat.Emissive.R = mat.Emissive.G = mat.Emissive.B = 0; //(uint8)(255 .0f * mtl->GetSelfIllum());
373
374 Color diffuse = mtl->GetDiffuse();
375 mat.Diffuse.R = (uint8)(diffuse.r * 255.0f);
376 mat.Diffuse.G = (uint8)(diffuse.g * 255.0f);
377 mat.Diffuse.B = (uint8)(diffuse.b * 255.0f);
378 mat.Ambient = mat.Diffuse;
379
380 Color specular = mtl->GetSpecular();
381 mat.Specular.R = (uint8)(specular.r * 255.0f);
382 mat.Specular.G = (uint8)(specular.g * 255.0f);
383 mat.Specular.B = (uint8)(specular.b * 255.0f);
384
385 mat.Shininess = mtl->GetShininess();
386 mat.Opacity = 1.0f - mtl->GetXParency();
387 mat.Translucency = 0.0f;
388
389 tmap = mtl->GetSubTexmap(ID_DI);
390 if (tmap && tmap->ClassID() == Class_ID(BMTEX_CLASS_ID,0)) {
391
392 char * tname = ((BitmapTex *)tmap)->GetMapName();
393 if (tname) {
394 tex.Set_Filename(tname);
395 mat.Diffuse.R = mat.Diffuse.G = mat.Diffuse.B = 255;
397 Set_Texture(tex,0,0);
398 }
399 }
400
401 if (materialColorTexture && !mtl->GetSubTexmap(ID_DI) && !mtl->GetSubTexmap(ID_RL))
402 { //no textures on material, substitute textures to improve rendering speed.
403 tex.Set_Filename(materialColorTexture);
405 //This texture will hold solid pixels of material color, don't need any filtering.
406// W3dTextureInfoStruct texinfo;
407// memset(&texinfo,0,sizeof(texinfo));
408// texinfo.Attributes = texinfo.Attributes | /*W3DTEXTURE_NO_LOD|*/W3DTEXTURE_CLAMP_U | W3DTEXTURE_CLAMP_V;
409// tex.Set_Anim_Info(&texinfo);
410 Set_Texture(tex,0,0);
411 }
412
413 if (mat.Opacity != 1.0f) {
416 }
417
418 Set_Vertex_Material(mat,0);
419 Set_Shader(shader,0);
420
421
422 /*
423 ** Setting up the reflection pass (envmap)
424 */
425 if (PassCount == 2) {
426
427 W3d_Shader_Reset(&shader);
428 if (ps2_mat)
429 {
431 }
432 else
433 {
435 }
441
442 // PS2 specific paramaters.
447
449 mat.Diffuse.R = mat.Diffuse.G = mat.Diffuse.B = 128;
452
453 tmap = mtl->GetSubTexmap(ID_RL);
454 if (tmap && tmap->ClassID() == Class_ID(BMTEX_CLASS_ID,0)) {
455
456 char * tname = ((BitmapTex *)tmap)->GetMapName();
457 if (tname) {
458 tex.Set_Filename(tname);
459 Set_Texture(tex,1);
460 }
461 }
462
463 Set_Vertex_Material(mat,1);
464 Set_Shader(shader,1);
465 }
466}
467
468void W3dMaterialClass::Init(GameMtl * gamemtl, char *materialColorTexture)
469{
470 Reset();
471 PassCount = gamemtl->Get_Pass_Count();
473 Set_Sort_Level(gamemtl->Get_Sort_Level());
474
475 for (int pass=0;pass<gamemtl->Get_Pass_Count(); pass++) {
476
477 /*
478 ** set up the shader
479 */
480 W3dShaderStruct shader;
481 W3d_Shader_Reset(&shader);
482 shader.DepthCompare = gamemtl->Get_Depth_Compare(pass);
483 shader.DepthMask = gamemtl->Get_Depth_Mask(pass);
484 shader.AlphaTest = gamemtl->Get_Alpha_Test(pass);
485 shader.DestBlend = gamemtl->Get_Dest_Blend(pass);
486 shader.PriGradient = gamemtl->Get_Pri_Gradient(pass);
487 shader.SecGradient = gamemtl->Get_Sec_Gradient(pass);
488 shader.SrcBlend = gamemtl->Get_Src_Blend(pass);
489 shader.DetailColorFunc = gamemtl->Get_Detail_Color_Func(pass);
490 shader.DetailAlphaFunc = gamemtl->Get_Detail_Alpha_Func(pass);
492 shader.PostDetailColorFunc = gamemtl->Get_Detail_Color_Func(pass); // (gth) set up the post-detail options
493 shader.PostDetailAlphaFunc = gamemtl->Get_Detail_Alpha_Func(pass);
494
495 // PS2 specific paramaters.
496 W3d_Shader_Set_PS2_Param_A(&shader, gamemtl->Get_PS2_Shader_Param_A(pass));
497 W3d_Shader_Set_PS2_Param_B(&shader, gamemtl->Get_PS2_Shader_Param_B(pass));
498 W3d_Shader_Set_PS2_Param_C(&shader, gamemtl->Get_PS2_Shader_Param_C(pass));
499 W3d_Shader_Set_PS2_Param_D(&shader, gamemtl->Get_PS2_Shader_Param_D(pass));
500
501 /*
502 ** set up the vertex material
503 */
505 mat.Attributes = 0;
506
507 if (gamemtl->Get_Copy_Specular_To_Diffuse(pass)) {
509 }
510
511 // mapping type for stage 0
512 switch(gamemtl->Get_Mapping_Type(pass, 0))
513 {
520
534 };
535
536 // mapping type for stage 1
537 switch(gamemtl->Get_Mapping_Type(pass, 1))
538 {
545
559 };
560
561 switch(gamemtl->Get_PSX_Translucency(pass))
562 {
568 };
569
570 if (!gamemtl->Get_PSX_Lighting(pass)) {
572 }
573
574 mat.Ambient = Color_To_W3d(gamemtl->Get_Ambient(pass,0));
575 mat.Diffuse = Color_To_W3d(gamemtl->Get_Diffuse(pass,0));
576 mat.Specular = Color_To_W3d(gamemtl->Get_Specular(pass,0));
577 mat.Emissive = Color_To_W3d(gamemtl->Get_Emissive(pass,0));
578 mat.Shininess = gamemtl->Get_Shininess(pass,0);
579 mat.Opacity = gamemtl->Get_Opacity(pass,0);
580 mat.Translucency = gamemtl->Get_Translucency(pass,0);
581
582 /*
583 ** install the two textures if present
584 */
585 W3dMapClass w3dmap;
586 BitmapTex * tex = NULL;
587
588 for (int stage=0; stage < MAX_STAGES; stage++) {
589
590 if (gamemtl->Get_Texture_Enable(pass,stage) && gamemtl->Get_Texture(pass,stage)) {
591
592 w3dmap.Reset();
593
594 // get the filename for the w3dmap texture
595 tex = (BitmapTex *)gamemtl->Get_Texture(pass,stage);
596 assert(tex->GetMapName());
597 w3dmap.Set_Filename(tex->GetMapName());
598
599 // get the animation and flags for the w3dmap texture
600 W3dTextureInfoStruct texinfo;
601 memset(&texinfo,0,sizeof(texinfo));
602
603 texinfo.AnimType = gamemtl->Get_Texture_Anim_Type(pass,stage);
604
605 if (gamemtl->Get_Texture_Publish(pass,stage)) {
606 texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_PUBLISH;
607 }
608 if (gamemtl->Get_Texture_No_LOD(pass,stage)) {
609 texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_NO_LOD;
610 }
611 if (gamemtl->Get_Texture_Clamp_U(pass,stage)) {
612 texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_CLAMP_U;
613 }
614 if (gamemtl->Get_Texture_Clamp_V(pass,stage)) {
615 texinfo.Attributes = texinfo.Attributes | W3DTEXTURE_CLAMP_V;
616 }
617 if (gamemtl->Get_Texture_Alpha_Bitmap(pass,stage)) {
619 }
620 texinfo.Attributes = texinfo.Attributes | (
621 (gamemtl->Get_Texture_Hint(pass,stage) << W3DTEXTURE_HINT_SHIFT)
623
624 // If the shader indicates bump-environment mapping mark this texture as a bumpmap.
625 if ((stage == 0) && (gamemtl->Get_Pri_Gradient (pass) == W3DSHADER_PRIGRADIENT_BUMPENVMAP)) {
627 }
628
629 texinfo.FrameCount = gamemtl->Get_Texture_Frame_Count(pass,stage);
630 texinfo.FrameRate = gamemtl->Get_Texture_Frame_Rate(pass,stage);
631
632 if ((texinfo.FrameCount > 1) || (texinfo.Attributes != 0)) {
633 w3dmap.Set_Anim_Info(&texinfo);
634 }
635
636 // plug it in and turn on texturing in the shader
637 Set_Texture(w3dmap,pass,stage);
639
640 // copy over the mapping channel
641 Set_Map_Channel(pass,stage,gamemtl->Get_Map_Channel(pass,stage));
642
643 // copy over the mapper args
644 Set_Mapper_Args(gamemtl->Get_Mapping_Arg_Buffer(pass, stage), pass, stage);
645
646 } else {
647 if (materialColorTexture)
648 { //no textures on material, substitute textures to improve rendering speed.
649 w3dmap.Reset();
650 w3dmap.Set_Filename(materialColorTexture);
651
652 // plug it in and turn on texturing in the shader
653 Set_Texture(w3dmap,pass,stage);
655 }
656 break; // break out of the loop (and dont put in stage 1 if stage 0 is missing...)
657 }
658 }
659
660 Set_Shader(shader,pass);
661 Set_Vertex_Material(mat,pass);
662 }
663}
664
665
667{
668 return ((PassCount >= 2) && (Get_Shader(0).DestBlend != W3DSHADER_DESTBLENDFUNC_ZERO));
669}
670
671
672/*
673
674
675 Implementation of W3dMaterialDescClass::VertClass
676
677
678*/
679W3dMaterialDescClass::VertMatClass::VertMatClass(void) :
680 PassIndex(-1),
681 Crc(0),
682 Name(NULL)
683{
684 for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; ++stage) {
685 MapperArgs[stage] = NULL;
686 }
687}
688
689W3dMaterialDescClass::VertMatClass::~VertMatClass(void)
690{
691 if (Name) free(Name);
692
693 for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; ++stage) {
694 if (MapperArgs[stage]) {
695 delete [] (MapperArgs[stage]);
696 MapperArgs[stage] = NULL;
697 }
698 }
699}
700
701W3dMaterialDescClass::VertMatClass &
702W3dMaterialDescClass::VertMatClass::operator = (const VertMatClass & that)
703{
704 if (this != &that) {
705 Material = that.Material;
706 PassIndex = that.PassIndex;
707 Crc = that.Crc;
708 Set_Name(that.Name);
709 for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; stage++) {
710 Set_Mapper_Args(that.MapperArgs[stage], stage);
711 }
712 }
713 return *this;
714}
715
716bool W3dMaterialDescClass::VertMatClass::operator != (const VertMatClass & that)
717{
718 return !(*this == that);
719}
720
721bool W3dMaterialDescClass::VertMatClass::operator == (const VertMatClass & that)
722{
723 assert(0); return false;
724}
725
726void W3dMaterialDescClass::VertMatClass::Set_Name(const char * name)
727{
728 if (Name) free(Name);
729
730 if (name) {
731 Name = strdup(name);
732 } else {
733 Name = NULL;
734 }
735}
736
737void W3dMaterialDescClass::VertMatClass::Set_Mapper_Args(const char * args, int stage)
738{
739 if (MapperArgs[stage]) {
740 delete [] (MapperArgs[stage]);
741 MapperArgs[stage] = NULL;
742 }
743
744 if (args) {
745 int len = strlen(args);
746 MapperArgs[stage] = new char [len + 1];
747 strcpy(MapperArgs[stage], args);
748 } else {
749 MapperArgs[stage] = NULL;
750 }
751}
752
753
754/*
755
756
757 Implementation of W3dMaterialDescClass
758
759
760*/
761W3dMaterialDescClass::MaterialRemapClass::MaterialRemapClass(void)
762{
763 PassCount = -1;
764 for (int pass=0; pass<W3dMaterialClass::MAX_PASSES; pass++) {
765 VertexMaterialIdx[pass] = -1;
766 ShaderIdx[pass] = -1;
767 for (int stage=0; stage<W3dMaterialClass::MAX_STAGES; stage++) {
768 TextureIdx[pass][stage] = -1;
769 }
770 }
771}
772
773bool W3dMaterialDescClass::MaterialRemapClass::operator != (const MaterialRemapClass & that)
774{
775 return !(*this == that);
776}
777
778bool W3dMaterialDescClass::MaterialRemapClass::operator == (const MaterialRemapClass & that)
779{
780 for (int pass=0; pass<W3dMaterialClass::MAX_PASSES; pass++) {
781
782 if (VertexMaterialIdx[pass] != that.VertexMaterialIdx[pass]) return false;
783 if (ShaderIdx[pass] != that.ShaderIdx[pass]) return false;
784
785 for (int stage=0; stage<W3dMaterialClass::MAX_STAGES; stage++) {
786
787 if (TextureIdx[pass][stage] != that.TextureIdx[pass][stage]) return false;
788 }
789 }
790 return true;
791}
792
793
794
799
803
805{
806 PassCount = -1;
807 SortLevel = -1;
808 MaterialRemaps.Clear();
809 Shaders.Clear();
810 VertexMaterials.Clear();
811 Textures.Clear();
812}
813
814
816{
817 /*
818 ** If passes hasn't been set yet, set it.
819 */
820 if (PassCount == -1) {
821 PassCount = mat.Get_Pass_Count();
822 }
823
824 /*
825 ** Same for sort level.
826 */
827 if (SortLevel == -1) {
828 SortLevel = mat.Get_Sort_Level();
829 }
830
831 /*
832 ** Verify that this material uses the same number of passes that any
833 ** other materials we have use.
834 */
835 if (mat.Get_Pass_Count() != PassCount) {
836 return INCONSISTENT_PASSES;
837 }
838
839 if (mat.Is_Multi_Pass_Transparent()) {
840 char msg[100];
841 sprintf(msg,"Enable Multipass-Transparency?");
842 HWND window=GetForegroundWindow();
843 if (IDYES!=MessageBox(window,msg,"Confirmation",MB_YESNO|MB_ICONINFORMATION|MB_TASKMODAL))
845 }
846
847 /*
848 ** Verify that this material uses the same sort level as all other
849 ** materials used on this mesh.
850 */
851 if (mat.Get_Sort_Level() != SortLevel) {
853 }
854
855 /*
856 ** Ok, lets re-index this material and store the unique parts
857 */
858 MaterialRemapClass remap;
859
860 for (int pass=0; pass<PassCount; pass++) {
861
862 remap.VertexMaterialIdx[pass] = Add_Vertex_Material(
863 mat.Get_Vertex_Material(pass),mat.Get_Mapper_Args(pass, 0),mat.Get_Mapper_Args(pass, 1),pass,name);
864
865 remap.ShaderIdx[pass] = Add_Shader(mat.Get_Shader(pass),pass);
866
867 for (int stage=0; stage<W3dMaterialClass::MAX_STAGES; stage++) {
868
869 remap.TextureIdx[pass][stage] = Add_Texture(mat.Get_Texture(pass,stage),pass,stage);
870 remap.MapChannel[pass][stage] = mat.Get_Map_Channel(pass,stage);
871
872 }
873 }
874
875 MaterialRemaps.Add(remap);
876 return OK;
877}
878
879
881{
882 return MaterialRemaps.Count();
883}
884
886{
887 return PassCount;
888}
889
891{
892 return VertexMaterials.Count();
893}
894
896{
897 return Shaders.Count();
898}
899
901{
902 return Textures.Count();
903}
904
906{
907 return SortLevel;
908}
909
911{
912 assert(vmat_index >= 0);
913 assert(vmat_index < VertexMaterials.Count());
914 return &(VertexMaterials[vmat_index].Material);
915}
916
917const char * W3dMaterialDescClass::Get_Mapper_Args(int vmat_index, int stage)
918{
919 assert(vmat_index >= 0);
920 assert(vmat_index < VertexMaterials.Count());
921 assert(stage >= 0);
922 assert(stage < W3dMaterialClass::MAX_STAGES);
923 return VertexMaterials[vmat_index].MapperArgs[stage];
924}
925
927{
928 assert(shader_index >= 0);
929 assert(shader_index < Shaders.Count());
930 return &(Shaders[shader_index].Shader);
931}
932
934{
935 assert(texture_index >= 0);
936 assert(texture_index < Textures.Count());
937 return &(Textures[texture_index].Map);
938}
939
941{
942 assert(mat_index >= 0);
943 assert(mat_index < MaterialRemaps.Count());
944 assert(pass >= 0);
945 assert(pass < PassCount);
946 return MaterialRemaps[mat_index].VertexMaterialIdx[pass];
947}
948
949int W3dMaterialDescClass::Get_Shader_Index(int mat_index,int pass)
950{
951 assert(mat_index >= 0);
952 assert(mat_index < MaterialRemaps.Count());
953 assert(pass >= 0);
954 assert(pass < PassCount);
955 return MaterialRemaps[mat_index].ShaderIdx[pass];
956}
957
958int W3dMaterialDescClass::Get_Texture_Index(int mat_index,int pass,int stage)
959{
960 assert(mat_index >= 0);
961 assert(mat_index < MaterialRemaps.Count());
962 assert(pass >= 0);
963 assert(pass < PassCount);
964 assert(stage >= 0);
965 assert(stage < W3dMaterialClass::MAX_STAGES);
966 return MaterialRemaps[mat_index].TextureIdx[pass][stage];
967}
968
970{
971 int index = Get_Vertex_Material_Index(mat_index,pass);
972 if (index == -1) {
973 return NULL;
974 } else {
975 return Get_Vertex_Material(index);
976 }
977}
978
979const char * W3dMaterialDescClass::Get_Mapper_Args(int mat_index,int pass,int stage)
980{
981 int index = Get_Vertex_Material_Index(mat_index,pass);
982 if (index == -1) {
983 return NULL;
984 } else {
985 return Get_Mapper_Args(index,stage);
986 }
987}
988
990{
991 int index = Get_Shader_Index(mat_index,pass);
992 if (index == -1) {
993 return NULL;
994 } else {
995 return Get_Shader(index);
996 }
997}
998
999W3dMapClass * W3dMaterialDescClass::Get_Texture(int mat_index,int pass,int stage)
1000{
1001 int index = Get_Texture_Index(mat_index,pass,stage);
1002 if (index == -1) {
1003 return NULL;
1004 } else {
1005 return Get_Texture(index);
1006 }
1007}
1008
1009int W3dMaterialDescClass::Get_Map_Channel(int mat_index,int pass,int stage)
1010{
1011 return MaterialRemaps[mat_index].MapChannel[pass][stage];
1012}
1013
1014const char * W3dMaterialDescClass::Get_Vertex_Material_Name(int mat_index,int pass)
1015{
1016 int index = Get_Vertex_Material_Index(mat_index,pass);
1017 if (index == -1) {
1018 return NULL;
1019 } else {
1020 return VertexMaterials[index].Name;
1021 }
1022}
1023
1025{
1026 return VertexMaterials[vmat_index].Name;
1027}
1028
1030{
1031 for (int mi=0; mi<MaterialRemaps.Count();mi++) {
1032 W3dShaderStruct * shader = Get_Shader(mi,pass);
1033
1034 if (shader) {
1035 if (stage == 0) {
1036 if (W3d_Shader_Get_Texturing(shader) == W3DSHADER_TEXTURING_ENABLE) return true;
1037 }
1038
1039 if (stage == 1) {
1042 return true;
1043 }
1044 }
1045 }
1046 }
1047 return false;
1048}
1049
1051{
1052 /*
1053 ** Only the last alpha pass gets vertex alpha
1054 */
1055 int max_alpha_pass = -1;
1056 for (int pi=0; pi<Pass_Count(); pi++) {
1057 if (Pass_Uses_Alpha(pi)) {
1058 max_alpha_pass = pi;
1059 }
1060 }
1061 return (max_alpha_pass == pass);
1062}
1063
1064
1066{
1067 for (int mi=0; mi<MaterialRemaps.Count(); mi++) {
1068
1069 W3dShaderStruct * shader = Get_Shader(mi,pass);
1070
1071 int dst_blend = W3d_Shader_Get_Dest_Blend_Func(shader);
1072 int src_blend = W3d_Shader_Get_Src_Blend_Func(shader);
1073 int alpha_test = W3d_Shader_Get_Alpha_Test(shader);
1074
1075 if ( (dst_blend == W3DSHADER_DESTBLENDFUNC_SRC_ALPHA) ||
1077 (src_blend == W3DSHADER_SRCBLENDFUNC_SRC_ALPHA) ||
1079 (alpha_test != 0) )
1080 {
1081 return true;
1082 }
1083 }
1084 return false;
1085}
1086
1087int W3dMaterialDescClass::Add_Vertex_Material(W3dVertexMaterialStruct * vmat,
1088 const char *mapper_args0,const char *mapper_args1,int pass,const char * name)
1089{
1090 if (vmat == NULL) {
1091 return -1;
1092 }
1093
1094 int crc = Compute_Crc(*vmat, mapper_args0, mapper_args1);
1095 for (int vi=0; vi<VertexMaterials.Count(); vi++) {
1096 if ((crc == VertexMaterials[vi].Crc) && (pass == VertexMaterials[vi].PassIndex)) {
1097 break;
1098 }
1099 }
1100
1101 if (vi == VertexMaterials.Count()) {
1102 VertMatClass vm;
1103 vm.Material = *vmat;
1104 vm.Crc = crc;
1105 vm.PassIndex = pass;
1106 vm.Set_Name(name);
1107 vm.Set_Mapper_Args(mapper_args0, 0);
1108 vm.Set_Mapper_Args(mapper_args1, 1);
1109 VertexMaterials.Add(vm);
1110 }
1111
1112 return vi;
1113}
1114
1115int W3dMaterialDescClass::Add_Shader(const W3dShaderStruct & shader,int pass)
1116{
1117 int crc = Compute_Crc(shader);
1118 for (int si=0; si<Shaders.Count(); si++) {
1119 if (crc == Shaders[si].Crc) break;
1120 }
1121
1122 if (si == Shaders.Count()) {
1123 ShadeClass s;
1124 s.Shader = shader;
1125 s.Crc = crc;
1126 Shaders.Add(s);
1127 }
1128
1129 return si;
1130}
1131
1132int W3dMaterialDescClass::Add_Texture(W3dMapClass * map,int pass,int stage)
1133{
1134 if ((map == NULL) || (map->Filename == NULL)) {
1135 return -1;
1136 }
1137
1138 int crc = Compute_Crc(*map);
1139 for (int ti=0; ti<Textures.Count(); ti++) {
1140 if (crc == Textures[ti].Crc) {
1141 break;
1142 }
1143 }
1144
1145 if (ti == Textures.Count()) {
1146 TexClass tex;
1147 tex.Map = *map;
1148 tex.Crc = crc;
1149 Textures.Add(tex);
1150 }
1151
1152 return ti;
1153}
1154
1155unsigned long W3dMaterialDescClass::Compute_Crc(const W3dVertexMaterialStruct & vmat,
1156 const char *mapper_args0,
1157 const char *mapper_args1)
1158{
1159 unsigned long crc = 0;
1160 crc = CRC_Memory((const unsigned char *)&vmat.Attributes,sizeof(vmat.Attributes),crc);
1161 crc = CRC_Memory((const unsigned char *)&vmat.Ambient,sizeof(vmat.Ambient),crc);
1162 crc = CRC_Memory((const unsigned char *)&vmat.Diffuse,sizeof(vmat.Diffuse),crc);
1163 crc = CRC_Memory((const unsigned char *)&vmat.Specular,sizeof(vmat.Specular),crc);
1164 crc = CRC_Memory((const unsigned char *)&vmat.Emissive,sizeof(vmat.Emissive),crc);
1165 crc = CRC_Memory((const unsigned char *)&vmat.Shininess,sizeof(vmat.Shininess),crc);
1166 crc = CRC_Memory((const unsigned char *)&vmat.Opacity,sizeof(vmat.Opacity),crc);
1167 crc = CRC_Memory((const unsigned char *)&vmat.Translucency,sizeof(vmat.Translucency),crc);
1168
1169 // Add mapper args string to crc. We are stripping out spaces, tabs, and
1170 // leading/trailing newlines before computing the CRC so two strings will
1171 // only differ if they have visible differences.
1172 crc = Add_String_To_Crc(mapper_args0, crc);
1173 crc = Add_String_To_Crc(mapper_args1, crc);
1174
1175 return crc;
1176}
1177
1178unsigned long W3dMaterialDescClass::Compute_Crc(const W3dShaderStruct & shader)
1179{
1180 unsigned long crc = 0;
1181 crc = CRC_Memory((const unsigned char *)&shader,sizeof(shader),crc);
1182 return crc;
1183}
1184
1185unsigned long W3dMaterialDescClass::Compute_Crc(const W3dMapClass & map)
1186{
1187 unsigned long crc = 0;
1188 if (map.AnimInfo != NULL) {
1189 crc = CRC_Memory((const unsigned char *)&map.AnimInfo->Attributes,sizeof(map.AnimInfo->Attributes),crc);
1190 crc = CRC_Memory((const unsigned char *)&map.AnimInfo->AnimType,sizeof(map.AnimInfo->AnimType),crc);
1191 crc = CRC_Memory((const unsigned char *)&map.AnimInfo->FrameCount,sizeof(map.AnimInfo->FrameCount),crc);
1192 crc = CRC_Memory((const unsigned char *)&map.AnimInfo->FrameRate,sizeof(map.AnimInfo->FrameRate),crc);
1193 }
1194 crc = CRC_Stringi(map.Filename, crc);
1195 return crc;
1196}
1197
1198unsigned long W3dMaterialDescClass::Add_String_To_Crc(const char *str, unsigned long in_crc)
1199{
1200 unsigned long out_crc = in_crc;
1201 if (str) {
1202 int len = strlen(str);
1203 char *temp = new char[len + 1];
1204 const char *p_in = str;
1205
1206 // skip leading spaces, tabs, newlines
1207 for (; *p_in == ' ' || *p_in == '\t' || *p_in == '\r' || *p_in == '\n'; p_in++);
1208
1209 // copy string, skipping spaces and tabs
1210 char * p_out = temp;
1211 int count = 0;
1212 for (; *p_in; p_in++) {
1213 for (; *p_in == ' ' || *p_in == '\t'; p_in++);
1214 if (!(*p_in)) break;
1215 *p_out = *p_in;
1216 p_out++;
1217 count++;
1218 }
1219 *p_out = 0;
1220
1221 // Erase any trailing newlines:
1222 if (count) {
1223 // p_out now points to the ending null - make it point to the
1224 // character before it (the last character of the string proper)
1225 p_out--;
1226
1227 for (; *p_out == '\r' || *p_out == '\n'; p_out--) {
1228 *p_out = '\000';
1229 count--;
1230 }
1231 }
1232
1233 out_crc = CRC_Memory((const unsigned char *)temp,count,in_crc);
1234 delete [] temp;
1235 }
1236 return out_crc;
1237}
1238
1239
#define NULL
Definition BaseType.h:92
#define W3DVERTMAT_STAGE1_MAPPING_ZIGZAG_LINEAR_OFFSET
Definition w3d_file.h:687
#define W3DTEXTURE_HINT_MASK
Definition w3d_file.h:1018
#define W3DVERTMAT_STAGE1_MAPPING_WS_CLASSIC_ENV
Definition w3d_file.h:688
#define MAX_SORT_LEVEL
Definition w3d_file.h:1196
#define W3DVERTMAT_STAGE1_MAPPING_WS_ENVIRONMENT
Definition w3d_file.h:689
#define W3DVERTMAT_STAGE0_MAPPING_ENVIRONMENT
Definition w3d_file.h:654
void W3d_Shader_Reset(W3dShaderStruct *s)
Definition w3d_file.h:925
#define W3DVERTMAT_STAGE0_MAPPING_CHEAP_ENVIRONMENT
Definition w3d_file.h:655
#define W3DVERTMAT_STAGE1_MAPPING_SINE_LINEAR_OFFSET
Definition w3d_file.h:685
#define W3DVERTMAT_STAGE1_MAPPING_SCALE
Definition w3d_file.h:682
int W3d_Shader_Get_Src_Blend_Func(const W3dShaderStruct *s)
Definition w3d_file.h:987
#define W3DTEXTURE_CLAMP_U
Definition w3d_file.h:1004
#define W3DVERTMAT_STAGE1_MAPPING_SCREEN
Definition w3d_file.h:679
#define W3DVERTMAT_STAGE0_MAPPING_BUMPENV
Definition w3d_file.h:671
int W3d_Shader_Get_Detail_Alpha_Func(const W3dShaderStruct *s)
Definition w3d_file.h:990
#define W3DTEXTURE_HINT_SHIFT
Definition w3d_file.h:1017
void W3d_Shader_Set_Dest_Blend_Func(W3dShaderStruct *s, int val)
Definition w3d_file.h:946
#define W3DVERTMAT_STAGE0_MAPPING_UV
Definition w3d_file.h:653
@ W3DSHADER_DETAILCOLORFUNC_DISABLE
Definition w3d_file.h:804
@ W3DSHADER_DESTBLENDFUNC_SRC_ALPHA
Definition w3d_file.h:777
@ W3DSHADER_PRIGRADIENT_MODULATE
Definition w3d_file.h:783
@ W3DSHADER_PRIGRADIENT_BUMPENVMAP
Definition w3d_file.h:785
@ W3DSHADER_SRCBLENDFUNC_ONE_MINUS_SRC_ALPHA
Definition w3d_file.h:797
@ W3DSHADER_DEPTHMASK_WRITE_DISABLE
Definition w3d_file.h:765
@ W3DSHADER_DESTBLENDFUNC_ZERO
Definition w3d_file.h:773
@ W3DSHADER_DESTBLENDFUNC_ONE
Definition w3d_file.h:774
@ W3DSHADER_SRCBLENDFUNC_SRC_ALPHA
Definition w3d_file.h:796
@ W3DSHADER_SECGRADIENT_DISABLE
Definition w3d_file.h:790
@ W3DSHADER_SRCBLENDFUNC_ONE
Definition w3d_file.h:795
@ W3DSHADER_TEXTURING_DISABLE
Definition w3d_file.h:800
@ W3DSHADER_DETAILALPHAFUNC_DISABLE
Definition w3d_file.h:819
@ W3DSHADER_DESTBLENDFUNC_ONE_MINUS_SRC_ALPHA
Definition w3d_file.h:778
@ W3DSHADER_TEXTURING_ENABLE
Definition w3d_file.h:801
#define W3DVERTMAT_STAGE1_MAPPING_ROTATE
Definition w3d_file.h:684
#define W3DVERTMAT_PSX_NO_RT_LIGHTING
Definition w3d_file.h:705
#define W3DVERTMAT_STAGE1_MAPPING_STEP_LINEAR_OFFSET
Definition w3d_file.h:686
#define W3DVERTMAT_STAGE0_MAPPING_ZIGZAG_LINEAR_OFFSET
Definition w3d_file.h:664
#define W3DVERTMAT_STAGE0_MAPPING_LINEAR_OFFSET
Definition w3d_file.h:657
#define W3DVERTMAT_PSX_TRANS_NONE
Definition w3d_file.h:700
#define SORT_LEVEL_NONE
Definition w3d_file.h:1195
#define W3DVERTMAT_STAGE0_MAPPING_SCALE
Definition w3d_file.h:659
#define W3DVERTMAT_STAGE0_MAPPING_STEP_LINEAR_OFFSET
Definition w3d_file.h:663
#define W3DVERTMAT_STAGE0_MAPPING_SINE_LINEAR_OFFSET
Definition w3d_file.h:662
void W3d_Shader_Set_Texturing(W3dShaderStruct *s, int val)
Definition w3d_file.h:950
#define W3DVERTMAT_STAGE1_MAPPING_EDGE
Definition w3d_file.h:693
#define W3DVERTMAT_STAGE0_MAPPING_SILHOUETTE
Definition w3d_file.h:658
#define W3DVERTMAT_STAGE0_MAPPING_SCREEN
Definition w3d_file.h:656
void W3d_Shader_Set_Depth_Mask(W3dShaderStruct *s, int val)
Definition w3d_file.h:945
#define W3DTEXTURE_CLAMP_V
Definition w3d_file.h:1005
int W3d_Shader_Get_Detail_Color_Func(const W3dShaderStruct *s)
Definition w3d_file.h:989
#define W3DTEXTURE_TYPE_BUMPMAP
Definition w3d_file.h:1027
#define W3DTEXTURE_PUBLISH
Definition w3d_file.h:1001
void W3d_Shader_Set_PS2_Param_B(W3dShaderStruct *s, int val)
Definition w3d_file.h:961
#define W3DVERTMAT_STAGE0_MAPPING_EDGE
Definition w3d_file.h:670
void W3d_Shader_Set_Pri_Gradient(W3dShaderStruct *s, int val)
Definition w3d_file.h:947
void W3d_Shader_Set_Src_Blend_Func(W3dShaderStruct *s, int val)
Definition w3d_file.h:949
#define W3DVERTMAT_STAGE1_MAPPING_UV
Definition w3d_file.h:676
#define W3DVERTMAT_COPY_SPECULAR_TO_DIFFUSE
Definition w3d_file.h:649
#define W3DVERTMAT_PSX_TRANS_100
Definition w3d_file.h:701
#define W3DVERTMAT_STAGE1_MAPPING_GRID_ENVIRONMENT
Definition w3d_file.h:691
#define W3DVERTMAT_STAGE0_MAPPING_WS_CLASSIC_ENV
Definition w3d_file.h:665
#define W3DTEXTURE_NO_LOD
Definition w3d_file.h:1003
#define W3DVERTMAT_STAGE1_MAPPING_SILHOUETTE
Definition w3d_file.h:681
#define W3DVERTMAT_STAGE0_MAPPING_ROTATE
Definition w3d_file.h:661
#define W3DVERTMAT_STAGE1_MAPPING_BUMPENV
Definition w3d_file.h:694
void W3d_Shader_Set_PS2_Param_D(W3dShaderStruct *s, int val)
Definition w3d_file.h:963
void W3d_Shader_Set_PS2_Param_C(W3dShaderStruct *s, int val)
Definition w3d_file.h:962
#define W3DVERTMAT_STAGE0_MAPPING_GRID
Definition w3d_file.h:660
#define W3DVERTMAT_PSX_TRANS_MINUS_100
Definition w3d_file.h:704
#define W3DVERTMAT_STAGE0_MAPPING_MASK
Definition w3d_file.h:652
#define W3DVERTMAT_STAGE0_MAPPING_GRID_ENVIRONMENT
Definition w3d_file.h:668
#define W3DVERTMAT_STAGE0_MAPPING_GRID_CLASSIC_ENV
Definition w3d_file.h:667
#define W3DVERTMAT_STAGE1_MAPPING_CHEAP_ENVIRONMENT
Definition w3d_file.h:678
#define W3DVERTMAT_STAGE1_MAPPING_GRID_CLASSIC_ENV
Definition w3d_file.h:690
#define W3DVERTMAT_STAGE1_MAPPING_LINEAR_OFFSET
Definition w3d_file.h:680
int W3d_Shader_Get_Alpha_Test(const W3dPS2ShaderStruct *s)
Definition w3d_file.h:979
#define W3DVERTMAT_STAGE0_MAPPING_WS_ENVIRONMENT
Definition w3d_file.h:666
#define W3DVERTMAT_STAGE1_MAPPING_RANDOM
Definition w3d_file.h:692
#define W3DVERTMAT_STAGE0_MAPPING_RANDOM
Definition w3d_file.h:669
#define W3DTEXTURE_ALPHA_BITMAP
Definition w3d_file.h:1006
void W3d_Vertex_Material_Reset(W3dVertexMaterialStruct *vmat)
Definition w3d_file.h:738
#define W3DVERTMAT_PSX_TRANS_25
Definition w3d_file.h:703
#define W3DVERTMAT_PSX_TRANS_50
Definition w3d_file.h:702
@ PSS_ZERO
Definition w3d_file.h:840
@ PSS_DEST
Definition w3d_file.h:839
@ PSS_SRC
Definition w3d_file.h:838
@ PSS_PRIGRADIENT_MODULATE
Definition w3d_file.h:848
@ PSS_ONE
Definition w3d_file.h:844
void W3d_Shader_Set_PS2_Param_A(W3dShaderStruct *s, int val)
Definition w3d_file.h:960
#define W3DVERTMAT_STAGE1_MAPPING_GRID
Definition w3d_file.h:683
int W3d_Shader_Get_Dest_Blend_Func(const W3dShaderStruct *s)
Definition w3d_file.h:984
int W3d_Shader_Get_Texturing(const W3dPS2ShaderStruct *s)
Definition w3d_file.h:978
#define W3DVERTMAT_STAGE1_MAPPING_ENVIRONMENT
Definition w3d_file.h:677
void W3d_Shader_Set_Sec_Gradient(W3dShaderStruct *s, int val)
Definition w3d_file.h:948
unsigned char uint8
Definition bittype.h:44
unsigned long CRC_Memory(const unsigned char *data, unsigned long length, unsigned long crc)
Definition realcrc.cpp:126
unsigned long CRC_Stringi(const char *string, unsigned long crc)
Definition realcrc.cpp:168
Int Color
Definition Xfer.h:45
Color Get_Specular(int pass, TimeValue t)
Definition GameMtl.cpp:2550
float Get_Translucency(int pass, TimeValue t)
Definition GameMtl.cpp:2574
int Get_Texture_Anim_Type(int pass, int stage)
Definition GameMtl.cpp:2781
int Get_PS2_Shader_Param_A(int pass)
Definition GameMtl.cpp:2796
int Get_Detail_Alpha_Func(int pass)
Definition GameMtl.cpp:2655
int Get_Texture_Clamp_U(int pass, int stage)
Definition GameMtl.cpp:2701
int Get_Src_Blend(int pass)
Definition GameMtl.cpp:2643
float Get_Shininess(int pass, TimeValue t)
Definition GameMtl.cpp:2562
int Get_Texture_Frame_Count(int pass, int stage)
Definition GameMtl.cpp:2771
int Get_PS2_Shader_Param_D(int pass)
Definition GameMtl.cpp:2817
Color Get_Emissive(int pass, TimeValue t)
Definition GameMtl.cpp:2556
int Get_Sec_Gradient(int pass)
Definition GameMtl.cpp:2637
int Get_Pri_Gradient(int pass)
Definition GameMtl.cpp:2631
int Get_Texture_Enable(int pass, int stage)
Definition GameMtl.cpp:2661
int Get_PSX_Lighting(int pass)
Definition GameMtl.cpp:2601
int Get_Map_Channel(int pass, int stage)
Definition GameMtl.cpp:2824
float Get_Opacity(int pass, TimeValue t)
Definition GameMtl.cpp:2568
int Get_Depth_Mask(int pass)
Definition GameMtl.cpp:2613
int Get_Detail_Color_Func(int pass)
Definition GameMtl.cpp:2649
int Get_Sort_Level(void) const
Definition gamemtl.h:203
Color Get_Ambient(int pass, TimeValue t)
Definition GameMtl.cpp:2538
int Get_PS2_Shader_Param_C(int pass)
Definition GameMtl.cpp:2810
int Get_Alpha_Test(int pass)
Definition GameMtl.cpp:2619
int Get_Texture_Hint(int pass, int stage)
Definition GameMtl.cpp:2741
Texmap * Get_Texture(int pass, int stage)
Definition GameMtl.cpp:2791
int Get_Pass_Count(void)
Definition GameMtl.cpp:2529
unsigned int Get_Surface_Type(void) const
Definition gamemtl.h:200
int Get_Texture_Publish(int pass, int stage)
Definition GameMtl.cpp:2671
int Get_Texture_Clamp_V(int pass, int stage)
Definition GameMtl.cpp:2711
int Get_Dest_Blend(int pass)
Definition GameMtl.cpp:2625
int Get_Depth_Compare(int pass)
Definition GameMtl.cpp:2607
int Get_Copy_Specular_To_Diffuse(int pass)
Definition GameMtl.cpp:2580
float Get_Texture_Frame_Rate(int pass, int stage)
Definition GameMtl.cpp:2761
int Get_Texture_Alpha_Bitmap(int pass, int stage)
Definition GameMtl.cpp:2731
Color Get_Diffuse(int pass, TimeValue t)
Definition GameMtl.cpp:2544
char * Get_Mapping_Arg_Buffer(int pass, int stage=0, unsigned int len=0U)
Definition GameMtl.cpp:3193
int Get_Texture_No_LOD(int pass, int stage)
Definition GameMtl.cpp:2721
int Get_Mapping_Type(int pass, int stage=0)
Definition GameMtl.cpp:2586
int Get_PSX_Translucency(int pass)
Definition GameMtl.cpp:2595
int Get_PS2_Shader_Param_B(int pass)
Definition GameMtl.cpp:2803
void Set_Anim_Info(const W3dTextureInfoStruct *info)
Definition w3dmtl.cpp:113
~W3dMapClass(void)
Definition w3dmtl.cpp:80
void Set_Filename(const char *name)
Definition w3dmtl.cpp:94
W3dMapClass & operator=(const W3dMapClass &that)
Definition w3dmtl.cpp:71
W3dMapClass(void)
Definition w3dmtl.h:60
char * Filename
Definition w3dmtl.h:71
W3dTextureInfoStruct * AnimInfo
Definition w3dmtl.h:72
void Reset(void)
Definition w3dmtl.cpp:86
void Set_Vertex_Material(const W3dVertexMaterialStruct &vmat, int pass=0)
Definition w3dmtl.cpp:224
void Set_Sort_Level(int level)
Definition w3dmtl.cpp:211
char * MapperArgs[MAX_PASSES][MAX_STAGES]
Definition w3dmtl.h:135
int Get_Sort_Level(void) const
Definition w3dmtl.cpp:284
const char * Get_Mapper_Args(int pass, int stage) const
Definition w3dmtl.cpp:302
W3dMapClass * Textures[MAX_PASSES][MAX_STAGES]
Definition w3dmtl.h:136
void Set_Shader(const W3dShaderStruct &shader, int pass=0)
Definition w3dmtl.cpp:253
void Set_Map_Channel(int pass, int stage, int channel)
Definition w3dmtl.cpp:272
int Get_Pass_Count(void) const
Definition w3dmtl.cpp:289
W3dVertexMaterialStruct * Materials[MAX_PASSES]
Definition w3dmtl.h:134
W3dMapClass * Get_Texture(int pass=0, int stage=0) const
Definition w3dmtl.cpp:319
int Get_Map_Channel(int pass=0, int stage=0) const
Definition w3dmtl.cpp:329
W3dVertexMaterialStruct * Get_Vertex_Material(int pass=0) const
Definition w3dmtl.cpp:294
int MapChannel[MAX_PASSES][MAX_STAGES]
Definition w3dmtl.h:137
void Set_Pass_Count(int count)
Definition w3dmtl.cpp:217
bool Is_Multi_Pass_Transparent(void) const
Definition w3dmtl.cpp:666
unsigned int Get_Surface_Type(void) const
Definition w3dmtl.cpp:279
void Set_Mapper_Args(const char *args_buffer, int pass=0, int stage=0)
Definition w3dmtl.cpp:235
void Reset(void)
Definition w3dmtl.cpp:193
void Free(void)
Definition w3dmtl.cpp:170
unsigned int SurfaceType
Definition w3dmtl.h:129
~W3dMaterialClass(void)
Definition w3dmtl.cpp:165
W3dShaderStruct Shaders[MAX_PASSES]
Definition w3dmtl.h:133
void Init(Mtl *mtl, char *materialColorTexture=NULL)
Definition w3dmtl.cpp:339
W3dShaderStruct Get_Shader(int pass=0) const
Definition w3dmtl.cpp:312
W3dMaterialClass(void)
Definition w3dmtl.cpp:150
void Set_Surface_Type(unsigned int type)
Definition w3dmtl.cpp:206
void Set_Texture(const W3dMapClass &map, int pass=0, int stage=0)
Definition w3dmtl.cpp:261
W3dMapClass * Get_Texture(int texture_index)
Definition w3dmtl.cpp:933
bool Pass_Uses_Vertex_Alpha(int pass)
Definition w3dmtl.cpp:1050
const char * Get_Vertex_Material_Name(int mat_index, int pass)
Definition w3dmtl.cpp:1014
int Pass_Count(void)
Definition w3dmtl.cpp:885
int Vertex_Material_Count(void)
Definition w3dmtl.cpp:890
~W3dMaterialDescClass(void)
Definition w3dmtl.cpp:800
int Get_Vertex_Material_Index(int mat_index, int pass)
Definition w3dmtl.cpp:940
ErrorType Add_Material(const W3dMaterialClass &mat, const char *name=NULL)
Definition w3dmtl.cpp:815
W3dShaderStruct * Get_Shader(int shader_index)
Definition w3dmtl.cpp:926
bool Stage_Needs_Texture_Coordinates(int pass, int stage)
Definition w3dmtl.cpp:1029
int Shader_Count(void)
Definition w3dmtl.cpp:895
int Get_Shader_Index(int mat_index, int pass)
Definition w3dmtl.cpp:949
int Material_Count(void)
Definition w3dmtl.cpp:880
int Get_Sort_Level(void)
Definition w3dmtl.cpp:905
const char * Get_Mapper_Args(int vmat_index, int stage)
Definition w3dmtl.cpp:917
W3dVertexMaterialStruct * Get_Vertex_Material(int vmat_index)
Definition w3dmtl.cpp:910
int Get_Texture_Index(int mat_index, int pass, int stage)
Definition w3dmtl.cpp:958
int Get_Map_Channel(int mat_index, int pass, int stage)
Definition w3dmtl.cpp:1009
bool Pass_Uses_Alpha(int pass)
Definition w3dmtl.cpp:1065
int Texture_Count(void)
Definition w3dmtl.cpp:900
#define GAMEMTL_PSX_TRANS_NONE
Definition gamemtl.h:100
#define GAMEMTL_MAPPING_RANDOM
Definition gamemtl.h:90
#define GAMEMTL_PSX_TRANS_MINUS_100
Definition gamemtl.h:104
#define GAMEMTL_PSX_TRANS_100
Definition gamemtl.h:101
#define GAMEMTL_MAPPING_SCREEN
Definition gamemtl.h:77
#define GAMEMTL_MAPPING_CHEAP_ENV
Definition gamemtl.h:76
#define GAMEMTL_MAPPING_BUMPENV
Definition gamemtl.h:92
#define GAMEMTL_MAPPING_WS_CLASSIC_ENV
Definition gamemtl.h:86
#define GAMEMTL_MAPPING_SILHOUETTE
Definition gamemtl.h:79
#define GAMEMTL_PSX_TRANS_25
Definition gamemtl.h:103
#define GAMEMTL_PSX_TRANS_50
Definition gamemtl.h:102
#define GAMEMTL_MAPPING_SCALE
Definition gamemtl.h:80
#define GAMEMTL_MAPPING_GRID
Definition gamemtl.h:81
#define GAMEMTL_MAPPING_ZIGZAG_LINEAR_OFFSET
Definition gamemtl.h:85
Class_ID PS2GameMaterialClassID
#define GAMEMTL_MAPPING_GRID_CLASSIC_ENV
Definition gamemtl.h:88
#define GAMEMTL_MAPPING_EDGE
Definition gamemtl.h:91
#define GAMEMTL_MAPPING_SINE_LINEAR_OFFSET
Definition gamemtl.h:83
#define GAMEMTL_MAPPING_GRID_ENVIRONMENT
Definition gamemtl.h:89
#define GAMEMTL_MAPPING_UV
Definition gamemtl.h:74
#define GAMEMTL_MAPPING_ROTATE
Definition gamemtl.h:82
#define GAMEMTL_MAPPING_ENV
Definition gamemtl.h:75
#define GAMEMTL_MAPPING_STEP_LINEAR_OFFSET
Definition gamemtl.h:84
#define GAMEMTL_MAPPING_WS_ENVIRONMENT
Definition gamemtl.h:87
Class_ID GameMaterialClassID
#define GAMEMTL_MAPPING_LINEAR_OFFSET
Definition gamemtl.h:78
MSG msg
Definition patch.cpp:409
uint8 PostDetailAlphaFunc
Definition w3d_file.h:883
uint8 DetailColorFunc
Definition w3d_file.h:878
uint8 DetailAlphaFunc
Definition w3d_file.h:879
uint8 PostDetailColorFunc
Definition w3d_file.h:882
uint8 SecGradient
Definition w3d_file.h:875
uint8 DepthCompare
Definition w3d_file.h:869
uint8 PriGradient
Definition w3d_file.h:874
W3dRGBStruct Emissive
Definition w3d_file.h:732
W3dRGBStruct Ambient
Definition w3d_file.h:729
W3dRGBStruct Specular
Definition w3d_file.h:731
W3dRGBStruct Diffuse
Definition w3d_file.h:730
#define Material