Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
shdsubmesh.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 : WWShade *
24 * *
25 * $Archive:: wwshade/shdsubmesh.cpp $*
26 * *
27 * Org Author:: Jani P *
28 * *
29 * Author : Kenny Mitchell *
30 * *
31 * $Modtime:: 07/12/02 10:31a $*
32 * *
33 * $Revision:: 1 $*
34 * *
35 * 07/12/02 KM Removed legacy mesh conversion *
36 *---------------------------------------------------------------------------------------------*
37 *---------------------------------------------------------------------------------------------*/
38
39#include "shddefmanager.h"
40#include "shdsubmesh.h"
41#include "shdrenderer.h"
42#include "shdlegacyw3d.h"
43#include "shdclassids.h"
44
45#include "chunkio.h"
46#include "texture.h"
47#include "w3d_file.h"
48#include "ww3d.h"
49#include "dx8fvf.h"
50#include "dx8wrapper.h"
51#include "meshmdl.h"
52#include "texture.h"
53#include "aabtree.h"
54#include "sharebuf.h"
55
57 :
58 Shader(NULL),
59 S(NULL),
60 T(NULL),
61 SxT(NULL),
66{
67 for (int i=0;i<MAX_TEXTURE_STAGES;++i)
68 {
69 UV[i]=NULL;
70 }
71}
72
74 :
75 Shader(NULL),
76 S(NULL),
77 T(NULL),
78 SxT(NULL),
83{
84 for (int i=0;i<MAX_TEXTURE_STAGES;++i)
85 {
86 UV[i]=NULL;
87 }
88 *this = that;
89}
90
92{
93 if (this != &that)
94 {
97 Sorting=that.Sorting;
99 for (int i=0;i<MAX_TEXTURE_STAGES;++i)
100 {
101 REF_PTR_SET(UV[i],that.UV[i]);
102 }
103
104 REF_PTR_SET(S,that.S);
105 REF_PTR_SET(T,that.T);
106 REF_PTR_SET(SxT,that.SxT);
107
110 }
111 return * this;
112}
113
114
116{
118 for (int i=0;i<MAX_TEXTURE_STAGES;++i)
119 {
121 }
122
126
128}
129
130// The legacy renderer is FVF-based so we need to figure out what FVF format to use
131static unsigned Define_FVF(MeshModelClass* mmc,bool enable_lighting)
132{
134 return dynamic_fvf_type;
135 }
137 return dynamic_fvf_type;
138 }
139
140 unsigned fvf=D3DFVF_XYZ;
141
142 int tex_coord_count=mmc->Get_UV_Array_Count();
143
144 if (mmc->Get_Color_Array(0,false)) {
145 fvf|=D3DFVF_DIFFUSE;
146 }
147 if (mmc->Get_Color_Array(1,false)) {
148 fvf|=D3DFVF_SPECULAR;
149 }
150
151 switch (tex_coord_count) {
152 default:
153 case 0:
154 break;
155 case 1: fvf|=D3DFVF_TEX1; break;
156 case 2: fvf|=D3DFVF_TEX2; break;
157 case 3: fvf|=D3DFVF_TEX3; break;
158 case 4: fvf|=D3DFVF_TEX4; break;
159 case 5: fvf|=D3DFVF_TEX5; break;
160 case 6: fvf|=D3DFVF_TEX6; break;
161 case 7: fvf|=D3DFVF_TEX7; break;
162 case 8: fvf|=D3DFVF_TEX8; break;
163 }
164
165 if (!mmc->Needs_Vertex_Normals()) { //enable_lighting || mmc->Get_Flag(MeshModelClass::PRELIT_MASK)) {
166 return fvf;
167 }
168
169 fvf|=D3DFVF_NORMAL; // Realtime-lit
170 return fvf;
171}
172
173
174// The legacy renderer is FVF-based so we need to figure out what FVF format to use
175static unsigned Define_FVF(ShdSubMeshClass* ssm,bool enable_lighting)
176{
178 return dynamic_fvf_type;
179 }
181 return dynamic_fvf_type;
182 }
183
184 unsigned fvf=D3DFVF_XYZ;
185
186 int tex_coord_count=0;
187 for (tex_coord_count=0;tex_coord_count < MeshMatDescClass::MAX_TEX_STAGES; tex_coord_count++) {
188 if (ssm->Get_UV_Array(tex_coord_count) == NULL) {
189 break;
190 }
191 }
192
193 if (ssm->Get_Diffuse_Array() != NULL) {
194 fvf|=D3DFVF_DIFFUSE;
195 }
196
197 switch (tex_coord_count) {
198 default:
199 case 0:
200 break;
201 case 1: fvf|=D3DFVF_TEX1; break;
202 case 2: fvf|=D3DFVF_TEX2; break;
203 case 3: fvf|=D3DFVF_TEX3; break;
204 case 4: fvf|=D3DFVF_TEX4; break;
205 case 5: fvf|=D3DFVF_TEX5; break;
206 case 6: fvf|=D3DFVF_TEX6; break;
207 case 7: fvf|=D3DFVF_TEX7; break;
208 case 8: fvf|=D3DFVF_TEX8; break;
209 }
210
211 if (ssm->Get_Vertex_Normal_Array() != NULL) {
212 fvf|=D3DFVF_NORMAL; // Realtime-lit
213 }
214
215 return fvf;
216}
217
218
220{
221 WWASSERT(first_polygon<model->Get_Polygon_Count());
222
224
225 int pass;
226
227 // Figure out how many polygons we can use
228 int active_polygon_count=0;
229 bool arrays_used=false;
230 for (pass=0;pass<model->Get_Pass_Count() && !arrays_used;++pass) {
231 if (model->Has_Shader_Array(pass) || model->Has_Material_Array(pass)) {
232 arrays_used=true;
233 break;
234 }
235 for (int stage=0;stage<MeshMatDescClass::MAX_TEX_STAGES;++stage) {
236 TextureClass* texture=NULL;
237 if (model->Has_Texture_Array(pass,stage)) {
238 arrays_used=true;
239 break;
240 }
241 }
242 }
243
244 // If any arrays are used by the mesh, count how many polygons we have that share properties.
245 if (arrays_used) {
246 bool stop=false;
247 active_polygon_count=0;
248 for (int poly=first_polygon;poly<model->Get_Polygon_Count() && !stop;++poly) {
249 for (pass=0;pass<model->Get_Pass_Count();++pass) {
250 if (model->Has_Shader_Array(pass)) {
251 if (model->Get_Shader(first_polygon,pass)!=model->Get_Shader(poly,pass)) {
252 stop=true;
253 break;
254 }
255 }
256
257 if (model->Has_Material_Array(pass)) {
258 TriIndex first_tri=model->Get_Polygon_Array()[first_polygon];
259 TriIndex cur_tri=model->Get_Polygon_Array()[poly];
260 if (model->Peek_Material(first_tri[0],pass)!=model->Peek_Material(cur_tri[0],pass) ||
261 model->Peek_Material(first_tri[1],pass)!=model->Peek_Material(cur_tri[1],pass) ||
262 model->Peek_Material(first_tri[2],pass)!=model->Peek_Material(cur_tri[2],pass)) {
263 stop=true;
264 break;
265 }
266 }
267
268 for (int stage=0;stage<MeshMatDescClass::MAX_TEX_STAGES;++stage) {
269 if (model->Has_Texture_Array(pass,stage)) {
270 if (model->Peek_Texture(first_polygon,pass,stage)!=model->Peek_Texture(poly,pass,stage)) {
271 stop=true;
272 break;
273 }
274 }
275 }
276 }
277 active_polygon_count++;
278 }
279 }
280 FirstVisiblePolygon=first_polygon;
281 VisiblePolygonCount=active_polygon_count;
284 }
286
287 // Now that the definition is initialized, create a shader instance (there's really
288 // only one def/instance pair with the legacy meshes, no optimization planned currently)
290 Shader=shader_def->Create();
291 REF_PTR_RELEASE(shader_def);
292
293 // Danger! We're assuming Shd6LegacyW3DClass is the only type created by legacy shader!!!
294 ((Shd6LegacyW3DClass*)Shader)->Set_FVF(Define_FVF(model,true));
295 ((Shd6LegacyW3DClass*)Shader)->Set_Pass_Count(model->Get_Pass_Count());
296
297 for (pass=0;pass<model->Get_Pass_Count();++pass) {
299 if (model->Has_Shader_Array(pass)) {
300 legacy_shader=model->Get_Shader(first_polygon,pass);
301 }
302 else {
303 legacy_shader=model->Get_Single_Shader(pass);
304 }
305
306 VertexMaterialClass* legacy_material=NULL;
307 if (model->Has_Material_Array(pass)) {
308 TriIndex first_tri=model->Get_Polygon_Array()[first_polygon];
309 legacy_material=model->Get_Material(first_tri[0],pass);
310 }
311 else {
312 legacy_material=model->Get_Single_Material(pass);
313 }
314
315 for (int stage=0;stage<MeshMatDescClass::MAX_TEX_STAGES;++stage) {
316 TextureClass* texture=NULL;
317 if (model->Has_Texture_Array(pass,stage)) {
318 texture=model->Get_Texture(first_polygon,pass,stage);
319 }
320 else {
321 texture=model->Get_Single_Texture(pass,stage);
322 }
323
324 if (texture) {
325// StringClass texture_name=texture->Get_Full_Path();
326// texture->Release_Ref();
327// shader_def->Set_Texture_Name(pass,stage,texture_name);
328 ((Shd6LegacyW3DClass*)Shader)->Set_Texture(pass,stage,texture);
329 texture->Release_Ref();
330 }
331 }
332
333
334 ((Shd6LegacyW3DClass*)Shader)->Set_Shader(pass,legacy_shader);
335 ((Shd6LegacyW3DClass*)Shader)->Set_Material(pass,legacy_material);
336 }
337
338 *(MeshGeometryClass*)this = *(MeshGeometryClass*)model;
339 if (CullTree)
340 CullTree->Set_Mesh(this);
341
342 // Copy texture coordinates
343 int uv_array_count=model->Get_UV_Array_Count();
344 WWASSERT(uv_array_count<=MAX_TEXTURE_STAGES);
345 for (int uvi=0;uvi<uv_array_count;++uvi) {
346 const Vector2 *uv=model->Get_UV_Array_By_Index(uvi);
347 if (uv) {
348 UV[uvi]=NEW_REF(ShareBufferClass<Vector2>,(model->Get_Vertex_Count(),"ShdSubMeshClass::UVCoords"));
349 memcpy(UV[uvi]->Get_Array(),uv,sizeof(Vector2)*model->Get_Vertex_Count());
350 }
351 }
352
353 // Copy vertex color array
354 const unsigned* diffuse=model->Get_DCG_Array(0);
355 if (diffuse) {
356 Diffuse=NEW_REF(ShareBufferClass<unsigned>,(model->Get_Vertex_Count(),"ShdSubMeshClass::Diffuse"));
357 memcpy(Diffuse->Get_Array(),diffuse,sizeof(unsigned)*model->Get_Vertex_Count());
358 }
359
360}
361
362
364{
365 // read header
367 cload.Open_Chunk();
368 if
369 (
370 cload.Read
371 (
372 &hdr,
375 )
376 {
378 }
379 cload.Close_Chunk();
380
381 // process header
382 PolyCount=hdr.NumTris;
384
385 if ((PolyCount!=0) && (VertexCount!=0))
386 {
387 Poly = NEW_REF(ShareBufferClass<TriIndex>,(PolyCount,"ShdSubMesh::Poly"));
388 PolySurfaceType = NEW_REF(ShareBufferClass<uint8>,(PolyCount,"ShdSubMesh::PolySurfaceType"));
389 Vertex = NEW_REF(ShareBufferClass<Vector3>,(VertexCount,"ShdSubMesh::Vertex"));
390
391 Poly->Clear();
392 PolySurfaceType->Clear();
393 Vertex->Clear();
394
395#if (!OPTIMIZE_VNORM_RAM)
396 VertexNorm =NEW_REF(ShareBufferClass<Vector3>,(VertexCount,"ShdSubMesh::VertexNorm"));
397 VertexNorm->Clear();
398#endif
399 }
400
401 BoundBoxMin.Set(hdr.BoxMin.X,hdr.BoxMin.Y,hdr.BoxMin.Z);
402 BoundBoxMax.Set(hdr.BoxMax.X,hdr.BoxMax.Y,hdr.BoxMax.Z);
405
406 read_chunks(cload);
407
408 if ((Shader->Peek_Definition() != NULL) && (Shader->Peek_Definition()->Get_Class_ID() == SHDDEF_CLASSID_LEGACYW3D)) {
409 // Danger! We're assuming Shd6LegacyW3DClass is the only type created by legacy shader!!!
410 Shd6LegacyW3DClass * legacy_shader = (Shd6LegacyW3DClass*)Shader;
411 legacy_shader->Set_FVF(Define_FVF(this,true));
412 if (!legacy_shader->Is_Opaque()) {
414 }
415 }
416
417 return WW3D_ERROR_OK;
418}
419
420
421/***********************************************************************************************
422 * ShdSubMeshClass::read_chunks -- read w3d chunks *
423 * *
424 * *
425 * INPUT: *
426 * *
427 * OUTPUT: *
428 * *
429 * WARNINGS: *
430 * *
431 * HISTORY: *
432 * 5/21/2002 kjm : Created. *
433 *=============================================================================================*/
435{
436 // If there are no more chunks within the mesh chunk,
437 // we are done.
438
439 while (cload.Open_Chunk())
440 {
441 // Process the chunk
443
444 switch (cload.Cur_Chunk_ID())
445 {
446 case W3D_CHUNK_SHDSUBMESH_VERTICES : error=read_vertices(cload); break;
448 case W3D_CHUNK_SHDSUBMESH_UV0 : error=read_uv0(cload); break;
449 case W3D_CHUNK_SHDSUBMESH_UV1 : error=read_uv1(cload); break;
450
454
455 case W3D_CHUNK_SHDSUBMESH_TRIANGLES : error=read_triangles(cload); break;
457 case W3D_CHUNK_SHDSUBMESH_SHADER : error=read_shader(cload); break;
459 default: break;
460 }
461
462 cload.Close_Chunk();
463
464 if (error!=WW3D_ERROR_OK)
465 {
466 return error;
467 }
468 }
469
470 return WW3D_ERROR_OK;
471}
472
473
474/***********************************************************************************************
475 * ShdSubMeshClass::read_vertices -- read the vertex chunk from a W3D file *
476 * *
477 * INPUT: *
478 * *
479 * OUTPUT: *
480 * *
481 * WARNINGS: *
482 * *
483 * HISTORY: *
484 * 5/21/2002 kjm : Created. *
485 *=============================================================================================*/
487{
488 W3dVectorStruct vert;
489 Vector3* loc=Vertex->Get_Array();
490 assert(loc);
491
492 for (int i=0; i<Get_Vertex_Count(); i++)
493 {
494 if (cload.Read(&vert,sizeof(W3dVectorStruct)) != sizeof(W3dVectorStruct))
495 {
497 }
498
499 loc[i].X=vert.X;
500 loc[i].Y=vert.Y;
501 loc[i].Z=vert.Z;
502 }
503
504 return WW3D_ERROR_OK;
505}
506
507
508/***********************************************************************************************
509 * ShdSubMeshClass::read_vertex_normals -- read the vertex normals chunk from a w3d file *
510 * *
511 * INPUT: *
512 * *
513 * OUTPUT: *
514 * *
515 * WARNINGS: *
516 * *
517 * HISTORY: *
518 * 5/21/2002 kjm : Created. *
519 *=============================================================================================*/
521{
522 W3dVectorStruct norm;
523 Vector3 * mdlnorms=get_vert_normals();
524 WWASSERT(mdlnorms);
525
526 for (int i=0; i<VertexCount; i++)
527 {
528 if (cload.Read(&norm,sizeof(W3dVectorStruct)) != sizeof(W3dVectorStruct))
529 {
531 }
532
533 mdlnorms[i].Set(norm.X,norm.Y,norm.Z);
534 }
535
536 return WW3D_ERROR_OK;
537}
538
539/***********************************************************************************************
540 * ShdSubMeshClass::read_uv0 -- read the texture coords chunk from a w3d file *
541 * *
542 * INPUT: *
543 * *
544 * OUTPUT: *
545 * *
546 * WARNINGS: *
547 * *
548 * HISTORY: *
549 * 5/26/2002 kjm : Created. *
550 *=============================================================================================*/
552{
553 UV[0]=NEW_REF(ShareBufferClass<Vector2>,(VertexCount,"ShdSubMeshClass::UV"));
554 UV[0]->Clear();
555
556 Vector2* uv=UV[0]->Get_Array();
557
558 for (int i=0; i<VertexCount; i++)
559 {
560 if
561 (
562 cload.Read
563 (
564 uv++,
565 sizeof(Vector2)
566 )!=sizeof(Vector2)
567 )
568 {
570 }
571 }
572
573 return WW3D_ERROR_OK;
574
575}
576
577/***********************************************************************************************
578 * ShdSubMeshClass::read_uv1 -- read the texture coords chunk from a w3d file *
579 * *
580 * INPUT: *
581 * *
582 * OUTPUT: *
583 * *
584 * WARNINGS: *
585 * *
586 * HISTORY: *
587 * 5/26/2002 kjm : Created. *
588 *=============================================================================================*/
590{
591 UV[1]=NEW_REF(ShareBufferClass<Vector2>,(VertexCount,"ShdSubMeshClass::UV"));
592 UV[1]->Clear();
593
594 Vector2* uv=UV[1]->Get_Array();
595
596 for (int i=0; i<VertexCount; i++)
597 {
598 if
599 (
600 cload.Read
601 (
602 uv++,
603 sizeof(Vector2)
604 )!=sizeof(Vector2)
605 )
606 {
608 }
609 }
610
611 return WW3D_ERROR_OK;
612
613}
614
615/***********************************************************************************************
616 * ShdSubMeshClass::read_tangent_basis_s -- read the tangent basis chunk from a w3d file *
617 * *
618 * INPUT: *
619 * *
620 * OUTPUT: *
621 * *
622 * WARNINGS: *
623 * *
624 * HISTORY: *
625 * 5/26/2002 kjm : Created. *
626 *=============================================================================================*/
628{
629 S=NEW_REF(ShareBufferClass<Vector3>,(VertexCount,"ShdSubMeshClass::S"));
630 S->Clear();
631
632 Vector3* t=S->Get_Array();
633
634 for (int i=0; i<VertexCount; i++)
635 {
636 if
637 (
638 cload.Read
639 (
640 t++,
641 sizeof(Vector3)
642 )!=sizeof(Vector3)
643 )
644 {
646 }
647 }
648
649 return WW3D_ERROR_OK;
650
651}
652
653/***********************************************************************************************
654 * ShdSubMeshClass::read_tangent_basis_t -- read the tangent basis chunk from a w3d file *
655 * *
656 * INPUT: *
657 * *
658 * OUTPUT: *
659 * *
660 * WARNINGS: *
661 * *
662 * HISTORY: *
663 * 5/26/2002 kjm : Created. *
664 *=============================================================================================*/
666{
667 T=NEW_REF(ShareBufferClass<Vector3>,(VertexCount,"ShdSubMeshClass::T"));
668 T->Clear();
669
670 Vector3* t=T->Get_Array();
671
672 for (int i=0; i<VertexCount; i++)
673 {
674 if
675 (
676 cload.Read
677 (
678 t++,
679 sizeof(Vector3)
680 )!=sizeof(Vector3)
681 )
682 {
684 }
685 }
686
687 return WW3D_ERROR_OK;
688
689}
690
691/***********************************************************************************************
692 * ShdSubMeshClass::read_tangent_basis_sxt -- read the tangent basis chunk from a w3d file *
693 * *
694 * INPUT: *
695 * *
696 * OUTPUT: *
697 * *
698 * WARNINGS: *
699 * *
700 * HISTORY: *
701 * 5/26/2002 kjm : Created. *
702 *=============================================================================================*/
704{
705 SxT=NEW_REF(ShareBufferClass<Vector3>,(VertexCount,"ShdSubMeshClass::SxT"));
706 SxT->Clear();
707
708 Vector3* t=SxT->Get_Array();
709
710 for (int i=0; i<VertexCount; i++)
711 {
712 if
713 (
714 cload.Read
715 (
716 t++,
717 sizeof(Vector3)
718 )!=sizeof(Vector3)
719 )
720 {
722 }
723 }
724
725 return WW3D_ERROR_OK;
726
727}
728
729/***********************************************************************************************
730 * ShdSubMeshClass::read_vertex_influences -- read the vertex bone links from a w3d file *
731 * *
732 * This is for WWSKin support, presumably when we implement HW skining this may become obsolete*
733 * *
734 * INPUT: *
735 * *
736 * OUTPUT: *
737 * *
738 * WARNINGS: *
739 * *
740 * HISTORY: *
741 * 11/07/2002 gth: Created *
742 *=============================================================================================*/
744{
745 uint16 * bone_links = get_bone_links();
746
747 for (int i=0; i<VertexCount; i++)
748 {
749 if
750 (
751 cload.Read
752 (
753 bone_links++,
754 sizeof(uint8)
755 )!=sizeof(uint8)
756 )
757 {
759 }
760 }
761
762 Set_Flag(SKIN,true);
763
764 return WW3D_ERROR_OK;
765}
766
767/***********************************************************************************************
768 * ShdSubMeshClass::read_triangles -- read the triangles chunk from a w3d file *
769 * *
770 * INPUT: *
771 * *
772 * OUTPUT: *
773 * *
774 * WARNINGS: *
775 * *
776 * HISTORY: *
777 * 5/21/2002 kjm : Created. *
778 *=============================================================================================*/
780{
781 unsigned short tri[3];
782
783 // cache pointers to various arrays in the surrender mesh
784 TriIndex * vi = get_polys();
785 Set_Flag(DIRTY_PLANES,false);
786// Vector4 * peq = get_planes();
787// uint8 * surface_types = Get_Poly_Surface_Type_Array();
788
789 // read in each polygon one by one
790 for (int i=0; i<Get_Polygon_Count(); i++)
791 {
792 if
793 (
794 cload.Read
795 (
796 tri,
797 sizeof(unsigned short)*3
798 )!=sizeof(unsigned short)*3
799 )
800 {
802 }
803
804 // set the vertex indices
805 vi[i].I = tri[0];
806 vi[i].J = tri[1];
807 vi[i].K = tri[2];
808
809 // set the normal
810 /*peq[i].X = tri.Normal.X;
811 peq[i].Y = tri.Normal.Y;
812 peq[i].Z = tri.Normal.Z;
813 peq[i].W = -tri.Dist;
814
815 // set the surface type
816 WWASSERT(tri.Attributes < 256);
817 surface_types[i] = (uint8)(tri.Attributes);*/
818 }
819
820 return WW3D_ERROR_OK;
821}
822
823/***********************************************************************************************
824 * ShdSubMeshClass::read_vertex_shade_indices -- read the vertex shade indices chunk *
825 * *
826 * INPUT: *
827 * *
828 * OUTPUT: *
829 * *
830 * WARNINGS: *
831 * *
832 * HISTORY: *
833 * 5/21/2002 kjm : Created. *
834 *=============================================================================================*/
836{
837 uint32 * shade_index = get_shade_indices(true);
838 uint32 si;
839
840 for (int i=0; i<Get_Vertex_Count(); i++)
841 {
842 if (cload.Read(&si,sizeof(uint32)) != sizeof(uint32))
843 {
845 }
846 shade_index[i] = si;
847 }
848 return WW3D_ERROR_OK;
849}
850
851
852/***********************************************************************************************
853 * ShdSubMeshClass::read_shader -- read the shader chunk *
854 * *
855 * INPUT: *
856 * *
857 * OUTPUT: *
858 * *
859 * WARNINGS: *
860 * *
861 * HISTORY: *
862 * 5/21/2002 kjm : Created. *
863 *=============================================================================================*/
865{
866 // load the shader definition
867 ShdDefClass* shddef=NULL;
868
869 ShdDefManagerClass::Load_Shader(cload, &shddef);
870
871 // create the shader interface
872 Shader=shddef->Create();
873
874 REF_PTR_RELEASE(shddef);
875 return WW3D_ERROR_OK;
876}
877
878
879/***********************************************************************************************
880 * ShdSubMesh::Get_Deformed_Vertices -- Gets the deformed vertices for a skin *
881 * *
882 * INPUT: *
883 * *
884 * OUTPUT: *
885 * *
886 * WARNINGS: *
887 * *
888 * HISTORY: *
889 * 3/4/2001 gth : Created. *
890 *=============================================================================================*/
891void ShdSubMeshClass::Get_Deformed_Vertices(Vector3 *dst_vert, Vector3 *dst_norm, const HTreeClass* htree)
892{
894 WWASSERT(htree);
895 get_deformed_vertices(dst_vert,dst_norm,htree);
896}
897
898
899/***********************************************************************************************
900 * ShdSubMeshClass::Get_Deformed_Vertices -- Gets the deformed vertices for a skin *
901 * *
902 * INPUT: *
903 * *
904 * OUTPUT: *
905 * *
906 * WARNINGS: *
907 * *
908 * HISTORY: *
909 * 3/4/2001 gth : Created. *
910 *=============================================================================================*/
912{
914 WWASSERT(htree);
915
916 get_deformed_vertices(dst_vert,htree);
917}
#define NULL
Definition BaseType.h:92
#define WWASSERT
@ W3D_CHUNK_SHDSUBMESH_SHADER
Definition w3d_file.h:499
@ W3D_CHUNK_SHDSUBMESH_VERTEX_SHADE_INDICES
Definition w3d_file.h:506
@ W3D_CHUNK_SHDSUBMESH_TANGENT_BASIS_S
Definition w3d_file.h:511
@ W3D_CHUNK_SHDSUBMESH_VERTEX_NORMALS
Definition w3d_file.h:504
@ W3D_CHUNK_SHDSUBMESH_TRIANGLES
Definition w3d_file.h:505
@ W3D_CHUNK_SHDSUBMESH_TANGENT_BASIS_SxT
Definition w3d_file.h:513
@ W3D_CHUNK_SHDSUBMESH_VERTICES
Definition w3d_file.h:503
@ W3D_CHUNK_SHDSUBMESH_UV0
Definition w3d_file.h:508
@ W3D_CHUNK_SHDSUBMESH_UV1
Definition w3d_file.h:509
@ W3D_CHUNK_SHDSUBMESH_VERTEX_INFLUENCES
Definition w3d_file.h:516
@ W3D_CHUNK_SHDSUBMESH_TANGENT_BASIS_T
Definition w3d_file.h:512
unsigned short uint16
Definition bittype.h:45
unsigned long uint32
Definition bittype.h:46
unsigned char uint8
Definition bittype.h:44
@ false
Definition bool.h:59
bool Close_Chunk()
Definition chunkio.cpp:448
uint32 Cur_Chunk_ID()
Definition chunkio.cpp:484
uint32 Read(void *buf, uint32 nbytes)
Definition chunkio.cpp:692
bool Open_Chunk()
Definition chunkio.cpp:412
uint32 * get_shade_indices(bool create=true)
ShareBufferClass< uint8 > * PolySurfaceType
ShareBufferClass< Vector3 > * Vertex
const Vector3 * Get_Vertex_Normal_Array(void)
int Get_Vertex_Count(void) const
TriIndex * get_polys(void)
const TriIndex * Get_Polygon_Array(void)
ShareBufferClass< Vector3 > * VertexNorm
AABTreeClass * CullTree
MeshGeometryClass & operator=(const MeshGeometryClass &that)
uint16 * get_bone_links(bool create=true)
ShareBufferClass< TriIndex > * Poly
void Set_Flag(FlagsType flag, bool onoff)
int Get_Polygon_Count(void) const
void get_deformed_vertices(Vector3 *dst_vert, Vector3 *dst_norm, const HTreeClass *htree)
Vector3 BoundSphereCenter
int Get_Flag(FlagsType flag)
Vector3 * get_vert_normals(void)
TextureClass * Peek_Texture(int pidx, int pass=0, int stage=0) const
Definition meshmdl.h:217
bool Has_Shader_Array(int pass) const
Definition meshmdl.h:207
unsigned * Get_DCG_Array(int pass)
Definition meshmdl.h:180
unsigned * Get_Color_Array(int array_index, bool create=true)
Definition meshmdl.h:185
bool Needs_Vertex_Normals(void)
Definition meshmdl.cpp:361
const Vector2 * Get_UV_Array_By_Index(int index)
Definition meshmdl.h:178
VertexMaterialClass * Peek_Material(int vidx, int pass=0) const
Definition meshmdl.h:216
bool Has_Material_Array(int pass) const
Definition meshmdl.h:206
int Get_Pass_Count(void) const
Definition meshmdl.h:174
TextureClass * Get_Texture(int pidx, int pass=0, int stage=0) const
Definition meshmdl.h:212
VertexMaterialClass * Get_Single_Material(int pass=0) const
Definition meshmdl.h:192
bool Has_Texture_Array(int pass, int stage) const
Definition meshmdl.h:208
TextureClass * Get_Single_Texture(int pass=0, int stage=0) const
Definition meshmdl.h:193
VertexMaterialClass * Get_Material(int vidx, int pass=0) const
Definition meshmdl.h:211
int Get_UV_Array_Count(void)
Definition meshmdl.h:177
ShaderClass Get_Shader(int pidx, int pass=0) const
Definition meshmdl.h:213
ShaderClass Get_Single_Shader(int pass=0) const
Definition meshmdl.h:194
WWINLINE void Release_Ref(void) const
Definition refcount.h:146
static ShaderClass _PresetOpaqueShader
Definition shader.h:365
virtual bool Is_Opaque(void) const
void Set_FVF(unsigned fvf)
virtual ShdInterfaceClass * Create(void) const =0
static void Load_Shader(ChunkLoadClass &cload, ShdDefClass **shddef)
virtual ShdInterfaceClass * Create() const
WW3DErrorType read_uv0(ChunkLoadClass &cload)
WW3DErrorType read_vertex_influences(ChunkLoadClass &cload)
ShareBufferClass< Vector3 > * S
Definition shdsubmesh.h:113
WW3DErrorType read_tangent_basis_s(ChunkLoadClass &cload)
WW3DErrorType read_shader(ChunkLoadClass &cload)
void Init_From_Legacy_Mesh_Model(MeshModelClass *model, int first_polygon)
ShareBufferClass< Vector2 > * UV[MAX_TEXTURE_STAGES]
Definition shdsubmesh.h:110
ShareBufferClass< Vector3 > * SxT
Definition shdsubmesh.h:115
const Vector2 * Get_UV_Array(unsigned stage)
Definition shdsubmesh.h:94
WW3DErrorType read_chunks(ChunkLoadClass &cload)
WW3DErrorType Load_W3D(ChunkLoadClass &cload)
ShareBufferClass< unsigned > * Diffuse
Definition shdsubmesh.h:111
WW3DErrorType read_vertex_shade_indices(ChunkLoadClass &cload)
const unsigned * Get_Diffuse_Array()
Definition shdsubmesh.h:95
WW3DErrorType read_tangent_basis_t(ChunkLoadClass &cload)
WW3DErrorType read_triangles(ChunkLoadClass &cload)
WW3DErrorType read_uv1(ChunkLoadClass &cload)
void Get_Deformed_Vertices(Vector3 *dst_vert, Vector3 *dst_norm, const HTreeClass *htree)
ShdSubMeshClass & operator=(const ShdSubMeshClass &that)
ShdInterfaceClass * Shader
Definition shdsubmesh.h:170
WW3DErrorType read_vertices(ChunkLoadClass &cload)
WW3DErrorType read_vertex_normals(ChunkLoadClass &cload)
WW3DErrorType read_tangent_basis_sxt(ChunkLoadClass &cload)
ShareBufferClass< Vector3 > * T
Definition shdsubmesh.h:114
float X
Definition vector3.h:90
float Z
Definition vector3.h:92
float Y
Definition vector3.h:91
WWINLINE void Set(float x, float y, float z)
Definition vector3.h:103
unsigned short K
Definition Vector3i.h:102
unsigned short J
Definition Vector3i.h:101
unsigned short I
Definition Vector3i.h:100
static bool Is_Sorting_Enabled(void)
Definition ww3d.h:220
const unsigned dynamic_fvf_type
const unsigned MAX_TEXTURE_STAGES
Definition dx8wrapper.h:76
Vector3i16 TriIndex
#define REF_PTR_RELEASE(x)
Definition refcount.h:80
#define REF_PTR_SET(dst, src)
Definition refcount.h:79
#define NEW_REF(C, P)
Definition refcount.h:62
@ SHDDEF_CLASSID_LEGACYW3D
Definition shdclassids.h:54
W3dVectorStruct SphCenter
Definition w3d_file.h:2235
W3dVectorStruct BoxMin
Definition w3d_file.h:2233
W3dVectorStruct BoxMax
Definition w3d_file.h:2234
WW3DErrorType
Definition w3derr.h:51
@ WW3D_ERROR_LOAD_FAILED
Definition w3derr.h:54
@ WW3D_ERROR_OK
Definition w3derr.h:52